· 9 years ago · Nov 14, 2016, 11:16 AM
1# CHECKERS Game Bot v/s Human
2"""
3MANUAL
4
5Global Variables Used:
6 1. bot_c : keeps records of number of checkers bot has
7 2. user_c : keeps records of number of checkers user has
8 3. board[][] : game board. stores states of gameplay. position of checkers.
9 4. src_i[] : variable to store parsed value of source_row (string -> int)
10 5. src_j[] : variable to store parsed value of source_col (string -> int)
11 6. dest_i[] : variable to store parsed value of destination_row (string -> int)
12 7. src_j[] : variable to store parsed value of destination_col (string -> int)
13 8. bi : flag variable to determine if checker can move in both directinos i.e. KING checker
14 9. inSrcI : variable to traverse in src_i
15 10. inSrcJ : variable to tracerse in src_j
16 11. botX[] : list to store row indexes of checkers of bot on board
17 12. botY[] : list to store column indexes of checkers of bot on board
18 13. userX[] : list to store row indexes of checkers of user on board
19 14. userY[] : list to store column indexes of checkers of user on board
20
21Function Description:
22 1. error(1) : displays error message for invalid move.
23 2. result(0/1) : declares winner.
24 3. checkDraw(to find) : checks if both of user and bot has no moves to play.
25 4. checkWin(to find) : checks if any of user or bot has won the game.
26 5. gameLogic(6) : bot moves determined by certain logics.
27 6. process_data(1) : obtains string -> data for array traversal
28 7. userInput(6) : gets user input; uses process_data(); updates board[][]; checks for invalid moves.
29 8. post(8 : actual game play; calls all the required functions needed to logically play
30 9. pre(1) : instructions and artwork.
31 10. logo(0) : CHECKERS logo on top of first screen.
32 11. preProcess(1) : assign movable areas to board. movable areas '-' and immovable areas '+'.
33 12. instructions(0) : necessary instructions to understand and play the game.
34 13. gameBoard(1) : displays contents of board[][] in matrix form.
35 14. gameBoardI(1) : copy of gameBoard(); with few values to be featured in instructions()
36 15. cmdArt(0) : to resize console screen
37 16. clrscr(0) : clear screen command.
38 17. next(0) : prompts user to press enter to proceed.
39 18. bid(1) : dice rolling mechanism to determine who makes the first move.
40 19. bot(3) : initializes bot checkers on board
41 20. user(3) : initializes user checkers on board
42 21. displayStats(3) : to show number of checkers each bot & user having after each move.
43 22. tied(0) : better graphical view of game tie notification.
44 23. userInputCapturing(6) : to avoid redundance, a sub function of userInput() - controls checker capturing. features spree notification.
45 24. spree(3) : to check if more than one checker can be captured.
46 25. spreeUp(3) : sub function of spree() to avoid redundancy.
47 26. mod(1) : to return absolute value
48"""
49import sys, os, time, random
50
51def mod(num):
52 if num<0:
53 return int(num*-1)
54 else:
55 return int(num)
56
57def error(message):
58 print("\nInvalid Move!"+str(message))
59 return
60
61def result(val): #tested
62 if val == 0:
63 clrscr()
64 print("\ / _ ")
65 print(" \ / ____ ____ \ ")
66 print(" - - | | | | | | | | |\ | o \\")
67 print(" | | | | | | /\ | | | | \ | |")
68 print(" | | | | | | / \ | | | | \ | o /")
69 print(" | |____| |____| |/ \| |____| | \| _/ ")
70 else:
71 clrscr()
72 print(" _")
73 print(" ___ ___ _____ ____ / ")
74 print(" | \ | | | | | | | |\ | o / ")
75 print(" |___/ | | | | /\ | | | | \ | | ")
76 print(" | \ | | | | / \ | | | | \ | o \ ")
77 print(" |___/ |___| | |/ \| |____| | \| \_")
78 return
79
80def checkDraw(board):
81 #tied()
82 return False
83
84def checkWin(board, user_c, bot_c): #modify win = 0 for user win and 1 for bot win
85 if bot_c == 0:
86 result(int(0))
87 return True
88 elif user_c == 0:
89 result(int(1))
90 return True
91 else:
92 #check if immovable condition exists
93 #else:
94 return False
95
96def bestMove(board, x, y, flag):
97 #create a tree/data structure of all possible moves of checkers. then select the deepest path to proceed.
98
99 """b = board #temporary variable
100 for i in range(0,len(x)):
101 ox = x[i]
102 oy = y[i]
103 cx = x[i] # current index x
104 cy = y[i] # current index y
105 #34 //convention from bot perspective numbers denoting that there exists a path in that direction
106 #21
107 while True:
108 for i in range (0,8): # identifying king checkers of bot
109 if b[7][i] == 'O':
110 b[7][i] = 'B'
111 displayStats(b, user_c, bot_c)
112
113 if b[cx][cy]
114
115 if b[cx][cy]=='O' or b[cx][cy]=='B':
116 if (cx<6 and cy<6 and (b[cx+1][cy+1]=='U' or b[cx+1][cy+1]=='X') and b[cx+2][cy+2]=='-'):
117 b[cx][cy].append('1')
118 cx+=2
119 cy+=2
120 continue
121 if (cx<6 and cy>0 and (b[cx+1][cy-1]=='U' or b[cx+1][cy-1]=='X') and b[cx+2][cy-2]=='-'):
122 b[cx][cy].append('2')
123 cx+=2
124 cy-=2
125 continue
126 if b[cx][cy]=='B':
127 if (cx>0 and cy>0 and (b[cx-1][cy-1]=='U' or b[cx-1][cy-1]=='X') and b[cx-2][cy-2]=='-'):
128 b[cx][cy].append('3')
129 cx-=2
130 cy-=2
131 continue
132 if (cx>0 and cy<6 and (b[cx-1][cy+1]=='U' or b[cx-1][cy+1]=='X') and b[cx-2][cy+2]=='-'):
133 b[cx][cy].append('4')
134 cx-=2
135 cy+=2
136 continue
137 """
138 return capture
139
140def movable(board, flag): #tested : gives available moves of both user and bot
141 x = []
142 y = []
143 for i in range(0,8):
144 for j in range(0,8):
145 if flag == 0: #user
146 if board[i][j] == 'X' or board[i][j] == 'U':
147 if (i>0 and j>0 and board[i-1][j-1]=='-') or (i>0 and j<7 and board[i-1][j+1]=='-') or (i>1 and j>1 and (board[i-1][j-1]=='O' or board[i-1][j-1]=='B') and board[i-2][j-2]=='-') or (i>1 and j<6 and (board[i-1][j+1]=='O' or board[i-1][j+1]=='B') and board[i-2][j+2]=='-'):
148 x.append(int(i))
149 y.append(int(j))
150 continue
151 if board[i][j] == 'U':
152 if (i<7 and j>0 and board[i+1][j-1]=='-') or (i<7 and j<7 and board[i+1][j+1]=='-') or (i<6 and j>1 and (board[i+1][j-1]=='O' or board[i+1][j-1]=='B') and board[i+2][j-2]=='-') or (i<6 and j<6 and (board[i+1][j+1]=='O' or board[i+1][j+1]=='B') and board[i+2][j+2]=='-'):
153 x.append(int(i))
154 y.append(int(j))
155 elif flag == 1: #bot
156 if board[i][j] == 'O' or board[i][j] == 'B':
157 if (i<7 and j>0 and board[i+1][j-1]=='-') or (i<7 and j<7 and board[i+1][j+1]=='-') or (i<6 and j>1 and (board[i+1][j-1]=='X' or board[i+1][j-1]=='U') and board[i+2][j-2]=='-') or (i<6 and j<6 and (board[i+1][j+1]=='X' or board[i+1][j+1]=='U') and board[i+2][j+2]=='-'):
158 x.append(int(i))
159 y.append(int(j))
160 continue
161 if board[i][j] == 'B':
162 if (i>0 and j>0 and board[i-1][j-1]=='-') or (i>0 and j<7 and board[i-1][j+1]=='-') or (i>1 and j>1 and (board[i-1][j-1]=='X' or board[i-1][j-1]=='U') and board[i-2][j-2]=='-') or (i>1 and j<6 and (board[i-1][j+1]=='X' or board[i-1][j+1]=='U') and board[i-2][j+2]=='-'):
163 x.append(int(i))
164 y.append(int(j))
165 return x, y
166
167def gameLogic(board, move, botX, botY, user_c, bot_c, userX, userY):
168 for i in range (0,8): # identifying king checkers of bot
169 if board[7][i] == 'O':
170 board[7][i] = 'B'
171 displayStats(board, user_c, bot_c)
172 #done #get all movable checker positions of bot
173 #done #get all movable checker positions of user
174 #predict best move of user
175 #prevent user's best move and also make bot's best move
176 #best move out of obtained list of checkers
177 """
178 TEMPORARY VARIABLES USED :
179 mcpbX : movable checker position of bot [x]
180 mcpbY : movable checker position of bot [y]
181 mcpuX : movable checker position of user [x]
182 mcpuY : movable checker position of user [y]
183 bestBX : x index of best move of bot
184 bestBY : y index of best move of bot
185 bestUX : x index of best move of user
186 bestUY : y index of best move of user
187 """
188 # 1. all movable checker of bot
189 flag = 1 # flag check for bot/user
190 mcpbX, mcpbY = movable(board, flag)
191 # 2. predict best move of bot
192 captureB = bestMove(board, mcpbX, mcpbY, flag)
193 # 3. all movable checker of user
194 flag = 0
195 mcpuX, mcpuY = movable(board, flag)
196 # 4. predict best move of user
197 captureU = bestMove(board, mcpuX, mcpuY, flag)
198 #list capture holds the values of how many opponent checker each checker can conquer.
199 #for now we will make best move of bot... in subsequent days, i might add a feedback mechanism to predict user move upto one move.
200
201
202 move = 0
203 return move, user_c, bot_c
204
205def process_data(data): #tested
206 row = []
207 col = []
208 for ch in data:
209 if (ord(ch)>64) and (ord(ch)<95):
210 row.append(str(ord(ch)-65))
211 if (ord(ch)>96) and (ord(ch)<125):
212 row.append(str(ord(ch)-97))
213 if (ord(ch)>47) and (ord(ch)<57):
214 col.append(str(ord(ch)-49))
215 return int(row[0]),int(col[0])
216
217def spreeUp(board, dest_x, dest_y): #tested
218 if dest_y - 2 >= 0 and dest_x - 2 >= 0:
219 if board[dest_x-2][dest_y-2] == '-' and (board[dest_x-1][dest_y-1] == 'O' or board[dest_x-1][dest_y-1] == 'B'):
220 return True
221 if dest_y + 2 <= 7 and dest_x - 2 >= 0:
222 if board[dest_x-2][dest_y+2] == '-' and (board[dest_x-1][dest_y+1] == 'O' or board[dest_x-1][dest_y+1] == 'B'):
223 return True
224 return False
225
226def spree(board, dest_x, dest_y): #tested
227 for i in range(0,8):
228 if board[0][i] == 'X':
229 board[0][i] = 'U'
230 #non-king, king
231 if board[dest_x][dest_y] == 'X':
232 return bool(spreeUp(board, dest_x, dest_y))
233 if board[dest_x][dest_y] == 'U':
234 flag = bool(spreeUp(board, dest_x, dest_y))
235 if dest_y - 2 >= 0 and dest_x + 2 <= 7:
236 if board[dest_x+2][dest_y-2] == '-' and (board[dest_x+1][dest_y-1] == 'O' or board[dest_x+1][dest_y-1] == 'B'):
237 return True
238 if dest_y + 2 <= 7 and dest_x + 2 <= 7:
239 if board[dest_x+2][dest_y+2] == '-' and (board[dest_x+1][dest_y+1] == 'O' or board[dest_x+1][dest_y+1] == 'B'):
240 return True
241 return False
242
243def userInputCapturing(board, src_x, src_y, dest_x, dest_y, bot_c): #tested
244 for i in range(0,8):
245 if board[0][i] == 'X':
246 board[0][i] = 'U'
247 displayStats(board, user_c, bot_c)
248 return int(move), int(bot_c)
249 #capturing
250 if board[src_x-1][src_y-1]=='O' or board[src_x-1][src_y-1]=='B' or board[src_x+1][src_y+1]=='O' or board[src_x+1][src_y+1]=='B' or board[src_x-1][src_y+1]=='O' or board[src_x-1][src_y+1]=='B' or board[src_x+1][src_y-1]=='O' or board[src_x+1][src_y-1]=='B':
251 board[dest_x][dest_y] = board[src_x][src_y]
252 board[src_x][src_y] = '-'
253 bot_c -= 1
254 if src_x - dest_x > 0: #up
255 if src_y - dest_y > 0: #left
256 board[src_x-1][src_y-1] = '-'
257 else:
258 board[src_x-1][src_y+1] = '-'
259 else:
260 if src_y - dest_y > 0: #left
261 board[src_x+1][src_y-1] = '-'
262 else:
263 board[src_x+1][src_y+1] = '-'
264 return True, bot_c
265 else:
266 return False, bot_c
267
268def userInput(board, move, userX, userY, user_c, bot_c): #tested
269 for i in range(0,8):
270 if board[0][i] == 'X':
271 board[0][i] = 'U'
272 displayStats(board, user_c, bot_c)
273 return int(move), int(bot_c)
274 sys.stdout.write("\nSource\t\t:\t")
275 src = str(raw_input())
276 if not src:
277 error(" : Source can not be left blank!\nEnter again! Redirecting...")
278 time.sleep(2)
279 return int(move), int(user_c), int(bot_c)
280 if len(src) != 2:
281 error(" : Dimensions incorrect!")
282 time.sleep(2)
283 return int(move), int(user_c), int(bot_c)
284 sys.stdout.write("Destination\t:\t")
285 dest = str(raw_input())
286 if not dest:
287 print("\nDestination can not be left blank!\nEnter again! Redirecting...")
288 time.sleep(2)
289 return int(move), int(user_c), int(bot_c)
290 if len(dest) != 2:
291 error(" : Dimensions incorrect!")
292 time.sleep(2)
293 return int(move), int(user_c), int(bot_c)
294 src_x, src_y = process_data(src)
295 dest_x, dest_y = process_data(dest)
296 #obtained source and destination indexes
297 if board[dest_x][dest_y] != '-':
298 error(" : Destination\nEnter again! Redirecting...")
299 time.sleep(2)
300 return int(move), int(user_c), int(bot_c)
301 if board[src_x][src_y] != 'X':
302 if board[src_x][src_y] != 'U':
303 error(" : Source check\nEnter again! Redirecting...")
304 time.sleep(2)
305 return int(move), int(user_c), int(bot_c)
306 if board[src_x][src_y] == '-':
307 error(" : Source can not be empty cell\nEnter again! Redirecting...")
308 time.sleep(2)
309 return int(move), int(user_c), int(bot_c)
310 if mod(src_x-dest_x) > 2 or mod(src_y-dest_y) > 2:
311 error(" : You are not a kangaroo :P\nEnter again! Redirecting...")
312 time.sleep(2)
313 return int(move), int(user_c), int(bot_c)
314 if src_x==dest_x or src_y==dest_y:
315 error(" : You must make a move.\nEnter again! Redirecting...")
316 time.sleep(2)
317 return int(move), int(user_c), int(bot_c)
318 if (dest_x < 0 or dest_x > 7 or src_x < 0 or src_x > 7):
319 error(" : Boundary exceeded.\nEnter again! Redirecting...")
320 time.sleep(2)
321 return int(move), int(user_c), int(bot_c)
322 if board[src_x][src_y] == 'X' and dest_x > src_x:
323 error(" : Only King can move backwards!\nEnter again! Redirecting...")
324 time.sleep(2)
325 return int(move), int(user_c), int(bot_c)
326 if mod(src_y-dest_y) == 1 or (src_x-dest_x) == 1: #non-capturing
327 board[dest_x][dest_y] = board[src_x][src_y]
328 board[src_x][src_y] = '-'
329 displayStats(board, user_c, bot_c)
330 move = 1
331 return int(move), int(user_c), int(bot_c)
332 #capturing
333 print("check")
334 time.sleep(3)
335 flag_temp, bot_c = userInputCapturing(board, src_x, src_y, dest_x, dest_y, bot_c)
336 if flag_temp:
337 displayStats(board, user_c, bot_c)
338 #check if a capturing spree is possible
339 while spree(board, dest_x, dest_y):
340 sys.stdout.write("\nCapturing spree!? (y/n) : ")
341 ch = str(raw_input())
342 if ch == 'y':
343 src_x = dest_x
344 src_y = dest_y
345 sys.stdout.write("\nSource\t\t:\t"+str(chr(src_x+65))+str(chr(src_y+49)))
346 sys.stdout.write("\nDestination\t:\t")
347 dest = str(raw_input())
348 if not dest:
349 print("\nDestination can not be left blank!\nEnter again! Redirecting...")
350 time.sleep(2)
351 continue
352 dest_x, dest_y = process_data(dest)
353 #capturing
354 flag_temp, bot_c = userInputCapturing(board, src_x, src_y, dest_x, dest_y, bot_c)
355 displayStats(board, user_c, bot_c)
356 else:
357 move = 1
358 return int(move), int(user_c), int(bot_c)
359 else:
360 error(" : Can not hop over empty cells.\nAren't you tired testing robustness of this game :P\nRedirecting...")
361 time.sleep(1)
362 return int(move), int(user_c), int(bot_c)
363
364def tied(): #tested
365 clrscr()
366 print(" _____ ")
367 print(" / | \ _________ _____ _____ ")
368 print(" | | | | \ ")
369 print(" | | |___ | | ")
370 print(" | | | | | ")
371 print(" | ____|____ |_____ |____ / ")
372 print("\nTry again next time :)")
373
374def displayStats(board, user_c, bot_c): #tested
375 clrscr()
376 print("Good Luck!\n")
377 print("Bot Checkers (O | B) : "+ str(bot_c) + "\tUser Checkers (X | U) : "+ str(user_c))
378 gameBoard(board)
379
380def post(board, move, userX, userY, botX, botY, user_c, bot_c): #tested
381 if checkWin(board, user_c, bot_c):
382 return
383 elif checkDraw(board):
384 tied()
385 return
386 if move == 0:
387 move, user_c, bot_c = userInput(board, move, userX, userY, user_c, bot_c)
388 post(board, move, userX, userY, botX, botY, user_c, bot_c)
389 if move == 1:
390 move, user_c, bot_c = gameLogic(board, move, botX, botY, user_c, bot_c, userX, userY)
391 post(board, move, userX, userY, botX, botY, user_c, bot_c)
392 return
393
394def logo(): #tested
395 print(" __ ___ __ ___ ____ ___ ")
396 print(" / | | | / | / | | \ / \ ")
397 print("| |___| |__ | |_/ |__ |___ / \___ ")
398 print("| | | | | | \ | | | \ ")
399 print(" \ __ | | |___ \ __ | \ |___ | | \___/ 1.0.0 - Nobita")
400 print("")
401
402def preProcess(board): #tested
403 for i in range(0,8):
404 for j in range(0,8):
405 if(i%2==0):
406 if(j%2!=0):
407 board[i][j] = '+'
408 if(i%2!=0):
409 if(j%2==0):
410 board[i][j] = '+'
411
412def instructions(): #tested
413 logo()
414 sys.stdout.write("This a 2-player board-game.\n")
415 print("\nCapturing Moves: ")
416 sys.stdout.write("\n\t1. Diagonally jump over opponent checker to capture.")
417 sys.stdout.write("\n\t2. More than one checker of opponent can be captured")
418 sys.stdout.write("\n\t3. Once a checker reaches to the base of opponent, it is considered a KING")
419 sys.stdout.write("\n\t4. Only a KING checker can traverse in both directions (towards and away from opponent).")
420 #
421 print("\n\nNon-Capturing Moves: ")
422 sys.stdout.write("\n\t1. Normal checker will only move towards opponent")
423 sys.stdout.write("\n\t2. Move diagonally one step in allowed direction")
424 sys.stdout.write("\n\t3. # indicates blocked area. - indicates movable areas.")
425 sys.stdout.write("\n\t4. Bot KING will be denoted by 'B' and User KING by 'U'")
426 sys.stdout.write("\n\t5. Bot CHECKERS will be denoted by 'O' and User by 'X'\n")
427 #
428 print("\nHOW TO PLAY!")
429 sys.stdout.write("\n\tSelect position of desired checker to move. Then enter destination address (where to move)\n")
430 sys.stdout.write("\n\te.g. want to move C3 to E1 hopping over D2 and continue to G3 hopping over F2. You have to enter as follows:")
431 sys.stdout.write("\n\tSource:\t\t\tC3\n\tDestination:\t\tE1\n\tContinue Move!? (y/n):\ty")
432 sys.stdout.write("\n\tSource:\t\t\t<prev destination i.e. E1 - pre-determined; not user input>\n\tDestination:\t\tG3\n\tContinue Move!? (y/n):\tn")
433 print("\n\n\tPlayer loses if no checkers are on their table or they are out of moves.")
434
435def gameBoardI(board): #tested
436 print("\n")
437 board[2][2] = 'X'
438 board[3][1] = 'O'
439 board[5][1] = 'O'
440 char = 'A'
441 index = 1
442 sys.stdout.write(" ")
443 for i in range(0,8):
444 sys.stdout.write(" "+str(index)+" ")
445 index += 1
446 print("\n")
447 for i in range(0,8):
448 sys.stdout.write(" "+chr(ord(char)+i)+" ")
449 for j in range(0,8):
450 sys.stdout.write(" "+board[i][j]+" ")
451 sys.stdout.write("\n\n")
452 board[2][2] = '-'
453 board[3][1] = '-'
454 board[5][1] = '-'
455 return
456
457def gameBoard(board): #tested
458 print("\n")
459 char = 'A'
460 index = 1
461 sys.stdout.write(" ")
462 for i in range(0,8):
463 sys.stdout.write(" "+str(index)+" ")
464 index += 1
465 print("\n")
466 for i in range(0,8):
467 sys.stdout.write(" "+chr(ord(char)+i)+" ")
468 for j in range(0,8):
469 sys.stdout.write(" "+board[i][j]+" ")
470 sys.stdout.write("\n\n")
471 return
472
473def cmdArt(): #tested
474 os.system('color 07')
475 os.system('mode con: cols=167 lines=57')
476
477def clrscr(): #tested
478 os.system('cls')
479
480def pre(board): #tested
481 clrscr()
482 cmdArt()
483 preProcess(board)
484 #instructions to play
485 instructions()
486 gameBoardI(board)
487
488def next(): #tested
489 sys.stdout.write("Press enter to continue...")
490 raw_input()
491 os.system('cls')
492
493def bid(board): #tested
494 clrscr()
495 print("BID FOR POWER! Rolling Dice...\n")
496 x = int(random.randint(1,6))
497 y = int(random.randint(1,6))
498 #print("x="+str(x)+" y="+str(y))
499 if x==y:
500 x+=1
501 #User bid
502 sys.stdout.write("You : ")
503 for i in range(1,20):
504 sys.stdout.write("\b"+str(i%6))
505 time.sleep(0.03)
506 sys.stdout.write("\b"+str(x))
507 #Bot bid
508 sys.stdout.write("\nBot : ")
509 for i in range(1,20):
510 sys.stdout.write("\b"+str(i%6))
511 time.sleep(0.03)
512 sys.stdout.write("\b"+str(y))
513 if x>y:
514 temp = int(0)
515 sys.stdout.write("\n\nYou have the move! Cheers!")
516 sys.stdout.write("\nRedirecting in 3 seconds...")
517 time.sleep(3)
518 return temp
519 else:
520 temp = int(1)
521 sys.stdout.write("\n\nBot has the move! Oops!")
522 sys.stdout.write("\nRedirecting in 3 seconds...")
523 time.sleep(3)
524 return temp
525
526def bot(board, botX, botY): #tested
527 for i in range(0,3):
528 for j in range(0,8):
529 if(j%2==0) and (i%2==0) and board[i][j]=='-':
530 board[i][j] = 'O'
531 botX.append(i)
532 botY.append(j)
533 if(j%2!=0) and (i%2!=0) and board[i][j]=='-':
534 board[i][j] = 'O'
535 botX.append(i)
536 botY.append(j)
537 return
538
539def user(board, userX, userY): #tested
540 for i in range(5,8):
541 for j in range(0,8):
542 if(j%2!=0) and (i%2!=0) and board[i][j]=='-':
543 board[i][j] = 'X'
544 userX.append(i)
545 userY.append(j)
546 if(j%2==0) and (i%2==0) and board[i][j]=='-':
547 board[i][j] = 'X'
548 userX.append(i)
549 userY.append(j)
550 return
551
552def main():
553 #asset variables
554 bot_c = 12 # to be decremented if opponent crosses
555 user_c = 12 # will be a check if any of bot/user_c is zero. game ends.
556 botX = []
557 botY = []
558 userX = []
559 userY = []
560 #gameBoard with initial values '-'
561 r, c = 8, 8
562 board = [['-' for x in range(r)] for y in range(c)]
563 #"""
564 #introduction
565 pre(board)
566 next()
567 #"""
568 #initial values
569 bot(board, botX, botY)
570 user(board, userX, userY)
571 #"""
572 #userInput and gameLogic
573 print("Lets see who has the move!")
574 print("Roll the dice...")
575 time.sleep(0.5)
576 move = bid(board)
577 displayStats(board, bot_c, user_c)
578 post(board, move, userX, userY, botX, botY, user_c, bot_c) #redirects automatically to user/bot according to the bid
579
580if __name__ == '__main__':
581 main()