sunjay / reversi

Reversi implemented in Haskell as a terminal game
MIT License
4 stars 0 forks source link

AI does not protect advantageous positions #4

Closed sunjay closed 8 years ago

sunjay commented 8 years ago

In playing the AI often, I discovered that the optimal strategy it was using was actually quite simple. The AI attempts to place pieces on the edges where they cannot be taken back. It does this intelligently though. The AI will only claim an edge or corner when it can take as many pieces as possible in that move. Those pieces, once taken, are very difficult to claim back.

Unfortunately, this strategy can also very easily be used against the AI. By making moves that force the AI to allow me to move on the edge, I can very easily beat the AI pretty much every single game. These are not close games either.

The AI needs to be given a better heuristic than just a plain difference of scores. It needs to understand that edges are more valuable than other tiles and corners are the most valuable of all.

screenshot from 2016-08-29 17-44-07 screenshot from 2016-08-29 17-35-28 screenshot from 2016-08-29 17-15-12 screenshot from 2016-08-29 16-53-07

sunjay commented 8 years ago

Fixed this in https://github.com/sunjay/reversi/commit/de7600b859bf760b7ae9ca789b8d6acd56fb95dc.

Oh my goodness the AI is ridiculously powerful now. It will force you to make the position it wants you to one move at a time.

Beaten badly: screenshot from 2016-08-30 02-00-58

Just before that defeat: screenshot from 2016-08-30 02-00-35

Beaten even worse (didn't even let me fill up the board before it took all my tiles): screenshot from 2016-08-30 01-52-43

Knew in advance that it had already beaten me: screenshot from 2016-08-30 02-06-43

Sure enough: screenshot from 2016-08-30 02-11-36