本文整理汇总了Python中gamestate.GameState.make_move方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.make_move方法的具体用法?Python GameState.make_move怎么用?Python GameState.make_move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gamestate.GameState
的用法示例。
在下文中一共展示了GameState.make_move方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_move
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
def test_invalid_move(self):
"""Tests that invalid moves raise an exception"""
GameStateTest.G.add_edge(0, 1)
state = GameState(GameStateTest.G)
state.make_move(0)
state.make_move(1)
self.assertRaises(InvalidMoveException)
示例2: test_gameover_state
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
def test_gameover_state(self):
"""Tests proper gameover state."""
state = GameState(GameStateTest.G)
state.make_move(0)
state.make_move(1)
state.make_move(2)
self.assertEquals(state.turn, labels.RED)
self.assertTrue(state.is_gameover())
self.assertTrue(state.is_terminal())
示例3: test_available_moves
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
def test_available_moves(self):
"""
Tests that valid moves are returned when queried especially after
a move has been made.
"""
GameStateTest.G.add_edge(0, 1)
state = GameState(GameStateTest.G)
self.assertEquals(state.get_available_moves(), [0, 1, 2])
state.make_move(0)
state.alternate_turn()
self.assertEquals(state.get_available_moves(), [2])
示例4: test_terminal_state
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
def test_terminal_state(self):
"""Tests proper terminal state."""
GameStateTest.G.add_edge(0, 1)
GameStateTest.G.add_node(3)
GameStateTest.G.add_edge(2, 3)
state = GameState(GameStateTest.G)
self.assertEquals(state.turn, labels.RED)
state.make_move(0)
state.alternate_turn()
state.make_move(2)
self.assertFalse(state.is_gameover())
self.assertTrue(state.is_terminal())
示例5: REPL
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
class REPL(object):
def __init__(self):
n = input("Number of vertices: ")
p = input("Edge probability: ")
color = raw_input("Select your color (R/B): ")
G = nx.erdos_renyi_graph(n, p)
self.state = GameState(G)
if color == 'R':
self.red = player.HumanPlayer(labels.RED)
self.blue = player.BotPlayer(labels.BLUE)
else:
self.red = player.BotPlayer(labels.RED)
self.blue = player.HumanPlayer(labels.BLUE)
print os.linesep, 'GAME HAS BEGUN', os.linesep
plt.ion()
plt.axis('off')
plt.show()
def error(self, e):
print e
def run(self):
while not self.state.is_gameover():
plt.clf()
self.state.draw()
try:
if self.state.turn is labels.RED:
move = self.red.get_move(self.state)
else:
move = self.blue.get_move(self.state)
if move is None:
print move, 'is none'
self.state.make_move(move)
self.state.alternate_turn()
plt.draw()
except GameoverException, e:
break
winner = self.state.winner
print winner, "is the winner."
示例6: test_available_count
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
def test_available_count(self):
state = GameState(GameStateTest.G)
self.assertEquals(state.count_available(), 3)
state.make_move(0)
self.assertEquals(state.count_available(), 2)
state.make_move(1)
self.assertEquals(state.count_available(), 1)
state.make_move(2)
self.assertEquals(state.count_available(), 0)
示例7: test_normal_play
# 需要导入模块: from gamestate import GameState [as 别名]
# 或者: from gamestate.GameState import make_move [as 别名]
def test_normal_play(self):
"""Tests a normal game."""
state = GameState(GameStateTest.G)
self.assertEquals(state.turn, labels.RED)
state.make_move(0)
self.assertFalse(state.check_gameover)
state.alternate_turn()
self.assertEquals(state.turn, labels.BLUE)
state.make_move(1)
self.assertFalse(state.check_gameover)
state.alternate_turn()
self.assertEquals(state.turn, labels.RED)
state.make_move(2)
self.assertTrue(state.check_gameover)
state.alternate_turn()
self.assertEquals(state.turn, labels.BLUE)
self.assertTrue(state.is_gameover())
self.assertTrue(state.is_terminal())
self.assertEquals(state.winner, labels.RED)