Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: To Experienced Java Programmers: strange BUG!!

Author: Bernd Nürnberger

Date: 05:49:11 05/06/04

Go up one level in this thread


On May 06, 2004 at 08:43:20, James Swafford wrote:

>On May 06, 2004 at 07:07:57, Bernd Nürnberger wrote:
>
>>Hello,
>>
>>I have a really strange bug in my move generator, but in the meantime,
>>after thourough debugging, I am more and more convinced, that it is not
>>a bug in my programming but a bug in Java itself or in the OS/Hardware
>>(but I am still hoping, I made a mistake somewhere ...).
>>
>>I have a iBook 300, Mac OS 9.x, and the latest Java for Mac OS 9.x (I think
>>its MRJ SDK 2.2.4 or so).
>>
>>HERE COMES THE PROBLEM:
>>
>>Some 64 bit long values behave really strange: the upper part (the 32 MSBs)
>>are trashed from time to time (lower 32 bits are OK, upper 32 bits seem
>>more or less random). I looked through the code again and again, so that
>>all literals have a "L" appended, and all literals seems ok now.
>>
>>Could it be, that some operators in Java on long values are not properly
>>implemented and make errors on certain circumstances? Maybe a set upper
>>bit (64th bit, sign bit) causes problems in some cases?
>>
>>I would be really glad to hear your thoughts are even solutions to this
>>kind of problem.
>>
>>Many many thanks in advance for your answers!
>
>My SWAG: your 'trash' in the upper 32 bits are coming from
>an OR op.  You're sure all your bitboards are properly
>initialized?
>
>Hard to say any more without looking over code. :-/
>
>--
>James

Thanks for this hint. I will also try to get a good Java
Debugger to get deeper into this problem. More strangly is the
behaviour that, if I output blackLegalMoves, for instance,
I get correct values!!

--- snippet ---
      // k -- black king
      /////////////////////

      from = board.blackKing;
      mvboard = KING_MOVES[from] & blackLegalMoves;
      halfply = from | Move.BPC_KING;
      while (mvboard != 0L) {
        to = Bitboard.last(mvboard);
        mvboard &= Bitboard.CLEAR_MASK[to];
        moves[mvidx++] = halfply | to << Move.TO | piece[to] << Move.CAPTY;
      }
--- snippet ---

Greetings, Bernd



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.