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 732136 - Easy AI is better than medium AI when running tests
Easy AI is better than medium AI when running tests
Status: RESOLVED FIXED
Product: four-in-a-row
Classification: Applications
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Nikhar
four-in-a-row-maint
Depends on:
Blocks:
 
 
Reported: 2014-06-23 22:02 UTC by Michael Catanzaro
Modified: 2014-07-18 21:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug fix (2.08 KB, patch)
2014-07-18 17:37 UTC, Nikhar
needs-work Details | Review
Bug fix (2.38 KB, patch)
2014-07-18 19:00 UTC, Nikhar
committed Details | Review
Converted tabs to spaces (10.39 KB, patch)
2014-07-18 19:02 UTC, Nikhar
committed Details | Review

Description Michael Catanzaro 2014-06-23 22:02:17 UTC
TEST: ai-test... (pid=7005)
  /AI/Draw:                                                            OK
  /AI/Random:                                                          OK
  /AI/Take Win/Horizontal Win:                                         OK
  /AI/Take Win/Vertical Win:                                           OK
  /AI/Take Win/Forward Diagonal Win:                                   OK
  /AI/Take Win/Backward Diagonal Win:                                  OK
  /AI/Avoid Loss/Horizontal Loss:                                      OK
  /AI/Avoid Loss/Vertical Loss:                                        OK
  /AI/Avoid Loss/Forward Diagonal Loss:                                OK
  /AI/Avoid Loss/Backward Diagonal Loss:                               OK
  /AI/AI vs AI/Easy vs Medium:                                         **
ERROR:../../src/test-ai.c:496:test_easy_vs_medium: assertion failed: (easy_wins <= NUMBER_GAMES/2)
FAIL
GTester: last random seed: R02S1e6398470bf113549bd7d6d2287d5fff
(pid=7012)
  /AI/AI vs AI/Easy vs Hard:                                           OK
  /AI/AI vs AI/Medium vs Hard:                                         OK
FAIL: ai-test

I expected I would be able to reproduce this by running 'gtester --seed=R02S1e6398470bf113549bd7d6d2287d5fff test-ai' but running with the same random seed for some reason does not end in the same result.  I'm not sure why.
Comment 1 Michael Catanzaro 2014-06-23 22:03:21 UTC
Nikhar, can you take a look at this?
Comment 2 Nikhar 2014-07-18 17:37:10 UTC
Created attachment 281139 [details] [review]
Bug fix
Comment 3 Michael Catanzaro 2014-07-18 17:47:00 UTC
Review of attachment 281139 [details] [review]:

Looks pretty good, just a few changes please.

After you fix these, please add a SEPARATE patch to fix the indentation throughout the file: should be four spaces per indent, with no tab characters.

::: src/test-ai.vala
@@ +22,3 @@
 const int NUMBER_GAMES = 5;
+const int MAXIMUM_GAMES = 100;
+int games_contested;

Er, no, I don't think we need a global variable for this.

@@ +183,3 @@
+/* Repeatedly contest between the two AI until either easier win ratio is less than a threshold
+   or maximum numbers of contests have been played.*/
+private int repeat_contests (string easier, string harder)

You'll want to make this function return void, and take two additional out parameters: one for the number of times the easier AI won, and one for the games played. Then you won't need the global variable.

(Notice also that it's not clear from your comment or the name of this function what the return value is -- when that's unavoidable, you should add a comment.)

@@ +191,3 @@
+	{
+		if (easy_wins <= games_contested/4)
+			break;

This should be merged into the loop guard:

while (games_contested <= MAXIMUM_GAMES && easy_wins > games_contested/4)

@@ +204,1 @@
+	assert (easy_wins <= games_contested/4);

Let's use a constant instead of leaving magic 4s everywhere
Comment 4 Nikhar 2014-07-18 19:00:01 UTC
Created attachment 281142 [details] [review]
Bug fix
Comment 5 Nikhar 2014-07-18 19:02:55 UTC
Created attachment 281143 [details] [review]
Converted tabs to spaces
Comment 6 Michael Catanzaro 2014-07-18 21:46:18 UTC
Great