Example #1
0
def main():
	global board
	#Initialization
	# add pieces to board and print board. 
	board = grid.setup_board(board)
	grid.print_board(board)

	# game loop. Play till user decides to quit
	while grid.get_winner(board):
		
		human.get_choice() 
		ai.get_move()
		board = grid.check_knight(board)
Example #2
0
def main() :
    for index in range(0, grid.NUM_OF_VESSELS) :
        human.get_location(index)
        t00_0_ai.get_location(index)

#    t00_0_ai.attack_grid.drop_test_bombs()
#    human.attack_grid.drop_test_bombs()

    while (not has_winner()) :
        # user's turn
        row, column = human.get_choice()
        if (t00_0_ai.defend_grid.is_hit(row, column)) :
            print("HIT!!")
        else :
            print("You missed.")
        t00_0_ai.defend_grid.drop_bomb(human.attack_grid, row, column)
        print()

        #ai's turn
        row, column = t00_0_ai.get_choice()
        if (human.defend_grid.is_hit(row, column)) :
            print("You've been hit.")
        else :
            print("I missed.")
        human.defend_grid.drop_bomb(t00_0_ai.attack_grid, row, column)
        human.defend_grid.print_grid()

    announce_winner()
def main():
	
	for i in range(grid.NUM_OF_VESSELS):
		
		#human.get_location(i)
		grid.add_vessel(human.grid_defend, i, i, 0, 'h') 
		ai.get_location(i)
		print("AI Grid:")
		grid.print_grid(ai.grid_defend)
		print("Human Grid:")
		grid.print_grid(human.grid_defend)  

	while not (grid.all_vessels_sunk(ai.grid_defend) and grid.all_vessels_sunk(human.grid_defend)):
		
		human.enter_choice()
		
		row, col = human.get_choice()
		grid.drop_bomb(ai.grid_defend, human.grid_attack, row, col)
		
		row, col = ai.get_choice()
		grid.drop_bomb(human.grid_defend, ai.grid_attack, row, col)
		
		print("AI Grid:")
		grid.print_grid(ai.grid_defend)
		print("Human Grid:")
		grid.print_grid(human.grid_defend)  
		print("AI Grid A:")
		grid.print_grid(ai.grid_attack)
		print("Human Grid A:")
		grid.print_grid(human.grid_attack)  
Example #4
0
def main():

    for i in range(grid.NUM_OF_VESSELS):

        #human.get_location(i)
        grid.add_vessel(human.grid_defend, i, i, 0, 'h')
        ai.get_location(i)
        print("AI Grid:")
        grid.print_grid(ai.grid_defend)
        print("Human Grid:")
        grid.print_grid(human.grid_defend)

    while not (grid.all_vessels_sunk(ai.grid_defend)
               and grid.all_vessels_sunk(human.grid_defend)):

        human.enter_choice()

        row, col = human.get_choice()
        grid.drop_bomb(ai.grid_defend, human.grid_attack, row, col)

        row, col = ai.get_choice()
        grid.drop_bomb(human.grid_defend, ai.grid_attack, row, col)

        print("AI Grid:")
        grid.print_grid(ai.grid_defend)
        print("Human Grid:")
        grid.print_grid(human.grid_defend)
        print("AI Grid A:")
        grid.print_grid(ai.grid_attack)
        print("Human Grid A:")
        grid.print_grid(human.grid_attack)