for Pascal fans: Critter

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: for Pascal fans: Critter

Post by rvida »

Steve Maughan wrote: However, it crashes at line 707 of uBitboard.pas with an access violation as s = -7.

FYI, sq = A1, occ = 0, mask = 35604928818740736, i = 1
Ooops, there is an obvious bug. I wonder why it works on 32bits.

Corrected code:

Code: Select all

function slider_attacks(sq: TSquare; occ, mask: TBitboard; const deltas: TDeltas): TBitboard;
var
  i: integer;
  s: TSquare;
begin
  result := BB_Empty;
  for i := 0 to 3 do begin
    s := delta_add(sq, deltas[i]);
    while valid_square&#40;integer&#40;s&#41;) and &#40;SquareBB&#91;s&#93; and mask <> 0&#41; do begin
      if &#40;square_distance&#40;s, delta_sub&#40;s, deltas&#91;i&#93;)) <> 1&#41; then break;
      set_bit&#40;result, s&#41;;
      if SquareBB&#91;s&#93; and occ <> 0 then break;
      inc&#40;s, deltas&#91;i&#93;);
    end;
  end;
end;
Sorry for the inconvenience. :oops:
User avatar
Steve Maughan
Posts: 1222
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: for Pascal fans: Critter

Post by Steve Maughan »

Richard,

Now it crashes at line 136 of uTranstab.pas with an AV.

Any idea?

Steve
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: for Pascal fans: Critter

Post by rvida »

Steve Maughan wrote:Richard,

Now it crashes at line 136 of uTranstab.pas with an AV.

Any idea?

Steve
My guess:
The size_t type is defined as cardinal in platform.inc. For 64bit platforms it should be defined as int64.

Soon I will upgrade my Delphi to XE2 and sort out all this stuff.

Richard
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: for Pascal fans: Critter

Post by rvida »

Just updated to 1.1.37

- added support for 64bit Delphi XE2
- 64bit binary included

Richard
User avatar
Steve Maughan
Posts: 1222
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: for Pascal fans: Critter

Post by Steve Maughan »

Richard,

Great!! I'll grab a copy. How does the 64 bit version compare in terms of speed?

Steve
User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 12:00 pm
Location: Slovakia, EU

Re: for Pascal fans: Critter

Post by rvida »

Steve Maughan wrote:How does the 64 bit version compare in terms of speed?
About 35% speedup in the opening, somewhat less (~20%) in late mid-game.

Code: Select all

postiton #1&#58; rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
position #2&#58; 6r1/1p2Q1pk/2p2p1p/n2p1P1P/p2P4/P1P1P3/1P1KR3/q2N4 b - -
position #3&#58; 1r6/R1nk1p2/1p4pp/pP1p1P2/P2P3P/5PN1/5K2/8 w - -

#  32bit 64bit speedup
----------------------
#1   694   934  +34.5%
#2  1017  1261  +23.9%
#3  1211  1449  +19.6%

Measured with 1 thread and 64mb hash on a Phenom II X6 1090T


Richard
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: for Pascal fans: Critter

Post by sje »

rvida wrote:

Code: Select all

    while valid_square&#40;integer&#40;s&#41;) and &#40;SquareBB&#91;s&#93; and mask <> 0&#41; do 
Is it the case that the Pascal dialect which you're using guarantees short circuit boolean evaluation? If not, I can see where there could be a problem.

This has been an issue with the Bozochess coding. Because I don't know which short circuit scheme (if any) is used by the end user's compiler, I have to code for the most general case and this can mean an extra "if" statement for each subsequent conditional expression.
tmokonen
Posts: 1299
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: for Pascal fans: Critter

Post by tmokonen »

Does the 64 bit compile require SSE4.2? It doesn't seem to work with any of the GUIs that I've tried it with.
tmokonen
Posts: 1299
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: for Pascal fans: Critter

Post by tmokonen »

This is the output I get from Arena:

Code: Select all

2011-10-07 02&#58;33&#58;18.343**----------New game---2011-10-07 02&#58;33&#58;18,343 Fri -------------
2011-10-07 02&#58;33&#58;18.521**Loading  1
2011-10-07 02&#58;33&#58;21.403*1*------------------Starting engine 1 OpenCritter 1.1.37 x64------------------
2011-10-07 02&#58;33&#58;21.406*1*Configured Engine 1 Type&#58;   UCI
2011-10-07 02&#58;33&#58;21.407*1*Engine 1 dir&#58; C&#58;\Games\Chess\Winboard\OpenCritter_1.1.37
2011-10-07 02&#58;33&#58;21.407*1*Engine 1 commandline&#58; C&#58;\Games\Chess\Winboard\OpenCritter_1.1.37\OpenCritter64.exe 
2011-10-07 02&#58;33&#58;21.513*1*Engine 1 ProcessID&#58; 2044
2011-10-07 02&#58;33&#58;21.513*1*Engine 1 Prio&#58;32 ThreadPrio&#58;0
2011-10-07 02&#58;33&#58;21.515<--1&#58;GTB PATHS
2011-10-07 02&#58;33&#58;21.535<--1&#58;  main&#58; \gtb
2011-10-07 02&#58;33&#58;21.535-->1&#58;uci
2011-10-07 02&#58;33&#58;21.535<--1&#58;GTB initialization
2011-10-07 02&#58;33&#58;21.536<--1&#58;  Compression  Scheme = 4
2011-10-07 02&#58;33&#58;21.536<--1&#58;  Compression Indexes = **FAILED**
2011-10-07 02&#58;33&#58;29.536-->1&#58;isready
The program is similarly unresponsive in the Fritz GUI.

When I run OpenCritter 1.1.37 x64 from the command line, it seems to work better. It gets past the GTB initialization phase to the hash allocation phase.

Code: Select all

OpenCritter v1.1.37 64bit
by Richard Vida, Slovakia

GTB DLL
  C&#58;\Games\Chess\Winboard\OpenCritter_1.1.37\gtb64.dll

GTB PATHS
  main&#58; \gtb

GTB initialization
  Compression  Scheme = 4
  Compression Indexes = **FAILED**

GTB Init OK

Hash table&#58;   4194304 entries of 16 bytes =   64 MB total
Eval cache&#58;     32768 entries of  8 bytes =  256 KB total
Pawn hash &#58;     65536 entries of 32 bytes =    2 MB total

2 cpu&#40;s&#41; detected

Opening book&#58; "book.cbk" - 53436 entries &#91;native&#93;

uci
id name OpenCritter v1.1.37
id author Richard Vida
option name Hash type spin default 64 min 16 max 1024
option name Ponder type check default false
option name OwnBook type check default true
option name Book File type string default book.cbk
option name UCI_Chess960 type check default false
option name MultiPV type spin default 1 min 1 max 100
option name Threads type spin default 2 min 1 max 8
option name Minimum Split Depth type spin default 6 min 4 max 10
option name GaviotaTbPath type string default \gtb
option name GaviotaTbCache type spin default 32 min 4 max 256
option name GaviotaTbCompression type combo default cp4 var uncompressed var cp1
 var cp2 var cp3 var cp4
option name Tablebase Usage type combo default Only At Root var Disable var Only
 At Root var Everywhere
option name Clear Hash type button
uciok
isready
readyok
I don't get it. Why would it act so strangely with a GUI, yet be fine from the command line?
tmokonen
Posts: 1299
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: for Pascal fans: Critter

Post by tmokonen »

Never mind, I seem to have solved the problem. I replaced the gtb64.dll file in the OpenCritter package with the one from Critter 1.2, and it worked for me after that.