コード例 #1
0
		players[1].save_comp_bomb_location()
		# print players[1].bomb_grid, players[1].bomb_str

		while(players[1].in_bombs_placed()):
			players[1].erase_bomb_locations()
			players[1].save_comp_bomb_location()

		print "\n%s placed a bomb at location %s." %(players[1].name, players[1].bomb_str)


	#human getting a bomb location
	if (players[turns_taken%2] == players[0]):
		print "Use letters A-J and numbers 1-10 for coordinates in the format 'A1'."
		#save valid bomb location str
		players[0].bomb_str = utilities.get_bomb_str(players[0].my_ships_board)
		# print players[turns_taken%2].bomb_str
		# Convert string location to a grid location
		players[0].create_bomb_grid(players[0].enemy_ships_board)

		# While bomb location is in bomb_list
		while (players[0].in_bombs_placed()):
		# 	While TRUE, 
			# Print ERROR MSG: already used pick new location
			print "Already bombed that spot."
			print "Pick a new location."
			
			# Get new bomb location
			# Save valid bomb location str
			players[0].bomb_str = utilities.get_bomb_str(players[0].my_ships_board)
コード例 #2
0
#Print updated players ship board
print computer.name
computer.print_my_ships_board()


#***********************************

#START CODE

# Ask for string bomb location
print "Use letters A-J and numbers 1-10 for coordinates in the format 'A1'."
print "Place a bomb."


#save valid bomb location str
player1.bomb_str = utilities.get_bomb_str(player1.my_ships_board)

#print player1.bomb_str

# Convert string location to a grid location
player1.create_bomb_grid(player1.enemy_ships_board)

# print player1.bomb_grid

# Check if bomb location is in bomb_list
if(player1.in_bombs_placed()):
# 	If TRUE, 
	# Print ERROR MSG: already used pick new location
	print "Already bombed that spot."
	print "Pick a new location."
	# CODE ASK FOR NEW LOCATION