本文整理汇总了Python中game_state.GameState.makeMove方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.makeMove方法的具体用法?Python GameState.makeMove怎么用?Python GameState.makeMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game_state.GameState
的用法示例。
在下文中一共展示了GameState.makeMove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import makeMove [as 别名]
class Game:
def __init__(self):
self.pastStateData = []
self.currentState = State()
def reset(self):
self.currentState.reset()
self.pastStateData = []
def makeMove(self, move):
self.pastStateData.append((self.currentState.toString(), -self.currentState.getPlayer()))
self.currentState.makeMove(move)
def getHeuristic(self):
if (self.currentState.getPlayer() == 1):
return self.starterHeuristic
else:
return self.followerHeuristic
def setHeuristic(self, heuristic, player):
heuristic.setState(self.currentState)
if (player == 1):
self.starterHeuristic = heuristic
else:
self.followerHeuristic = heuristic
def takeTurn(self):
move = self.getHeuristic().getForcedMove()
if move is None:
move = self.getHeuristic().getMove()
self.makeMove(move)
def play(self):
result = board.UNFINISHED
while result is board.UNFINISHED:
self.takeTurn()
result = self.getHeuristic().getGameResult()
return (self.pastStateData[1:], result)
示例2: getCompletenessScore
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import makeMove [as 别名]
def getCompletenessScore(self, move, player):
score = 0
completenessData = self.state.getLineCompleteness(move, player).data
for (numComplete, numLines) in enumerate(completenessData):
score += self.WEIGHTS[numComplete] * math.pow(numLines, self.POWERS[numComplete])
return score
if __name__ == '__main__':
# TESTS
from test import *
from game_state import GameState as State
state = State()
heuristic = PotentialWinsHeuristic()
heuristic.setState(state)
assertEquals((3, 0), heuristic.getMove())
state.makeMove((3, 0))
state.makeMove((3, 1))
assertEquals((2, 0), heuristic.getMove())
state.makeMove((3, 2))
state.makeMove((3, 3))
state.makeMove((3, 4))
state.makeMove((3, 5))
assertEquals((1, 0), heuristic.getMove())
state.makeMove((1, 0))
assertEquals((1, 1), heuristic.getMove())