Zulko / easyAI

Python artificial intelligence framework for games
http://zulko.github.io/easyAI/
Other
639 stars 126 forks source link

Either the docs need update or DictTT is very broken. #19

Closed JohnAD closed 7 years ago

JohnAD commented 7 years ago

Following the documentation at:

http://zulko.github.io/easyAI/get_started.html#human-and-ai-players

Adding tt=table to Negamax, where table that is an instance of DictTT results in:

AttributeError: DictTT instance has no attribute 'lookup'

Looking at the Nim.py example, it appears that perhaps that the TT class is supposed to be used instead. Using that, unfortunately, appears to create an infinite loop where a few board states are toggled back and forth when the .play() method is invoked with two AI players.

The id_solve function used by Nim.py does not appear to have the looping problem. so that might be a starting point for diagnosis. The game I'm writing is, unfortunately, not really solvable. Not with an off-the-shelf computer anyway. :)

I'm happy to help fix this, but I'd like feedback first. I'd hate to solve a problem that already has a quick work-around. :)

If curious, I'm using a genetics algorithm with easyAI to optimize the relative value of tactics and short-term strategies. My YouTube video for this: https://www.youtube.com/watch?v=Y6P-_sTYQcM

JohnAD commented 7 years ago

A point of curiosity: the example Connect Four game appears to have once used DictTT as it has an import statement:

http://zulko.github.io/easyAI/examples/games.html#connect-4

However, it is no longer being invoked. Ironically, it is using the .play() method with two AIs, which is the very situation I am trying to make work.

Odd coincidence possibly as history does not show ConnectFour ever supporting a transposition table.

JohnAD commented 7 years ago

As to the looping problem: my bad. The problem was simply not creating a valid tuple with tt_entry. Sometimes it's the obvious stuff in retrospect. Ironically, use of TT slows my game down rather than speed it up. (2.5s vs 13s on a test run.) I suspect that is because each branch can be between 3 and 60 possible moves. It fans out too much.

The title of the subject remains true: the docs are out of date (assuming TT is the correct class, not DictTT.)

I'd be happy to update the documentation. I'm also thinking:

JohnAD commented 7 years ago

docs updating with PR #21