error in Dice of Doom version 1 (chapter 15)?

87 views
Skip to first unread message

ccc31807

unread,
Sep 15, 2011, 12:41:11 PM9/15/11
to Land of Lisp
I have implemented (retyped from scratch) the code in chapter 15 up to
page 321, Creating an Intelligent Computer Opponent. When I attempt to
play the game, if the second player does not have any legal moves, I
get this error:

CAR: 2 is not a list

I've spend about a day trying various means to debug this, but my Lisp
chops aren't good enough (yet). Any help would be appreciated.Here is
typical console output with my debugging effots:

[64]> (play-vs-human (game-tree (gen-board) 0 0 t))
Current player: A
A-3 A-1
A-2 B-2
Chose your move:
TREE------------
(0 #((0 3) (0 1) (0 2) (1 2))
(((0 3) (0 #((0 1) (0 1) (0 2) (0 2)) ((NIL (1 #((0 2) (0 1) (0 2) (0
2)) NIL)))))))
MOVES----------
(((0 3) (0 #((0 1) (0 1) (0 2) (0 2)) ((NIL (1 #((0 2) (0 1) (0 2) (0
2)) NIL))))))
-----------------
1. 0 -> 3
1
Current player: A
A-1 A-1
A-2 A-2
Chose your move:
TREE------------
(0 #((0 1) (0 1) (0 2) (0 2)) ((NIL (1 #((0 2) (0 1) (0 2) (0 2))
NIL))))
MOVES----------
((NIL (1 #((0 2) (0 1) (0 2) (0 2)) NIL)))
-----------------
1. end turn
1
Current player: B
A-2 A-1
A-2 A-2

*** - CAR: 2 is not a list
The following restarts are available:
ABORT :R1 Abort main loop
Break 1 [65]> :a

Conrad Barski

unread,
Sep 15, 2011, 2:03:25 PM9/15/11
to land-o...@googlegroups.com
I have not heard of anyone encountering this error- It may be due to a
typo in your code, but I can't say exactly where the error is. If the
next player doesn't have a valid move, the game should end and the
program will calculate which player owns more spaces on the board- I
suspect the error is happening when the program is trying to determine
the winner (which in this case should be player A).

Sorry, I can't figure out more looking at this right now.

-Conrad

--
Conrad Barski, M.D.
Medical Software Developer
Washington DC

ccc31807

unread,
Sep 16, 2011, 10:47:29 AM9/16/11
to Land of Lisp
Conrad,

Thanks for your prompt response. I found my error.

The benefit to retyping all the code is that it helps people, like me,
who are kinetic learners. The cost is that you sometimes make
typographical errors that might be hard to find.

Of course, the advantage to debugging code that you make silly typos
in is that you get lots of practice debugging. It's painful, but I
suppose it's more painful NOT to learn how to do it early.

I think 'Land of Lisp' is a stunning achievement, and I mean this in a
positive way. I also think it's a deeply flawed book, and I also mean
this in a positive way. As an example of a stunning but deeply flawed
accomplishment, consider Beethoven's last three piano sonatas, which
are virtually unplayable both from a technical standpoint and a sonic
standpoint, yet they embody music of the highest order.

You can't do everything in one book, and you certainly went beyond the
call of duty in this one. One thing you did not do is show all your
slow and halting steps from the inception to the final product, but
you tended to present them as fully formed. Please don't take this as
a negative criticism, but simply as a comment from one who is now on
his third reading of your book, and as one who as to date purchased
three of them (I literally wore the first two out so that they became
unusable.)

If you have another project in mind, I might suggest that you consider
a book focused on (1) how you develop a non-trivial application from a
functional standpoint, and (3) Lisp style and design on the package
and application level.

Thanks again, CC.

Conrad

unread,
Sep 16, 2011, 2:19:03 PM9/16/11
to Land of Lisp
I think you describe LOL very well- It's basically an attempt at
sharing my understanding of Lisp & FP in a stream-of-consciousness
style (because I think things are easier to learn if they have a more
narrative, instead of logical, structure)

Of course, this type of "chaotic" approach has weaknesses, as you
point out astutely. I think there are several good books that could
still be written in this area- I especially am amazed that there isn't
yet a "fun" book on FP, in particular (since many people are trying to
learn FP right now)

Unfortunately writing a book is very difficult, as I've found out.
It'll be a while before I might attempt another book (if ever)

robert taylor

unread,
Sep 17, 2011, 8:19:01 PM9/17/11
to land-o...@googlegroups.com
ccc31807 ...

If you want something that drills down a bit deeper and yet is still accessible:
Common Lisp - An interactive approach.
http://www.cse.buffalo.edu/~shapiro/Commonlisp/index.html

If you want something that handholds you a bit:
Successful Lisp
http://psg.com/~dlamkins/sl/

If you want something a bit more high level and geared towards
experienced programmers:
Practical Common Lisp
http://www.gigamonkeys.com/book/

If you want the common lisp spec for the gory details of the language:
http://www.lispworks.com/documentation/common-lisp.html

What none of the above do is make programming fun. LOL is an amazing
piece of work that drills down JUST ENOUGH to give you the flavour of
what is going on. It wets your appetite and provides some key
insights on how to accomplish JUST ENOUGH things to get you going in
the right direction. It also provides some some very IMPORTANT
perspectives on the LISP language that would only be visible to an
experienced programmer. It sort of binds the other 3 books in a, HOLY
CRAP LOOK WHAT WE CAN DO, kind of way and makes us think about all the
possibilities.

And above all, Conrads illustrations have added, what I consider, the
beginning of a valuable visual language -- something I would like to
add to my self eventually.

ccc31807, I simply think your expectations are flawed. LOL does what
it does perfectly and succinctly. It is rather easy to fill any of
the bits and pieces that you point out with a few minutes of googling.
Combine the 4 books + the common lisp spec and you have a VERY ROBUST
entry point to the language that should be able to get anyone making
fun things with a little practice.

The rest is up to us I guess.

ccc31807

unread,
Sep 19, 2011, 1:14:45 PM9/19/11
to Land of Lisp
On Sep 17, 8:19 pm, robert taylor <linuxhooli...@gmail.com> wrote:

> ccc31807, I simply think your expectations are flawed. LOL does what
> it does perfectly and succinctly. It is rather easy to fill any of
> the bits and pieces that you point out with a few minutes of googling.
> Combine the 4 books + the common lisp spec and you have a VERY ROBUST
> entry point to the language that should be able to get anyone making
> fun things with a little practice.

You missed the point I was trying to make. Any ambitious attempt is
bound to be deeply flawed, due to our human imperfection. As an
example from mythology, consider Icarus, who had the ambition to soar
to the skies. As an example from religion, consider Adam and Eve, who
had the ambition to be like God, knowing good and evil. I'm not saying
that we should not attempt because of fear of failure, I am saying
that we SHOULD attempt, in spite of our fear of failure.

> What none of the above do is make programming fun. LOL is an amazing
> piece of work that drills down JUST ENOUGH to give you the flavour of
> what is going on. It wets your appetite and provides some key
> insights on how to accomplish JUST ENOUGH things to get you going in
> the right direction. It also provides some some very IMPORTANT
> perspectives on the LISP language that would only be visible to an
> experienced programmer. It sort of binds the other 3 books in a, HOLY
> CRAP LOOK WHAT WE CAN DO, kind of way and makes us think about all the
> possibilities.

After years of trying, I was finally able to borrow a copy of Molly
Miller's book 'Lisp Style and Design.' I can't say that it did me much
good, but it was an eye-opener, in the sense that it demonstrates that
you actually can use Lisp to write a big application like a word
processor. I have spent a considerable amount of time attempting to
reverse-design Barski's examples, and have made little headway. Why is
that important?

With a language like Java, you can have analysts, designers, code
monkeys, and testers, and large shops have all of these. With a
language like Lisp, one person has to be the analyst, designer, code
monkey, and tester. I agree with you about LOL -- the word I used was
'stunning.' However a stunning demonstration may motivate you (and I
agree that LOL is also very motivational) it's not sufficient alone to
instruct about combining the various skills necessary to actually
build something.

In fairness to Barski, I'll note that a single individual trying to
bootstrap Lisp (like me) is in an entirely different position from
someone who is in a community that can help develop all the parts.
This was the source of my original post about a possible bug, when I
had simply mistyped one character.

CC.

Edward Kenworthy

unread,
Sep 19, 2011, 1:57:05 PM9/19/11
to land-o...@googlegroups.com, Land of Lisp
The only philosophy that occured to me from reading this was: when you are in a hole, stop digging.

;)


Sequiturian

unread,
Nov 6, 2012, 12:40:20 PM11/6/12
to land-o...@googlegroups.com
On Monday, September 19, 2011 1:14:45 PM UTC-4, ccc31807 wrote:
You missed the point I was trying to make. Any ambitious attempt is
bound to be deeply flawed, due to our human imperfection.

CC.

CC, perhaps what you have discovered is that Lisp is not the language for you. Lisp takes a highly organized and structural mind and acute attention to detail to do well. Not everyone has that or desires to. Lisp is not for everyone, and it doesn't try to be. Just sayin'

LL
Reply all
Reply to author
Forward
0 new messages