Jump to content

New bug in handviewer code


smerriman

Recommended Posts

It looks like the old 1-character bug has been fixed - yay :)

 

Unfortunately, an extra line of code was added at the same time which is causing more regular issues.

 

Here's a silly hand diagram demonstrating the problem clearly, though it actually pops up on nearly every hand.

 

[hv=https://www.bridgebase.com/tools/handviewer.html?a=1NPPP&d=e&s=SA32HAKQDAKQcAKQJ&w=SKQT9754H432D32C2&n=S86HJT98DJT9CT987&p=SAS4S6SJS3]400|300[/hv]

 

Click through to after the lead to trick 2 and click GIB to see missing results for the T, 9, and 5.

 

Specifically, any time two cards that weren't originally equals now are due to the intermediate cards having been played on earlier tricks, the lower cards never show a double dummy score.

 

This is due to a new line of code which been added (wasn't there last time I checked) - the long line with the comment here:

 

 

   for (c = card; c >= 0; c--) {
     if (deck[suit][c] >= 0 && deck[suit][c] != whosTurn) {
       break;
     }
     if (deck[suit][c] < 0 && deck[suit][c] - 4 != whosTurn) {  // played card belongs to someone else?  note that deck[suit][c] is set to whosTurn-4 in playCard(..) once a card is played
       break;
     }
     if (deck[suit][c] >= 0) {
       if (gibDivs[suit][c].parentNode != div) {
         div.appendChild(gibDivs[suit][c]);
         if (tricks >= goal) {
           gibDivs[suit][c].style.background = '#B0D57E';
           gibDivs[suit][c].style.color = '#000000';
           if (tricks == goal) {
             div.lastChild.innerHTML = '=';
           } else {
             div.lastChild.innerHTML = tricks - goal;
           }
         } else {
           div.lastChild.style.background = '#CB0000';
           div.lastChild.style.color = '#FFFFFF';
           div.lastChild.innerHTML = goal - tricks;
         }
       }
     } else {
       var inThisTrick = false;
       for (var it = 0; it <= inTrick; it++) {
         if (suitPlayed[trick][it] == suit && rankPlayed[trick][it] == c) {
           inThisTrick = true;
           break;
         }
       }

       if (inThisTrick == true) {
         break;
       }
   }

 

 

The server request only returns scores for cards that really aren't equals (SK and S7), with this loop in the handviewer code meant to apply the same score to the remaining equals. But the commented line specifically tests if the next card was played by another hand on an earlier trick, and stops adding scores.

 

It's only meant to stop if the card hasn't been played, or was played by another hand to the *same* trick, which is what the later inThisTrick part does. So that line of code shouldn't be there.

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

The line you refer to was supposedly part of this fix for this earlier problem https://www.bridgebase.com/forums/topic/84587-gib-makes-dd-error/page__view__findpost__p__1013211. We're looking into it.

 

We originally made the change from < to <= that you suggested, but that didn't fix all the problems, so this was done later and we thought it was the complete fix.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...