// 


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[])
{

  srand(time(0));//Initializing random number generator
  
  int A,B,i,count=0,P=0,BoardPosition[99];//declaring variables that will be used to build the game
  
  // the loop here assigns the numbers in the Possition araay to 0
  // in order to use only a few of them to represent the snakes and ladders
  for(i=0;i<=99;i++)
  {
    BoardPosition[i]=0;
        }
        // here assigning the positions of Ladders and Snakes 
        // positive numbers means it is a ladder and it is an advantage will move player forward
        // negative numbers means it is a Snake and it is a disadvantage will take player down
    BoardPosition[4]=22;
    BoardPosition[23]=-18;
    BoardPosition[9]=21;
    BoardPosition[19]=19;
    BoardPosition[37]=22;
    BoardPosition[65]=-25;
    BoardPosition[48]=21;
    BoardPosition[50]=-23;
    BoardPosition[54]=-30;
    BoardPosition[60]=33;
    BoardPosition[98]=-31;
    BoardPosition[81]=-23;
    BoardPosition[94]=-24;
    
    for (i=0;i<=99;i++)
    {
        A=rand()% 6+1; // generating the first dice random number
        B=rand()% 6+1; // generating the second dice random number
        P=P+A+B; // adding to player`s position the numbers apeared in dices
        
        // here if condition to insure player do not exceed numbers of board
        if(P>99){
            break;
        }
        else
        {
            printf("Dices: %i,%i   ",A,B); 
            P=P+BoardPosition[P]; // here it reads what is on board, Snake? or Ladder? and adjust Position accordingly
            printf("you are in position : %i\n",P);
            
        }
        
        
        count=count+1; // number of moves
        
        
        
        }
        
        printf("cangatulaitons you won in %i moves ..\n",count);
  
  
  system("PAUSE");	
  return 0;
}
