Author: Steven Edwards
Date: 12:10:05 02/23/04
Go up one level in this thread
On February 23, 2004 at 13:02:24, Robert Hyatt wrote: >On February 23, 2004 at 12:30:47, Steven Edwards wrote: >>Heres some example code from Symbolic, the KBNK endgame class recognizer: >> >>(defun IsKBNK? (MyPos) >> "Return White if KBNK, Black if KBNK reversed, nil otherwise" >> (cond >> ((and >> (= (CountByColorPos White MyPos) 3) >> (= (CountByColorPos Black MyPos) 1) >> (= (CountByManPos WhiteBishop MyPos) 1) >> (= (CountByManPos WhiteKnight MyPos) 1)) White) >> ((and >> (= (CountByColorPos Black MyPos) 3) >> (= (CountByColorPos White MyPos) 1) >> (= (CountByManPos BlackBishop MyPos) 1) >> (= (CountByManPos BlackKnight MyPos) 1)) Black) >> (t nil))) >>3. The above code, like all of ChessLisp, is typesafe. This means that a >>function that expects a color checks for a color value, one that expects a >>position symbol checks for a position symbol, etc. > >That's ok for a "beginner" IMHO. But "checks for a xxx" is a performance issue >that I don't want to deal with. IE I generally know what I am doing, and while >I do make mistakes, I don't mind finding them myself rather than having the >system itself help. This is only true when performance is the main issue, of >course, but for chess, performance is a major part of the equation. Two items: 1. Scalar typesafety in ChessLisp is very fast in part because of building in the idea of chess scalar values (pieces, colors, squares, etc.) into the basic allocated cell representation. It requires only a couple of instructions per runtime check. 2. The error checking can be disabled if needed. There is a ChessLisp intrinsic function "error-checking" that accesses the interpreter's "do error checks" flag.
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.