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 734866 - Undo is broken with two human players
Undo is broken with two human players
Status: RESOLVED FIXED
Product: iagno
Classification: Applications
Component: general
3.13.x
Other Linux
: Normal normal
: ---
Assigned To: iagno-maint
iagno-maint
Depends on:
Blocks:
 
 
Reported: 2014-08-15 15:39 UTC by Michael Catanzaro
Modified: 2014-08-16 21:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Correct undo when in two-players mode. (5.56 KB, patch)
2014-08-16 10:48 UTC, Arnaud B.
none Details | Review
Correct undo when in two-players mode. (5.56 KB, patch)
2014-08-16 10:55 UTC, Arnaud B.
rejected Details | Review
Fix undo in two-player games (880 bytes, patch)
2014-08-16 13:46 UTC, Michael Catanzaro
none Details | Review
Fix undo in two-player games (1.20 KB, patch)
2014-08-16 19:55 UTC, Michael Catanzaro
none Details | Review
Fix undo in two-players game. (1.30 KB, patch)
2014-08-16 20:38 UTC, Arnaud B.
reviewed Details | Review
Fix undo in two-players mode. (1.55 KB, patch)
2014-08-16 21:37 UTC, Arnaud B.
committed Details | Review

Description Michael Catanzaro 2014-08-15 15:39:44 UTC
Undo is broken with two human players -- it undos two moves instead of one, and does nothing before the second ply.
Comment 1 Arnaud B. 2014-08-16 10:48:31 UTC
Created attachment 283588 [details] [review]
Correct undo when in two-players mode.

Here is a patch. The function can_undo() changes: it’s goal is to test if we already played enough to undo a move (or to restart the game), depending on the game mode; the undo() function shouldn’t be callable if undoing is impossible.
Comment 2 Arnaud B. 2014-08-16 10:55:11 UTC
Created attachment 283589 [details] [review]
Correct undo when in two-players mode.

Oops, no need to have a public gamemode (for now).
Comment 3 Michael Catanzaro 2014-08-16 13:44:09 UTC
Review of attachment 283589 [details] [review]:

I'm a bit confused by this patch. There was previously nothing wrong with can_undo(): you know that because the undo button was always sensitive or insensitive at the correct times.

::: src/iagno.vala
@@ +336,3 @@
 
+        if (gamemode == "two-players")
+        {

This here is what actually fixes the bug. There's a logic error in the if statement below that causes us to take the game.undo (2) case instead of the game.undo (1) case when the game has two players.

I think that by returning early here, you skip the logic that handles undoing an infinite number of times as long as the player was forced to pass, which should cause undo to fail after a pass.  But none of this matters since we can just fix the original logic error now that we've found it.
Comment 4 Michael Catanzaro 2014-08-16 13:46:43 UTC
Created attachment 283592 [details] [review]
Fix undo in two-player games

I think this patch also fixes it without breaking undo after passing; do you see any problems with it?
Comment 5 Arnaud B. 2014-08-16 19:45:47 UTC
I find all the undo-related code confusing, that’s why I tried a better definition of some parts, but you’re right, there’s a bug in my patch. Yours isn’t perfect on the exact same case, but at least it undoes. ^^ On a two-players game:
1) light player plays;
2) dark player plays;
3) light can’t play, dark player plays;
4) light can’t play, dark player plays;
5) light can’t play, dark player plays;
6) “undo” pressed, back to… 2).
I think it’s not exactly the expected result. ^^
Comment 6 Michael Catanzaro 2014-08-16 19:55:56 UTC
Created attachment 283621 [details] [review]
Fix undo in two-player games

Adapted from work by Arnaud Bonatti
Comment 7 Arnaud B. 2014-08-16 20:38:29 UTC
Created attachment 283623 [details] [review]
Fix undo in two-players game.

I think that works.
Comment 8 Michael Catanzaro 2014-08-16 21:06:23 UTC
Review of attachment 283623 [details] [review]:

Makes sense to me.

I think it'd be a bit cleaner to modify the first if statement instead of adding a new one:

if (game.current_color != player_one || (computer == null && game.can_move (game.current_color))
Comment 9 Arnaud B. 2014-08-16 21:37:37 UTC
Created attachment 283626 [details] [review]
Fix undo in two-players mode.

I think it’s clearer like that (and looks like it works and doesn’t break anything else).
Comment 10 Michael Catanzaro 2014-08-16 21:54:28 UTC
Review of attachment 283626 [details] [review]:

Yes, this is best.
Comment 11 Michael Catanzaro 2014-08-16 21:56:09 UTC
Attachment 283626 [details] pushed as df86d60 - Fix undo in two-players mode.