February 9, 2007
I decided to create a more graphical view of my continuo game. I find it easier to look at compared to the ASCII version in my previous entry. The color chains are much easier to follow.
I used lispbuilder-sdl to generate the graphics. Each 4×4 card has a thick black border and is labelled with a number representing the play order.
Score: 908

Score: 919

Score: 799

Score: 830

8 Comments |
Lisp, Programming |
Permalink
Posted by anthonyf
February 7, 2007
This year’s International Lisp Conference is having a programming contest for those attending. Unfortunately for me, I live in the Seattle, WA area and the conference is in Cambridge, England! I love contests like this anyway so I decided to take a crack at it.
The contest is to play a solitaire version of the card game Continuo. The contest page gives a good description of how the game is played so I wont get into that here. The game looks like a lot of fun so I ordered a copy of the real game from a local game shop.
My Lisp solution is very naive but appears to play a decent game. It simply plays the next card in the highest scoring position. I think higher overall scores could be achieved if you take into account cards that have been played already as well as the ones not yet played. I cant really wrap my brain around that one at the moment so my naive solution works just fine for now
I wont post my code until the contest is over, but I will say that it is about 200 lines of highly unoptimized code, including comments and some test code. Using SBCL on Linux it runs in about 16 seconds and conses like nobody’s business. Here’s an example run with test data that scores 852.
CONTINUO> (time (play-continuo '(:RBRB :GYGB :GYRY :BYBY :RBYR :RGRB :RGBG
:BYGY :RGRY :RBRY :RYRY :RYGY :YRBY :BYRY
:BRBY :GBYB :RBGB :GBGB :RYBY :RYRG :GYBY
:RGYR :GBRB :RBYB :YGBY :GBGY :GRBG :BRGB
:YRGY :BGBY :GYGY :RYRB :GRYG :GRGY :RBRG
:RGYG :BGYB :BRYB :GBYG :RGRG :GRGB :RGBR)))
score=852
- - - - - - - - - - - - - - - - - - - -
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-22 G R G B
-21 R R G G G Y B G
-20 G G R R Y Y B B
-19 B G R G B B Y Y
-18 Y G R G G B Y G R G Y G
-17 G G R R Y G Y G G G Y Y
-16 R R G G G G Y Y Y Y G G R G R G
-15 G R G Y Y Y G G G Y G R G G R R
-14 B Y B R G Y G Y R Y G R R R G G
-13 Y Y B B G Y B Y Y Y G G G R G R
-12 Y G B G B B Y Y Y Y B B G G Y Y Y R G Y B R Y B
-11 G G B B R B Y B B B Y Y R G Y R R R G G R R Y Y
-10 B Y G B B B G G Y B Y R Y B Y G Y G Y R G G R R Y Y R R
-9 Y Y G G G B G Y B B Y Y Y R Y B G G Y Y Y G R Y B Y R B
-8 G G Y Y Y B G Y Y Y B B R R Y Y Y Y G G R Y R Y B R B G R B R G
-7 B G Y B B B G G R Y B Y Y Y R R R Y G Y Y Y R R R R B B B B R R
-6 G R Y G G G B B B Y B G B Y R Y B Y G Y R R Y Y B B R R R R B B
-5 R R Y Y Y G B Y Y Y B B B Y B Y Y Y G G Y R Y R G B R B G R B R R G B R
-4 Y Y R R B G B Y B B Y Y Y Y B B G G Y Y Y R B R Y B R Y G R B G G G B B
-3 G Y R G G G B B G B Y B B B Y Y Y G Y B R R B B B B R R R R B B B B G G
-2 B B G G G R Y R Y B Y B B G Y G B B R R R R B B B B R R R B G R
-1 Y B G B R R Y Y Y R Y G G G Y Y R B R Y Y R B Y G B R G
0 Y Y R R R R Y Y Y Y G G R B R B B R B Y B R G B
1 R Y R G Y Y R R G Y G B B B R R R R B B R R G G
2 R Y R B G Y R Y R Y B R R R B B B B R R G G R R
3 Y Y R R R G R Y Y Y B B B R B R Y B R B B G R B
4 R R Y Y G G R R B B Y Y B R G R R B G B
5 B R Y R R R G G R B Y R R R G G B B G G
6 Y R G R G B G R G G R R G G B B
7 G B G B B B G G R G R B B G B R
8 B B G G G G B B
9 G G B B R G B G
10 B G B G
Evaluation took:
16.28 seconds of real time
15.820989 seconds of user run time
0.220014 seconds of system run time
[Run times include 1.612 seconds GC run time.]
0 page faults and
1,848,458,504 bytes consed.
NIL
EDIT: I used slime-profile-package to profile my code and was able to make a very small change that produces the same result as above in only 1.35 seconds. I really love slime
Evaluation took:
1.35 seconds of real time
1.352084 seconds of user run time
0.0 seconds of system run time
[Run times include 0.048 seconds GC run time.]
0 page faults and
62,727,048 bytes consed.
Leave a Comment » |
Lisp, Programming |
Permalink
Posted by anthonyf