Author: Christophe Theron
Date: 10:52:47 02/23/04
Go up one level in this thread
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))) > >Comments: > >1. Does anyone really think that Lisp is hard to read? From what I see, LISP has a basic "(operator arg arg arg...)" structure (correct me if I'm wrong, the last time I looked at LISP was 15 or 20 years ago). Just a general comment: I find it slightly harder to read than C for example, but naturally I'm very used to reading C so I would probably adapt to LISP, eventually. But there is something that I find very inelegant: if one is ready to give up on the more standard "operator(arg,arg...)" or "arg1 operator arg2" (like in "a+b"), then it is possible to do it without the parenthesis! Frankly, all thoses parenthesis in your example are absolutely impossible to manage for a normal human. So you had to make the structure obvious by using identation. Then these parenthesis appear to be redundant with identation. The identation is there for the human, the parenthesis are there for the computer. Ugly. Nothing new here. That's why LISP has been dubbed "Lots of Insipid and Stupid Parenthesis" a lot time ago. I think it is deserved. Now how can you do it without the parenthesis? By writing it in Forth! I find Forth to be one of the most elegant language that has ever been designed. It is fast, efficient, and not harder to read than LISP (and because you do not have to insert the parenthesis I would dare to say that it is easier to write and more readable than LISP). You will not use basic "(operator arg arg)" structures, you will use "arg arg operator" instead. Same thing, with the order reversed, and without any parenthesis! So to answer your question: yes I find LISP hard to read, and if I was ready to use a different language I would go to Forth instead of LISP. >2. While the above could have been done in the C++ code of the underlying >tookit, it wouldn't have been that much faster. > >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. While this is generally considered as a good thing, I think that type checking has been mostly been overevaluated. Type checking won't write correct programs for you. Writing correct programs comes from an attitude of being extremely careful and reading your own code several times before trying it. >4. Further work on KBNK will help with the design and implementation of the >pattern recognition and planning facilities. Is it supposed to be an argument in favor of LISP? This bit of code could have been written in any language with the same efficiency... If it is supposed to be an argument in favor of pattern recognition, then Chess Tiger must be based on pattern recognition, because I must have an almost identical bit of code somewhere! :) Christophe
This page took 0.01 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.