After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 707730 - Review AI's choice of strategy
Review AI's choice of strategy
Status: RESOLVED FIXED
Product: iagno
Classification: Applications
Component: general
3.9.x
Other Linux
: Normal normal
: ---
Assigned To: iagno-maint
iagno-maint
Depends on:
Blocks:
 
 
Reported: 2013-09-08 17:25 UTC by Michael Catanzaro
Modified: 2014-09-19 13:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
computer-player: refactor strategies (2.83 KB, patch)
2014-09-19 05:27 UTC, Michael Catanzaro
committed Details | Review

Description Michael Catanzaro 2013-09-08 17:25:22 UTC
The AI uses three strategies throughout the game: Best, Perfect, and Victory.  Best is used for the majority of the game.  Towards the end, it switches to Victory, and then one turn later to Perfect.  That can't be right: why should there be a strategy that's used for only one turn?  This needs to be reviewed (preferably by someone who understands them).

The code in question was recently changed due to Bug #668553, but I kept the original behavior for choosing strategy.
Comment 1 Michael Catanzaro 2014-09-19 05:27:03 UTC
Arnaud, can you sanity-check me on this please?
Comment 2 Michael Catanzaro 2014-09-19 05:27:22 UTC
Created attachment 286567 [details] [review]
computer-player: refactor strategies

The victory strategy was pointless and just made the AI play worse
at the end of the game before the AI could see to the final move.

Rename the other strategies to make sense.
Comment 3 Arnaud B. 2014-09-19 06:36:55 UTC
No technical problem with the code. I don’t really understand the Victory strategy, it is probably here to make a smooth transition between two “typed” strategies, but I’m not sure. Basically, it would need testing. ^^ 

Concerning the level 1… I already told my opinion here[1]; it would at least be better if he chooses place at random during a part of the game (we have a function…), and switch to MAXIMIZE_TILES at the same time the other levels.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=736938#c3
Comment 4 Arnaud B. 2014-09-19 07:48:48 UTC
In fact, concerning the level 1, it would be quite better to just adjust the depth of the search, using the MAXIMIZE_TILES strategy all the game long. Let’s say, `var depth = level * 2;`? That would reduce the time of search of the level 3…
Comment 5 Michael Catanzaro 2014-09-19 13:25:11 UTC
(In reply to comment #3)
> No technical problem with the code. I don’t really understand the Victory
> strategy, it is probably here to make a smooth transition between two “typed”
> strategies, but I’m not sure. Basically, it would need testing. ^^ 

The point of the Victory strategy was to clamp the heuristic value to simply "I will win" or "I will lose" -- it's harmless if the AI can see all the way to the end of the game, but it makes it play worse otherwise. So I think we should go with it.

> Concerning the level 1… I already told my opinion here[1]; it would at least be
> better if he chooses place at random during a part of the game (we have a
> function…), and switch to MAXIMIZE_TILES at the same time the other levels.
> 
> [1] https://bugzilla.gnome.org/show_bug.cgi?id=736938#c3

The problem is that I'm not sure anything else we do will really make the easy AI easy enough.  It's pretty obviously dumb at first, but towards the end of the game even the worst possible move can hurt, and it turns out OK (it loses when I play it, but not by much).

Ideally we would have an AI that looks like it's making smart moves while actually setting the human up for a win, but I have no clue how you'd write such a thing.

(In reply to comment #4)
> In fact, concerning the level 1, it would be quite better to just adjust the
> depth of the search, using the MAXIMIZE_TILES strategy all the game long. Let’s
> say, `var depth = level * 2;`? That would reduce the time of search of the
> level 3…

We could try it, but I think that would still be too strong for easy.

Another thing we could do once we have libgames-scores hooked up is secretly track how many games the player has won, and offer to change the difficulty level if he's winning a lot. Or simply make difficulty level selection more obvious.
Comment 6 Michael Catanzaro 2014-09-19 13:25:37 UTC
Attachment 286567 [details] pushed as 8bab807 - computer-player: refactor strategies