The "PLT Games" thing that comes with Racket contains a spider solitaire game. I felt like implementing it myself, partially with intent to try designing programs to play the game and see how well various algorithms work. Well, I did implement it, and, after showing it to a friend and working on it more, I have a fairly good textual interface for a human to play. I even learned about color escape codes and used them. I think I actually prefer my game over the GUI game. Here's the text display. arc> (mv 7 4)
0 1 2 3 4 5 6 7 8 9
-- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- A♣ -- --
-- 4♥ -- -- K♣ Q♥ 2♥ 6♣ 10♣
9♣ 3♣ 2♥ Q♣ 9♣
0 1 2 3 4 5 6 7 8 9
nil
[Let's hope the weird Unicode characters get correctly monospaced here. They look fine in my terminal window (MacOSX Terminal), but in pastebin, the non-ASCII characters are extra fat.]Here is me playing part of a game: http://pastebin.com/NnAHqNMW And, now, how shall I distribute this to you guys? Unfortunately, I make use of a) an ssyntax hack[1] and b) various library functions of my own, so I can't just give you my spider.arc source. I could either ssexpand everything and factor out the library utilities into a nice neat little file, or just throw my whole arc3.1 folder at you (cleaned up slightly). The latter is somewhat easier, so I did that. Here it is. http://dl.dropbox.com/u/3678008/public-arc3.1.zip The file spider.arc is everything relevant to the spider game. The big fat file "a" is what you get when I start with a library file and add things and use it as scratch paper for many months; all utilities used in spider.arc can probably be found in "a". (Feel free, by the way, to use any of the code I've written.) To play spider solitaire: 1. Extract public-arc3.1 and go "racket -if as.scm" as usual. (Incidentally, I've made as.scm smart enough to parameterize the current-directory while loading Arc libraries, so you probably don't need to cd to that folder.) 2. At the Arc prompt, (spider-help) will explain the relevant functions. Probably you'll want to (= colored t) and (new-game 2), and maybe use (game-repl) if you get sick of typing parens around (mv a b). If it prints a bunch of characters like \e[1;31m\e[m, then your terminal isn't interpreting the color escape codes and you should (= colored nil). If it prints some crap like ΓÖú, then your terminal isn't interpreting the Unicode characters and you should (= card-sym (obj club "@" spade "#" heart "%" diamond "&")). [1] http://arclanguage.org/item?id=13172 |