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):
|
if (card.house == picked_card.house):
|
||||||
# Pick it up
|
# Pick it up
|
||||||
picked_cards.append(card)
|
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):
|
def findVarys(self):
|
||||||
for card in self.state.cardlist:
|
for card in self.state.cardlist:
|
||||||
if card.house == 'varys':
|
if card.house == 'varys':
|
||||||
return card.location
|
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):
|
def getPossibleMoves(self):
|
||||||
moves = []
|
moves = []
|
||||||
|
|
||||||
|
@ -105,6 +116,7 @@ class State():
|
||||||
seen = {}
|
seen = {}
|
||||||
|
|
||||||
for (xx, yy) in l:
|
for (xx, yy) in l:
|
||||||
|
print(self.board[xx][yy])
|
||||||
house = self.board[xx][yy].house
|
house = self.board[xx][yy].house
|
||||||
if str(house) in seen:
|
if str(house) in seen:
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -34,14 +34,15 @@ class GameNode(object):
|
||||||
return (w / n) + (c * math.sqrt(log(t) / n))
|
return (w / n) + (c * math.sqrt(log(t) / n))
|
||||||
|
|
||||||
def runSimulation(self):
|
def runSimulation(self):
|
||||||
|
print(self.state)
|
||||||
self.backPropagate(self.simulate())
|
self.backPropagate(self.simulate())
|
||||||
|
|
||||||
def simulate(self):
|
def simulate(self):
|
||||||
state = self.state
|
state = self.state
|
||||||
|
|
||||||
while not state.gameOver:
|
while not state.gameOver():
|
||||||
moves = state.getPossibleMoves()
|
moves = state.getPossibleMoves()
|
||||||
randomMove = random.choice(possibleMoves)
|
randomMove = random.choice(moves)
|
||||||
state = state.playMove(randomMove)
|
state = state.playMove(randomMove)
|
||||||
|
|
||||||
return self.state.result(state)
|
return self.state.result(state)
|
||||||
|
|
Loading…
Reference in New Issue