buggnubg - Bugs: bug #36485, External interface never drops

 
 

bug #36485: External interface never drops

Submitted by:  Guido Flohr <gflohr>
Submitted on:  Thu 17 May 2012 11:04:56 AM UTC  
 
Originator Name: Guido FlohrItem Group: Other bug
Category: Command line interfaceRelease: 0.90-devel
Privacy: PublicOperating System: All
OS Type: AnyProcessor Type: Any
Severity: 3 - NormalOpen/Closed: Closed
Assigned to: Guido Flohr <gflohr>Priority: 5 - Normal
Status: Fixed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 18 May 2012 11:19:28 AM UTC, comment #3:

Fixed now.

As it turned out, the position and the scores had to be swapped again only, when the cube was turned. This is owed to a different notion of playing direction and turn between FIBS and GNUBG.

I have attached a test script. You need BaldLies (git://git.guido-flohr.net/perl/BaldLies.git) for it. If you don't install BaldLies the test script is started in the checked out repository like this:

perl -Ilib/ test-gnubg-fibsboard.pl

It tests 11 critical match states. For each state it sets up two symmetrical positions ($match1 and $match2), renders them both for black and white, and feeds them into the external interface of GNUBG. The idea is that the position id is always the same for all four cases.

You have to start the external interface of GNUBG on port 9999 prior to starting the script.

I think, even without any Perl expertise it should be pretty easy to extend the tests.
I think, even with little or no Perl knowledge it should be easy to add more tests.

Guido Flohr <gflohr>
Project MemberIn charge of this item.
Thu 17 May 2012 10:03:26 PM UTC, comment #2:

Hi Michael,

I moved the swapping of the scores and the board from external.c to the parsing code in drawboard.c because I thought that the parser should normalize the parsed board state, not the caller. Search for "Opponent's turn?" in drawboard.c. I also swap the names (gratuitously) and may-double flags (maybe important) there, which was not done before.

The SwapSides() is now also moved implicitely to ParseFIBSBoard() and in all other contexts this works just fine. I'm pretty sure that it is correct.

I have played around with fTurn and the scores manually in the debugger but I never saw a drop from GNUBG.

Un^H^Hfortunately I will be on holidays for the next 10 days. I will have a look again, when I'm back.

Cheers,
Guido

Guido Flohr <gflohr>
Project MemberIn charge of this item.
Thu 17 May 2012 09:04:44 PM UTC, comment #1:

Howdy Guido,

I reviewed your last set of changes and I think I see where the
confusion is occurring, and what is driving the odd results.

A TanBoard structure which is defined as:

typedef unsigned int TanBoard[2][25];

Represent both players on the board. However the evaluation functions in
GNUBG assume the player on roll/move is ALWAYS player 1 (not player 0).

So whatever you do you have to make sure that you swap the board and the
score if the board passed in has player 0 on roll/move.

That is why this old code was very important:

anScore[ 0 ] = fTurn ? nScoreOpponent : nScore;
anScore[ 1 ] = fTurn ? nScore : nScoreOpponent;

...

if ( !fTurn )
SwapSides( anBoard );

I noticed you no longer swap the scores and the swapsides function is no
longer called and the score code no longer swaps:

anScore[ 0 ] = nScoreOpponent;
anScore[ 1 ] = nScore;

If you adjust your thinking and put back in the swapping so that the
perspective of player on roll/move is ALWAYS player 1 (never player 0),
and adjust the rest of your code to follow suit you should be able to
get it working.

I believe that the reason you are always seeing a take in these
situations is because the position was evaluated from the wrong player
being on roll/move. Namely in your example you sent, the bearoff
position had the person way behind cubing and of course the opponent had
a take. There are probably cases where the code would work and that is
where the FIBSBOARD had the person cubing already as player 1 (and the
swapping is unnecessary).

I hope that helps, I am pretty sure you will come up with a solution
based on this tidbit.

Michael Petch <mdpetch>
Project Administrator
Thu 17 May 2012 11:04:56 AM UTC, original submission:

I have fixed a couple of bugs of the external interface but I am stuck now with the last one. GNUBG replies to all doubles with "take", even in hopeless situations.

Example (requires a current CVS snapshot):

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
board:You:player_b:25:1:4:0:9:6:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:-9:-6:0:0:0:0:0:-1:0:0:0:0:1:0:0:0:1:-1:0:25:0:0:0:0:0:0:0:0
take

I changed the #if 0 to #if 1 in external.c, ExtFIBSBoard(), line 472 so that the board is dumped before the evaluation:

GNU Backgammon Position ID: //0AAADw+w8AAA
Match ID : no matchid
+13-14-15-16-17-18------19-20-21-22-23-24-+
| | | O O |
| | | O O |
| | | O O |
| | | O O |
| | | 6 9 |
v| |BAR| |
| | | 9 6 |
| | | X X |
| | | X X |
| | | X X |
| | | X X |
+12-11-10--9--8--7-------6--5--4--3--2--1-+

score 1-4 to 25 dice 0 0 cubeowner -1 cube 1 turn 1 crawford 0 doubled 1

I have played around changing the cube owner and the cube value but at no avail. GNUBG always replies with a take. I have about 30 more tests, and they show that roll-or-double decisions are taken correctly. So why not take-or-drop?

Guido Flohr <gflohr>
Project MemberIn charge of this item.

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #25879:  test-gnubg-fibsboard.pl added by gflohr (10kB - application/x-perl - Test script for external interface)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mdpetch (Updated the item)
  • -unavailable- added by gflohr (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 18 May 2012 11:19:57 AM UTCgflohrOpen/ClosedOpen=>Closed
      StatusIn Progress=>Fixed
    Fri 18 May 2012 11:11:17 AM UTCgflohrAttached File-=>Added test-gnubg-fibsboard.pl, #25879
    Fri 18 May 2012 11:10:22 AM UTCgflohrAssigned tomdpetch=>gflohr
    Thu 17 May 2012 04:52:14 PM UTCmdpetchAssigned toNone=>mdpetch
      StatusNone=>In Progress

    Back to the top


    Powered by Savane 3.1-cleanup