Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TicTacToe games utility method is incorrect #24

Closed
GoogleCodeExporter opened this issue Nov 7, 2015 · 3 comments
Closed

TicTacToe games utility method is incorrect #24

GoogleCodeExporter opened this issue Nov 7, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

Fixed in r54.

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

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant