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

 
 

bug #36485: External interface never drops

Submitter:  Guido Flohr <gflohr>
Submitted:  Thu 17 May 2012 11:04:56 AM UTC
   
 
Originator Name:  Guido Flohr Item Group:  * Other bug
Category:  * Command line interface Release:  * 0.90-devel
Privacy:  Public Operating System:  * All
Severity:  * 3 - Normal Open/Closed:  Closed
Assigned to:  gflohr Priority:  5 - Normal
Status:  Fixed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group Member
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>
Group Member
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>
Group 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>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #25879:  test-gnubg-fibsboard.pl added by gflohr (10KiB - 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
  • -email is unavailable- added by mdpetch (Updated the item)
  • -email is unavailable- added by gflohr (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-05-18 gflohr Open/ClosedOpen Closed
        StatusIn Progress Fixed
    2012-05-18 gflohr Attached File- Added test-gnubg-fibsboard.pl, #25879
    2012-05-18 gflohr Assigned tomdpetch gflohr
    2012-05-17 mdpetch Assigned toNone mdpetch
        StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code