import random #Program will be making use of random numbers so you have to import the random library def board2(x,y):#This is the function that displays the board a=["__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__","__"] # ABOVE is the array that stores the value fo each square. each value is two undelined spaces # BELOW The variables X and Y are passed to this function. They represent the players score. This loop loops through the array using the variable I. # BELOW If i=x or 1= y or they both = i then the if statement below writes the appropriate letters in the array. for i in range(50): if i==x and i==y: a[i]="AB" elif i==x: a[i]="A_" elif i==y: a[i]="_B" #BELOW the board is printed with the array being updated based on the values of X and Y print("|_"+a[43] +"_|_"+a[44] +"_|_"+a[45] +"_|_"+a[46] +"_|_"+a[47] +"_|_"+a[48] +"_|_"+a[49] + "_|") print("|_"+a[42] +"_|_"+a[41] +"_|_"+a[40] +"_|_"+a[39] +"_|_"+a[38] +"_|_"+a[37] +"_|_"+a[36] + "_|") print("|_"+a[29] +"_|_"+a[30] +"_|_"+a[31] +"_|_"+a[32] +"_|_"+a[33] +"_|_"+a[34] +"_|_"+a[35] + "_|") print("|_"+a[28] +"_|_"+a[27] +"_|_"+a[26] +"_|_"+a[25] +"_|_"+a[24] +"_|_"+a[23] +"_|_"+a[22] + "_|") print("|_"+a[15] +"_|_"+a[16] +"_|_"+a[17] +"_|_"+a[18] +"_|_"+a[19] +"_|_"+a[20] +"_|_"+a[21] + "_|") print("|_"+a[14] +"_|_"+a[13] +"_|_"+a[12] +"_|_"+a[11] +"_|_"+a[10] +"_|_"+a[9] +"_|_"+a[8] + "_|") print("|_"+a[1] +"_|_"+a[2] +"_|_"+a[3] +"_|_"+a[4] +"_|_"+a[5] +"_|_"+a[6] +"_|_"+a[7] + "_|") print("Welcome to the big number game") while True: # This loop will ask how many players until they type a correct response. play=input("Would you like A: 1 player or B: 2 player game") if play=="A": players=1 break elif play=="B": players=2 break else: continue if players==2: # The main algorithm for if there are TWO players print(str(players) + " player game") print("Let's play") x=1 # Obviously a new game so let's reset those counter variables y=1 board2(x,y)# prints the board with x and Y being 1 (first squar on the board) while True:#The main game loop. This will run until a player rwaches above 49, then we will break from the loop input("press enter to roll the dice player 1") go1=random.randint(1,7)#generates random numbers and puts them in the variables GO1 and GO2 go2=random.randint(1,7) if go1==go2:# Checks for a double print("oh no a double. You have to go back!") x=x-(go1+go2)#updates x (which is the counter) by taking GO1 and GO2 away if x<1:# Just in case the above subtraction takes the X counter below 1 x=1 else: # If not a double we add GO1 and GO 2 to the X counter x=x+go1+go2 print("You rolled a " + str(go1)+ " and a " + str(go2)) if x>48: x=49 board2(x,y) #Calls the function with the new X and Y values if x<49:#If X (player 1's score) is still less than 49, the game continues, coz he hasn't won input("press enter to roll the dice player 2")#Same as above but for player 2 and using the counter Y go3=random.randint(1,7) go4=random.randint(1,7) if go3==go4: print("oh no a double. You have to go back!") y=y-(go3+go4) if y<1: y=1 else: y=y+go3+go4 print("You rolled a " + str(go3)+ " and a " + str(go4)) if y>48: y=49 board2(x,y) if y>48:# If Y greater than 48, player two is the winner win="B" break # breaks the loop, no more turns else:#If X is not less than 49, player one is the winner win="A" break # breaks the loop, no more turns else: # This is the one player game. It is similar to the 2 player game but we just ask for X to be played, we set Y to zero so it can't be seen on the board print(str(players) + " player game") print("Let's play") x=1 y=0 board2(x,y) while True: input("press enter to roll the dice player 1") go1=random.randint(1,7) go2=random.randint(1,7) if go1==go2: print("oh no a double. You have to go back!") x=x-(go1+go2) if x<1: x=1 else: x=x+go1+go2 print("You rolled a " + str(go1)+ " and a " + str(go2)) board2(x,y) if x>48: win="A" break if win=="A":#Checks the vaue of the variable A and prints out a well done message 100 times! for i in range(100): print("Well done player 1") else: for i in range(100): print("Well done player 2")