DominikKoller / aima-python

Automatically exported from code.google.com/p/aima-python
0 stars 0 forks source link

TicTacToe games utility method is incorrect #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Firstly it does not have a player argument so none of the search algorithms 
work on it.

    def utility(self, state, player):
        "Return the value to X; 1 for win, -1 for loss, 0 otherwise."
        if player == 'X':
            return state.utility
        if player == 'O':
            return -state.utility

Does seem to work.

Tom Hall

Original issue reported on code.google.com by tom.h...@forward.co.uk on 11 Aug 2011 at 6:55

GoogleCodeExporter commented 9 years ago
ttt = TicTacToe()
state = ttt.initial
for move in [(2,1),(1,1),(3,1),(1,3),(2,2),(2,3),(3,3)]:
    state = ttt.make_move(move,state)
    ttt.display(state)

print ttt.legal_moves(state)
move = minimax_decision(state,ttt)
print move
state = ttt.make_move(move,state)
ttt.display(state)

Is how I tested it

Original comment by tom.h...@forward.co.uk on 11 Aug 2011 at 7:31

GoogleCodeExporter commented 9 years ago
Fixed in r54.

Original comment by wit...@gmail.com on 1 Sep 2011 at 10:19

GoogleCodeExporter commented 9 years ago
Probably would be worth pushing this fix to 
http://aima.cs.berkeley.edu/python/games.py and 
http://aima.cs.berkeley.edu/python/games.html

By the same token, I think http://aima.eecs.berkeley.edu/python/readme.html 
should mention http://code.google.com/p/aima-python or else be synchronized.

Original comment by Franck.Dernoncourt on 12 Mar 2012 at 10:07