Game traversal happening (no limits = crash)
This commit is contained in:
parent
e38012b8fd
commit
c443081083
|
@ -55,15 +55,26 @@ class State():
|
|||
if (card.house == picked_card.house):
|
||||
# Pick it up
|
||||
picked_cards.append(card)
|
||||
self.board[row][col] = game.House.empty
|
||||
empty_card = game.Card.new_message()
|
||||
empty_card.house = game.House.empty
|
||||
self.board[row][col] = empty_card
|
||||
|
||||
print(picked_cards)
|
||||
return self
|
||||
|
||||
def findVarys(self):
|
||||
for card in self.state.cardlist:
|
||||
if card.house == 'varys':
|
||||
return card.location
|
||||
|
||||
"""
|
||||
Returns true if the game has
|
||||
reached the final state ie
|
||||
there are no legal possible moves
|
||||
"""
|
||||
|
||||
def gameOver(self):
|
||||
return (len(self.getPossibleMoves()) == 0)
|
||||
|
||||
def getPossibleMoves(self):
|
||||
moves = []
|
||||
|
||||
|
@ -105,6 +116,7 @@ class State():
|
|||
seen = {}
|
||||
|
||||
for (xx, yy) in l:
|
||||
print(self.board[xx][yy])
|
||||
house = self.board[xx][yy].house
|
||||
if str(house) in seen:
|
||||
return False
|
||||
|
|
|
@ -34,14 +34,15 @@ class GameNode(object):
|
|||
return (w / n) + (c * math.sqrt(log(t) / n))
|
||||
|
||||
def runSimulation(self):
|
||||
print(self.state)
|
||||
self.backPropagate(self.simulate())
|
||||
|
||||
def simulate(self):
|
||||
state = self.state
|
||||
|
||||
while not state.gameOver:
|
||||
while not state.gameOver():
|
||||
moves = state.getPossibleMoves()
|
||||
randomMove = random.choice(possibleMoves)
|
||||
randomMove = random.choice(moves)
|
||||
state = state.playMove(randomMove)
|
||||
|
||||
return self.state.result(state)
|
||||
|
|
Loading…
Reference in New Issue