本文整理汇总了Python中ai.AI.make_move方法的典型用法代码示例。如果您正苦于以下问题:Python AI.make_move方法的具体用法?Python AI.make_move怎么用?Python AI.make_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ai.AI
的用法示例。
在下文中一共展示了AI.make_move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: game_board
# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import make_move [as 别名]
#.........这里部分代码省略.........
that_player = player_two
if player_types[0]=='AI':
mode='AI'
player_graphic="ai.bmp"
else:
mode='Human'
player_graphic = "player_one.bmp"
if moves % 2 == 1:
this_player = player_two
that_player = player_one
if player_types[1]=='AI':
mode='AI'
player_graphic="ai.bmp"
else:
mode='Human'
player_graphic = "player_two.bmp"
for x in range(5):
for y in range(5):
if board.marks[x][y] is None:
spriterenderer.render(factory.from_image(self.RESOURCES.get_path("tile.bmp")),x*64,y*64)
if board.marks[x][y] == player_one:
spriterenderer.render(factory.from_image(self.RESOURCES.get_path("tile_o.bmp")),x*64,y*64)
if board.marks[x][y] == player_two:
spriterenderer.render(factory.from_image(self.RESOURCES.get_path("tile_x.bmp")),x*64,y*64)
if board.check_winning_positions() != (False,False):
winning_player = board.check_winning_positions()[0]
if winning_player == player_one:
winning_graphic = 'player_one_wins.bmp'
if player_one != 'Guest' and not updated_p1:
player=pd.load_player(player_one)
pd.update_player(player_one,player.wins+1,player.losses)
updated_p1 = True
if player_two != 'Guest' and not updated_p2:
player=pd.load_player(player_two)
pd.update_player(player_two,player.wins,player.losses+1)
updated_p2=True
elif winning_player == player_two:
winning_graphic = 'player_two_wins.bmp'
if player_one != 'Guest' and not updated_p2:
player=pd.load_player(player_two)
pd.update_player(player_two,player.wins+1,player.losses)
updated_p2=True
if player_two != 'Guest' and not updated_p1:
player=pd.load_player(player_one)
pd.update_player(player_one,player.wins,player.losses+1)
updated_p1=True
spriterenderer.render(factory.from_image(self.RESOURCES.get_path(winning_graphic)),0,(x+1)*64)
events = sdl2ext.get_events()
for event in events:
if event.type == SDL_MOUSEBUTTONDOWN:
running = False
SDL_Delay(1000)
break
elif moves == 25:
winning_graphic = "tie_game.bmp"
spriterenderer.render(factory.from_image(self.RESOURCES.get_path(winning_graphic)),0,(x+1)*64)
events = sdl2ext.get_events()
for event in events:
if event.type == SDL_MOUSEBUTTONDOWN:
running = False
break
elif mode == 'Human':
spriterenderer.render(factory.from_image(self.RESOURCES.get_path(player_graphic)),0,(x+1)*64)
events = sdl2ext.get_events()
for event in events:
if event.type == SDL_QUIT:
running = False
break
elif event.type == SDL_MOUSEBUTTONDOWN:
x_pos = int(event.button.x/64)
y_pos = int(event.button.y/64)
if x_pos <= 4 and y_pos <= 4 and board.marks[x_pos][y_pos] is None:
board.marks[x_pos][y_pos]=this_player
moves = moves + 1
elif mode=='AI':
move = ai.make_move(board,this_player,that_player)
moves = moves + 1
board.update_position(move[0],move[1],this_player)
for x in range(5):
for y in range(5):
if board.marks[x][y] is None:
spriterenderer.render(factory.from_image(self.RESOURCES.get_path("tile.bmp")),x*64,y*64)
if board.marks[x][y] == player_one:
spriterenderer.render(factory.from_image(self.RESOURCES.get_path("tile_o.bmp")),x*64,y*64)
if board.marks[x][y] == player_two:
spriterenderer.render(factory.from_image(self.RESOURCES.get_path("tile_x.bmp")),x*64,y*64)
spriterenderer.render(factory.from_image(self.RESOURCES.get_path(player_graphic)),0,(x+1)*64)
SDL_Delay(500)
events = sdl2ext.get_events()
for event in events:
if event.type == SDL_QUIT:
running = False
break
else:
pass
else:
raise Exception
SDL_Delay(10)
sdl2ext.quit()
示例2: MyWin
# 需要导入模块: from ai import AI [as 别名]
# 或者: from ai.AI import make_move [as 别名]
#.........这里部分代码省略.........
# self.item.setOffset(47+y*61, 16+x*53)
# self.scene.addItem(self.item)
# QMessageBox.about(self, "Strzal", "({}, {})".format(x, y))
self.send = (x, y)
self.client.sendObj({"x": x, "y": y})
else:
QMessageBox.about(self, "Blad", "Niepoprawne pola")
else:
QMessageBox.about(self, "Info", "Nie polaczyles sie z przeciwnikiem")
if is_hit:
pass
else:
pass
else:
x = self.x_field.text()
y = self.y_field.text()
x, y = parser(x, y)
if x != -1 and y != -1:
if self.enemies_board[x][y] == 1:
self.enemies_board[x][y] = 2
is_hit = True
picture = 'res/ok.png'
else:
self.enemies_board[x][y] = 3
is_hit = False
picture = 'res/cancel.png'
self.is_my_turn = False
self.ai.make_move()
def get_shot(self, x, y):
'''
Shot handler.
:param x: x coord of shot
:param y: y coord of shot
'''
is_Hit = False
if self.my_board[x][y] == 1:
self.my_board[x][y] = 2
is_hit = True
picture = 'res/ok.png'
else:
self.my_board[x][y] = -1
is_hit = False
picture = 'res/cancel.png'
if x % 2 != 0:
self.item = QGraphicsPixmapItem(QPixmap(picture))
self.item.setOffset(16+y*61, 17+(x*52))
self.scene.addItem(self.item)
elif x % 2 == 0:
self.item = QGraphicsPixmapItem(QPixmap(picture))
self.item.setOffset(47+y*61, 16+x*53)
self.scene.addItem(self.item)
def set_ship(self):
if not self.is_client_connected:
x = self.set_X.text()
y = self.set_Y.text()