This is the full code for my Final Project:
from random import randint board = [] COOL_COLOR = 0 NOT_COOL_COLOR = 1 BOARD_WIDTH = 10 TOP_MARGIN = 5 class bcolors: BLUE = '\033[94m' RED = '\033[31m' GREEN = '\033[92m' BOLD = '\033[1m' ENDC = '\033[0m' UNDERLINE = '\033[4m' def col_print(color, message): if color == COOL_COLOR: print bcolors.BLUE + message + bcolors.ENDC, elif color == NOT_COOL_COLOR: print bcolors.RED + message + bcolors.ENDC, else: print message for x in range(10): board.append(["O"] * 10) def print_board(board): for i in range(TOP_MARGIN): print " " print " ===================" print " " for row in range(BOARD_WIDTH): print " ", for col in range(BOARD_WIDTH): if board[row][col] == "h": col_print(NOT_COOL_COLOR, "H") elif board[row][col] == "L": col_print(NOT_COOL_COLOR, "G") elif board[row][col] == "F": col_print(NOT_COOL_COLOR, "g") elif board[row][col] == "Y": col_print(NOT_COOL_COLOR, "C") elif board[row][col] == "d": col_print(NOT_COOL_COLOR, "A") elif board[row][col] == "X": col_print(NOT_COOL_COLOR, "S") elif board[row][col] == "O": print board[row][col], else: col_print(COOL_COLOR, board[row][col]) print " " print " " print " ===================" """ def print_board(board): for x in board: print " ".join(x) """ def set_home_position(board): board[0][5] = "h" board[9][5] = "H" #main program start option = raw_input ("Hello. Welcome to the Army Game. Do you want to play? Yes(Y) or No(N)? :") if option == "Yes" or option == "yes" or option == 'Y' or option == 'y': print "Here are the rules:" print "1. You are playing against the computer and both of you will have 5 players" print "2. The 5 players are (General, Archer, Grenade, Cannon, Soldier) and they are ranked from top to bottom in that specific order" print "3. You can only kill players that are a lower rank than you, and you cannot kill players that are a higher rank than you" print "4. If you kill a player that is your own rank, than both of the players die" print "5. Friendly fire is not tolerated" print "6. You may only move 1 player every turn" print "7. You may only move either 1 step vertically or 1 step horizontally, you may not move diagonally" print "8. First one to reach the opponent's home(H) wins" print "9. You are color BLUE, the computer is color RED" raw_input("Hit any key to continue ...") print "" print "To start, you must choose specify locations of your players" else: print "Okay, see you next time!" exit() set_home_position(board) print_board(board) #general guess_row_general = 8 x = False while (x == False): guess_col_general = int(raw_input ("Insert general col:")) if board[guess_row_general][guess_col_general] != "O": print "Sorry, this spot is already occupied" x = False else: x = True board[guess_row_general][guess_col_general] = "G" #archer guess_row_archer = 8 x = False while (x == False): guess_col_archer = int(raw_input ("Insert archer col:")) if board[guess_row_archer][guess_col_archer] != "O": print "Sorry, this spot is already occupied" x = False else: x = True board[guess_row_archer][guess_col_archer] = "A" #grenade guess_row_grenade = 8 x = False while (x == False): guess_col_grenade = int(raw_input ("Insert grenade col:")) if board[guess_row_grenade][guess_col_grenade] != "O": print "Sorry, this spot is already occupied" x = False else: x = True board[guess_row_grenade][guess_col_grenade] = "g" #cannon guess_row_cannon = 8 x = False while (x == False): guess_col_cannon = int(raw_input ("Insert cannon col:")) if board[guess_row_cannon][guess_col_cannon] != "O": print "Sorry, this spot is already occupied" x = False else: x = True board[guess_row_cannon][guess_col_cannon] = "C" #soldier guess_row_soldier = 8 x = False while (x == False): guess_col_soldier = int(raw_input ("Insert soldier col:")) if board[guess_row_soldier][guess_col_soldier] != "O": print "Sorry, this spot is already occupied" x = False else: x = True board[guess_row_soldier][guess_col_soldier] = "S" #computer general comp_row_general = 1 x = False while (x == False): comp_col_general = randint(0, 9) if board[comp_row_general][comp_col_general] != "O": x = False else: x = True board[comp_row_general][comp_col_general] = "L" #computer archer comp_row_archer = 1 x = False while (x == False): comp_col_archer = randint(0, 9) if board[comp_row_archer][comp_col_archer] != "O": x = False else: x = True board[comp_row_archer][comp_col_archer] = "d" #computer grenade comp_row_grenade = 1 x = False while (x == False): comp_col_grenade = randint(0, 9) if board[comp_row_grenade][comp_col_grenade] != "O": x = False else: x = True board[comp_row_grenade][comp_col_grenade] = "F" #computer cannon comp_row_cannon = 1 x = False while (x == False): comp_col_cannon = randint(0, 9) if board[comp_row_cannon][comp_col_cannon] != "O": x = False else: x = True board[comp_row_cannon][comp_col_cannon] = "Y" #computer soldier comp_row_soldier = 1 x = False while (x == False): comp_col_soldier = randint(0, 9) if board[comp_row_soldier][comp_col_soldier] != "O": x = False else: x = True board[comp_row_soldier][comp_col_soldier] = "X" print "\n\nGAME START" set_home_position(board) print_board (board) y = True num_turn = 0 while (y == True): num_turn += 1 print "Turn: ", num_turn the_choice = raw_input("Which person would you like to move? General, Archer, Grenade, Cannon, or Soldier? :") if the_choice == "General" or the_choice == "general": x = False while (x == False): user_general_row = int(raw_input ("Insert the new general row:")) user_general_col = int(raw_input ("Insert thew new general col:")) if board[user_general_row][user_general_col] == "G" or board[user_general_row][user_general_col] == "A" or board[user_general_row][user_general_col] == "g" or board[user_general_row][user_general_col] == "C" or board[user_general_row][user_general_col] == "S": print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_general_row) - int (guess_row_general)) == 1 and abs(int(user_general_col) - int(guess_col_general)) == 1: print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_general_row) - int (guess_row_general)) > 1 or abs(int(user_general_col) - int(guess_col_general)) > 1: print "invalid, sorry. Please re-enter position" x = False elif board[user_general_row][user_general_col] == "L": board[user_general_row][user_general_col] = "O" board[guess_row_general][guess_col_general] = "O" board[comp_row_general][comp_col_general] = "O" set_home_position(board) print_board (board) x = True elif board[user_general_row][user_general_col] == "d" or board[user_general_row][user_general_col] == "F" or board[user_general_row][user_general_col] == "Y" or board[user_general_row][user_general_col] == "X" or board[user_general_row][user_general_col] == "O": board[user_general_row][user_general_col] = "G" board[guess_row_general][guess_col_general] = "O" guess_row_general = user_general_row guess_col_general = user_general_col set_home_position(board) print_board (board) x = True elif board[user_general_row][user_general_col] == "h": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif the_choice == "Archer" or the_choice == "archer": x = False while (x == False): user_archer_row = int(raw_input ("Insert the new archer row:")) user_archer_col = int(raw_input ("Insert thew new archer col:")) if board[user_archer_row][user_archer_col] == "G" or board[user_archer_row][user_archer_col] == "A" or board[user_archer_row][user_archer_col] == "g" or board[user_archer_row][user_archer_col] == "C" or board[user_archer_row][user_archer_col] == "S": print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_archer_row) - int (guess_row_archer)) == 1 and abs(int(user_archer_col) - int(guess_col_archer)) == 1: print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_archer_row) - int (guess_row_archer)) > 1 or abs(int(user_archer_col) - int(guess_col_archer)) > 1: print "invalid, sorry. Please re-enter position" x = False elif board[user_archer_row][user_archer_col] == "d": board[user_archer_row][user_archer_col] = "O" board[guess_row_archer][guess_col_archer] = "O" board[comp_row_archer][comp_col_archer] = "O" set_home_position(board) print_board (board) x = True elif board[user_archer_row][user_archer_col] == "L": board[user_archer_row][user_archer_col] = "O" board[guess_row_archer][guess_col_archer] = "O" board[comp_row_general][comp_col_general] = "L" set_home_position(board) print_board (board) x = True elif board[user_archer_row][user_archer_col] == "F" or board[user_archer_row][user_archer_col] == "Y" or board[user_archer_row][user_archer_col] == "X" or board[user_archer_row][user_archer_col] == "O": board[user_archer_row][user_archer_col] = "A" board[guess_row_archer][guess_col_archer] = "O" guess_row_archer = user_archer_row guess_col_archer = user_archer_col set_home_position(board) print_board (board) x = True elif board[user_archer_row][user_archer_col] == "h": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif the_choice == "Grenade" or the_choice == "grenade": x = False while (x == False): user_grenade_row = int(raw_input ("Insert the new grenade row:")) user_grenade_col = int(raw_input ("Insert thew new grenade col:")) if board[user_grenade_row][user_grenade_col] == "G" or board[user_grenade_row][user_grenade_col] == "A" or board[user_grenade_row][user_grenade_col] == "g" or board[user_grenade_row][user_grenade_col] == "C" or board[user_grenade_row][user_grenade_col] == "S": print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_grenade_row) - int (guess_row_grenade)) == 1 and abs(int(user_grenade_col) - int(guess_col_grenade)) == 1: print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_grenade_row) - int (guess_row_grenade)) > 1 or abs(int(user_grenade_col) - int(guess_col_grenade)) > 1: print "invalid, sorry. Please re-enter position" x = False elif board[user_grenade_row][user_grenade_col] == "F": board[user_grenade_row][user_grenade_col] = "O" board[guess_row_grenade][guess_col_grenade] = "O" board[comp_row_grenade][comp_col_grenade] = "O" set_home_position(board) print_board (board) x = True elif board[user_grenade_row][user_grenade_col] == "L": board[user_grenade_row][user_grenade_col] = "O" board[guess_row_grenade][guess_col_grenade] = "O" board[comp_row_general][comp_col_general] = "L" set_home_position(board) print_board (board) x = True elif board[user_grenade_row][user_grenade_col] == "d": board[user_grenade_row][user_grenade_col] = "O" board[guess_row_grenade][guess_col_grenade] = "O" board[comp_row_archer][comp_col_archer] = "d" set_home_position(board) print_board (board) x = True elif board[user_grenade_row][user_grenade_col] == "Y" or board[user_grenade_row][user_grenade_col] == "X" or board[user_grenade_row][user_grenade_col] == "O": board[user_grenade_row][user_grenade_col] = "g" board[guess_row_grenade][guess_col_grenade] = "O" guess_row_grenade = user_grenade_row guess_col_grenade = user_grenade_col set_home_position(board) print_board (board) x = True elif board[user_grenade_row][user_grenade_col] == "h": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif the_choice == "Cannon" or the_choice == "cannon": x = False while (x == False): user_cannon_row = int(raw_input ("Insert the new cannon row:")) user_cannon_col = int(raw_input ("Insert thew new cannon col:")) if board[user_cannon_row][user_cannon_col] == "G" or board[user_cannon_row][user_cannon_col] == "A" or board[user_cannon_row][user_cannon_col] == "g" or board[user_cannon_row][user_cannon_col] == "C" or board[user_cannon_row][user_cannon_col] == "S": print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_cannon_row) - int (guess_row_cannon)) == 1 and abs(int(user_cannon_col) - int(guess_col_cannon)) == 1: print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_cannon_row) - int (guess_row_cannon)) > 1 or abs(int(user_cannon_col) - int(guess_col_cannon)) > 1: print "invalid, sorry. Please re-enter position" x = False elif board[user_cannon_row][user_cannon_col] == "Y": board[user_cannon_row][user_cannon_col] = "O" board[guess_row_cannon][guess_col_cannon] = "O" board[comp_row_cannon][comp_col_cannon] = "O" set_home_position(board) print_board (board) x = True elif board[user_cannon_row][user_cannon_col] == "L": board[user_cannon_row][user_cannon_col] = "O" board[guess_row_cannon][guess_col_cannon] = "O" board[comp_row_general][comp_col_general] = "L" set_home_position(board) print_board (board) x = True elif board[user_cannon_row][user_cannon_col] == "d": board[user_cannon_row][user_cannon_col] = "O" board[guess_row_cannon][guess_col_cannon] = "O" board[comp_row_archer][comp_col_archer] = "d" set_home_position(board) print_board (board) x = True elif board[user_cannon_row][user_cannon_col] == "F": board[user_cannon_row][user_cannon_col] = "O" board[guess_row_cannon][guess_col_cannon] = "O" board[comp_row_grenade][comp_col_grenade] = "F" set_home_position(board) print_board (board) x = True elif board[user_cannon_row][user_cannon_col] == "X" or board[user_cannon_row][user_cannon_col] == "O": board[user_cannon_row][user_cannon_col] = "C" board[guess_row_cannon][guess_col_cannon] = "O" guess_row_cannon = user_cannon_row guess_col_cannon = user_cannon_col set_home_position(board) print_board (board) x = True elif board[user_cannon_row][user_cannon_col] == "h": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif the_choice == "Soldier" or the_choice == "soldier": x = False while (x == False): user_soldier_row = int(raw_input ("Insert the new soldier row:")) user_soldier_col = int(raw_input ("Insert thew new soldier col:")) if board[user_soldier_row][user_soldier_col] == "G" or board[user_soldier_row][user_soldier_col] == "A" or board[user_soldier_row][user_soldier_col] == "g" or board[user_soldier_row][user_soldier_col] == "C" or board[user_soldier_row][user_soldier_col] == "S": print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_soldier_row) - int (guess_row_soldier)) == 1 and abs(int(user_soldier_col) - int(guess_col_soldier)) == 1: print "invalid, sorry. Please re-enter position" x = False elif abs(int (user_soldier_row) - int (guess_row_soldier)) > 1 or abs(int(user_soldier_col) - int(guess_col_soldier)) > 1: print "invalid, sorry. Please re-enter position" x = False elif board[user_soldier_row][user_soldier_col] == "X": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_soldier][comp_col_soldier] = "O" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "L": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_general][comp_col_general] = "L" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "d": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_archer][comp_col_archer] = "d" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "F": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_grenade][comp_col_grenade] = "F" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "Y": board[user_soldier_row][user_soldier_col] = "O" board[guess_row_soldier][guess_col_soldier] = "O" board[comp_row_cannon][comp_col_cannon] = "Y" set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "O": board[user_soldier_row][user_soldier_col] = "S" board[guess_row_soldier][guess_col_soldier] = "O" guess_row_soldier = user_soldier_row guess_col_soldier = user_soldier_col set_home_position(board) print_board (board) x = True elif board[user_soldier_row][user_soldier_col] == "h": print "Congratulations! You won the game!!!" break if x == True: y = True else: break computer_the_choice = randint(0, 4) if computer_the_choice == 0: x = False while (x == False): newcomp_general_row = randint (0, 9) newcomp_general_col = randint (0, 9) if board[newcomp_general_row][newcomp_general_col] == "L" or board[newcomp_general_row][newcomp_general_col] == "d" or board[newcomp_general_row][newcomp_general_col] == "F" or board[newcomp_general_row][newcomp_general_col] == "Y" or board[newcomp_general_row][newcomp_general_col] == "X": x = False elif abs(int (newcomp_general_row) - int (comp_row_general)) == 1 and abs(int(newcomp_general_col) - int(comp_col_general)) == 1: x = False elif abs(int (newcomp_general_row) - int (comp_row_general)) > 1 or abs(int(newcomp_general_col) - int(comp_col_general)) > 1: x = False elif board[newcomp_general_row][newcomp_general_col] == "G": board[newcomp_general_row][newcomp_general_col] = "O" board[comp_row_general][comp_col_general] = "O" board[guess_row_general][guess_col_general] = "O" set_home_position(board) print_board (board) x = True elif board[newcomp_general_row][newcomp_general_col] == "A" or board[newcomp_general_row][newcomp_general_col] == "g" or board[newcomp_general_row][newcomp_general_col] == "C" or board[newcomp_general_row][newcomp_general_col] == "S" or board[newcomp_general_row][newcomp_general_col] == "O": board[newcomp_general_row][newcomp_general_col] = "L" board[comp_row_general][comp_col_general] = "O" comp_row_general = newcomp_general_row comp_col_general = newcomp_general_col set_home_position(board) print_board (board) x = True elif board[newcomp_general_row][newcomp_general_col] == "H": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif computer_the_choice == 1: x = False while (x == False): newcomp_archer_row = randint (0, 9) newcomp_archer_col = randint (0, 9) if board[newcomp_archer_row][newcomp_archer_col] == "L" or board[newcomp_archer_row][newcomp_archer_col] == "d" or board[newcomp_archer_row][newcomp_archer_col] == "F" or board[newcomp_archer_row][newcomp_archer_col] == "Y" or board[newcomp_archer_row][newcomp_archer_col] == "X": x = False elif abs(int (newcomp_archer_row) - int (comp_row_archer)) == 1 and abs(int(newcomp_archer_col) - int(comp_col_archer)) == 1: x = False elif abs(int (newcomp_archer_row) - int (comp_row_archer)) > 1 or abs(int(newcomp_archer_col) - int(comp_col_archer)) > 1: x = False elif board[newcomp_archer_row][newcomp_archer_col] == "A": board[newcomp_archer_row][newcomp_archer_col] = "O" board[comp_row_archer][comp_col_archer] = "O" board[guess_row_archer][guess_col_archer] = "O" set_home_position(board) print_board (board) x = True elif board[newcomp_archer_row][newcomp_archer_col] == "G": board[newcomp_archer_row][newcomp_archer_col] = "O" board[comp_row_archer][comp_col_archer] = "O" board[guess_row_general][guess_col_general] = "G" set_home_position(board) print_board (board) x = True elif board[newcomp_archer_row][newcomp_archer_col] == "g" or board[newcomp_archer_row][newcomp_archer_col] == "C" or board[newcomp_archer_row][newcomp_archer_col] == "S" or board[newcomp_archer_row][newcomp_archer_col] == "O": board[newcomp_archer_row][newcomp_archer_col] = "d" board[comp_row_archer][comp_col_archer] = "O" comp_row_archer = newcomp_archer_row comp_col_archer = newcomp_archer_col set_home_position(board) print_board (board) x = True elif board[newcomp_archer_row][newcomp_archer_col] == "H": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif computer_the_choice == 2: x = False while (x == False): newcomp_grenade_row = randint (0, 9) newcomp_grenade_col = randint (0, 9) if board[newcomp_grenade_row][newcomp_grenade_col] == "L" or board[newcomp_grenade_row][newcomp_grenade_col] == "d" or board[newcomp_grenade_row][newcomp_grenade_col] == "F" or board[newcomp_grenade_row][newcomp_grenade_col] == "Y" or board[newcomp_grenade_row][newcomp_grenade_col] == "X": x = False elif abs(int (newcomp_grenade_row) - int (comp_row_grenade)) == 1 and abs(int(newcomp_grenade_col) - int(comp_col_grenade)) == 1: x = False elif abs(int (newcomp_grenade_row) - int (comp_row_grenade)) > 1 or abs(int(newcomp_grenade_col) - int(comp_col_grenade)) > 1: x = False elif board[newcomp_grenade_row][newcomp_grenade_col] == "g": board[newcomp_grenade_row][newcomp_grenade_col] = "O" board[comp_row_grenade][comp_col_grenade] = "O" board[guess_row_grenade][guess_col_grenade] = "O" set_home_position(board) print_board (board) x = True elif board[newcomp_grenade_row][newcomp_grenade_col] == "G": board[newcomp_grenade_row][newcomp_grenade_col] = "O" board[comp_row_grenade][comp_col_grenade] = "O" board[guess_row_general][guess_col_general] = "G" set_home_position(board) print_board (board) x = True elif board[newcomp_grenade_row][newcomp_grenade_col] == "A": board[newcomp_grenade_row][newcomp_grenade_col] = "O" board[comp_row_grenade][comp_col_grenade] = "O" board[guess_row_archer][guess_col_archer] = "A" set_home_position(board) print_board (board) x = True elif board[newcomp_grenade_row][newcomp_grenade_col] == "C" or board[newcomp_grenade_row][newcomp_grenade_col] == "S" or board[newcomp_grenade_row][newcomp_grenade_col] == "O": board[newcomp_grenade_row][newcomp_grenade_col] = "F" board[comp_row_grenade][comp_col_grenade] = "O" comp_row_grenade = newcomp_grenade_row comp_col_grenade = newcomp_grenade_col set_home_position(board) print_board (board) x = True elif board[newcomp_grenade_row][newcomp_grenade_col] == "H": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif computer_the_choice == 3: x = False while (x == False): newcomp_cannon_row = randint (0, 9) newcomp_cannon_col = randint (0, 9) if board[newcomp_cannon_row][newcomp_cannon_col] == "L" or board[newcomp_cannon_row][newcomp_cannon_col] == "d" or board[newcomp_cannon_row][newcomp_cannon_col] == "F" or board[newcomp_cannon_row][newcomp_cannon_col] == "Y" or board[newcomp_cannon_row][newcomp_cannon_col] == "X": x = False elif abs(int (newcomp_cannon_row) - int (comp_row_cannon)) == 1 and abs(int(newcomp_cannon_col) - int(comp_col_cannon)) == 1: x = False elif abs(int (newcomp_cannon_row) - int (comp_row_cannon)) > 1 or abs(int(newcomp_cannon_col) - int(comp_col_cannon)) > 1: x = False elif board[newcomp_cannon_row][newcomp_cannon_col] == "C": board[newcomp_cannon_row][newcomp_cannon_col] = "O" board[comp_row_cannon][comp_col_cannon] = "O" board[guess_row_cannon][guess_col_cannon] = "O" set_home_position(board) print_board (board) x = True elif board[newcomp_cannon_row][newcomp_cannon_col] == "G": board[newcomp_cannon_row][newcomp_cannon_col] = "O" board[comp_row_cannon][comp_col_cannon] = "O" board[guess_row_general][guess_col_general] = "G" set_home_position(board) print_board (board) x = True elif board[newcomp_cannon_row][newcomp_cannon_col] == "A": board[newcomp_cannon_row][newcomp_cannon_col] = "O" board[comp_row_cannon][comp_col_cannon] = "O" board[guess_row_archer][guess_col_archer] = "A" set_home_position(board) print_board (board) x = True elif board[newcomp_cannon_row][newcomp_cannon_col] == "g": board[newcomp_cannon_row][newcomp_cannon_col] = "O" board[comp_row_cannon][comp_col_cannon] = "O" board[guess_row_grenade][guess_col_grenade] = "g" set_home_position(board) print_board (board) x = True elif board[newcomp_cannon_row][newcomp_cannon_col] == "S" or board[newcomp_cannon_row][newcomp_cannon_col] == "O": board[newcomp_cannon_row][newcomp_cannon_col] = "Y" board[comp_row_cannon][comp_col_cannon] = "O" comp_row_cannon = newcomp_cannon_row comp_col_cannon = newcomp_cannon_col set_home_position(board) print_board (board) x = True elif board[newcomp_cannon_row][newcomp_cannon_col] == "H": print "Congratulations! You won the game!!!" break if x == True: y = True else: break elif computer_the_choice == 4: x = False while (x == False): newcomp_soldier_row = randint (0, 9) newcomp_soldier_col = randint (0, 9) if board[newcomp_soldier_row][newcomp_soldier_col] == "L" or board[newcomp_soldier_row][newcomp_soldier_col] == "d" or board[newcomp_soldier_row][newcomp_soldier_col] == "F" or board[newcomp_soldier_row][newcomp_soldier_col] == "Y" or board[newcomp_soldier_row][newcomp_soldier_col] == "X": x = False elif abs(int (newcomp_soldier_row) - int (comp_row_soldier)) == 1 and abs(int(newcomp_soldier_col) - int(comp_col_soldier)) == 1: x = False elif abs(int (newcomp_soldier_row) - int (comp_row_soldier)) > 1 or abs(int(newcomp_soldier_col) - int(comp_col_soldier)) > 1: x = False elif board[newcomp_soldier_row][newcomp_soldier_col] == "S": board[newcomp_soldier_row][newcomp_soldier_col] = "O" board[comp_row_soldier][comp_col_soldier] = "O" board[guess_row_soldier][guess_col_soldier] = "O" set_home_position(board) print_board (board) x = True elif board[newcomp_soldier_row][newcomp_soldier_col] == "G": board[newcomp_soldier_row][newcomp_soldier_col] = "O" board[comp_row_soldier][comp_col_soldier] = "O" board[guess_row_general][guess_col_general] = "G" set_home_position(board) print_board (board) x = True elif board[newcomp_soldier_row][newcomp_soldier_col] == "A": board[newcomp_soldier_row][newcomp_soldier_col] = "O" board[comp_row_soldier][comp_col_soldier] = "O" board[guess_row_archer][guess_col_archer] = "A" set_home_position(board) print_board (board) x = True elif board[newcomp_soldier_row][newcomp_soldier_col] == "g": board[newcomp_soldier_row][newcomp_soldier_col] = "O" board[comp_row_soldier][comp_col_soldier] = "O" board[guess_row_grenade][guess_col_grenade] = "g" set_home_position(board) print_board (board) x = True elif board[newcomp_soldier_row][newcomp_soldier_col] == "C": board[newcomp_soldier_row][newcomp_soldier_col] = "O" board[comp_row_soldier][comp_col_soldier] = "O" board[guess_row_cannon][guess_col_cannon] = "C" set_home_position(board) print_board (board) x = True elif board[newcomp_soldier_row][newcomp_soldier_col] == "O": board[newcomp_soldier_row][newcomp_soldier_col] = "X" board[comp_row_soldier][comp_col_soldier] = "O" comp_row_soldier = newcomp_soldier_row comp_col_soldier = newcomp_soldier_col set_home_position(board) print_board (board) x = True elif board[newcomp_soldier_row][newcomp_soldier_col] == "H": print "Congratulations! You won the game!!!" break if x == True: y = True else: break else: y = True