Editing tscp

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Editing tscp

Post by sje »

I haven't heard from Tom, so I'm going to mothball my tscp work. That's okay because I've got plenty of other tasks to handle.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

TSCP edits now available for distribution

Post by sje »

TSCP edits now available for distribution

Tom Kerrigan has graciously reviewed my edits to tscp and has made them available on his web site: http://www.tckerrigan.com/Chess/TSCP/Community/

The zip file: http://www.tckerrigan.com/Chess/TSCP/Co ... 181_se.zip
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: TSCP edits now available for distribution

Post by MikeB »

sje wrote:TSCP edits now available for distribution

Tom Kerrigan has graciously reviewed my edits to tscp and has made them available on his web site: http://www.tckerrigan.com/Chess/TSCP/Community/

The zip file: http://www.tckerrigan.com/Chess/TSCP/Co ... 181_se.zip
fyi - using a simple makefile with simple pgo, but change the bench to 7 ply.

Code: Select all

Tom Kerrigan's Simple Chess Program (TSCP)
version 1.81, 2/5/03
Copyright 1997 Tom Kerrigan

"help" displays a list of commands.

tscp> bench

8  . r b . . r k .
7  p . . . . p p p
6  . p . q p . n .
5  . . . n . . N .
4  . . p P . . . .
3  . . P . . . P .
2  P P Q . . P B P
1  R . B . R . K .

   a b c d e f g h

ply      nodes  score  pv
  1        130     20  c1e3
  2       3441      5  g5e4 d6c7
  3       8911     30  g5e4 d6c7 c1e3
  4     141367     10  g5e4 d6c7 c1e3 c8d7
  5     550778     26  c2a4 d6c7 g2d5 e6d5 c1e3
  6    5919598     16  g2d5 d6d5 c1f4 b8a8 f4e5 c8d7
  7   28757562     27  g2e4 c8d7 e4g6 h7g6 g5e4 d6c7 c1e3
Time: 26585 ms
ply      nodes  score  pv
  1        130     20  c1e3
  2       3441      5  g5e4 d6c7
  3       8911     30  g5e4 d6c7 c1e3
  4     141367     10  g5e4 d6c7 c1e3 c8d7
  5     550778     26  c2a4 d6c7 g2d5 e6d5 c1e3
  6    5919598     16  g2d5 d6d5 c1f4 b8a8 f4e5 c8d7
  7   28757562     27  g2e4 c8d7 e4g6 h7g6 g5e4 d6c7 c1e3
Time: 26666 ms
ply      nodes  score  pv
  1        130     20  c1e3
  2       3441      5  g5e4 d6c7
  3       8911     30  g5e4 d6c7 c1e3
  4     141367     10  g5e4 d6c7 c1e3 c8d7
  5     550778     26  c2a4 d6c7 g2d5 e6d5 c1e3
  6    5919598     16  g2d5 d6d5 c1f4 b8a8 f4e5 c8d7
  7   28757562     27  g2e4 c8d7 e4g6 h7g6 g5e4 d6c7 c1e3
Time: 26571 ms

Nodes: 28757562
Best time: 26571 ms
Nodes per second: 1082291 (Score: 4.451)
tscp> perft 6
perft(6): 119060324   3.170 MHz
tscp> 
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Speed enhancements

Post by sje »

There are two simple speed enhancements which can be made by adding only a small amount of code:

1) Incremental updating of king positions. At present, the code must scan the entire board each time it test for a king-in-check condition.

2) Incremental updating of the signature hash. At present, the code must scan the entire board each time it makes a move.

Many other changes could be made to improve the speed without changing move selection or node counts. But which changes are simple enough for the program to remain simple overall?
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

A third enhancement

Post by sje »

A third simple enhancement would be to add color indexed vectors to enable table driven directional delta calculation. Currently, in every calculation involving pawn motion, there are separate code branches for white and black. These could be combined to cut the size of the affected code in half and to slightly decrease code cache pressure. Castling related code could be similarly factored by color.

None of these changes would affect fixed depth move selection or node counts.

----

On a side note, the 200 full move limit should be increased, as I've seen the program lose several games in drawn positions when the 201st move was to be searched.
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: A third enhancement

Post by jdart »

That would be a nice cleanup, but I think eliminating the board scans is a bigger win. Most engines do incremental hash update so that is a good enhancement.

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

Not so simple enhancements

Post by sje »

Not so simple enhancements

The first of these would be to get rid of the setjmp()/longjmp() calls by changing the search to gracefully unwind when the time limit strikes. This would not change move selection or node counts, but it would provide a better tutorial example of structured programming.

The second of these would be to install FEN I/O capability, as currently there is no easy way to set up an arbitrary position. This could be extended to allow the setboard directive when running under xboard.

The third not so simple change would be to support SAN I/O. This takes a little more work, but I think it's worth the effort as coordinate notation is something best left to the 1970s.

A fourth idea would be to support PGN I/O. The output side of this is fairly easy once SAN is supported, but the parsing side is more complex. Perhaps allowing only the most simply formatted PGN games to be read would be sufficient.
User avatar
Jim Ablett
Posts: 1384
Joined: Fri Jul 14, 2006 7:56 am
Location: London, England
Full name: Jim Ablett

Re: Not so simple enhancements

Post by Jim Ablett »

Fimbulwiinter Chess engine which is basically a modified TSCP, uses a LoadFEN command and has src available >

http://shedletsky.com/chess/#Downloads

Jim.
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: TSCP edits now available for distribution

Post by Dann Corbit »

Ten lines of code make it run twice as fast:
https://www.dropbox.com/s/hrjvuldv75hnymw/tscp.7z?dl=0
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: TSCP edits now available for distribution

Post by Dann Corbit »

Output:

Code: Select all

tscp> xboard

new
post
st 99
go
1 48 0 21 d2d4
2 0 0 84 d2d4 d7d5
3 35 0 800 d2d4 d7d5 b1c3
4 5 0 4219 e2e4 d7d5 f1b5 c8d7 b5d3
5 35 2 22461 e2e4 e7e5 d2d4 d7d5 g1f3
6 13 13 138420 e2e4 e7e5 d2d4 e5d4 d1d4 g8f6
7 30 87 1174560 e2e4 d7d5 e4d5 d8d5 d2d4 d5e4 g1e2 e7e5
8 18 604 7348443 e2e4 e7e5 g1f3 g8f6 b1c3 b8c6 d2d4 d7d6
9 33 3305 43457317 e2e4 b8c6 f1b5 d7d5 d2d3 g8f6 b1c3 e7e6 b5c6 b7c6