A scopa game in Common Lisp
2011-02-25
This is a scopa game for 2 players, human vs pc, written in Common Lisp mostly for fun, and to put in practice what I learned about CL so far.
This is my first “real program” (if it can be called so) in Common Lisp, so just don’t expect it to be well-designed. Comments are very welcome.. and don’t strive to be polite about it. :)
Use (play) to play.
Example session at the REPL of GNU CLISP:
I lost against the PC :/
[1]> (load "scopa.clisp")
;; Loading file scopa.clisp ...
;; Loaded file scopa.clisp
T
[2]> (play)
On the table: [7 OF COPPE], [6 OF DENARI], [2 OF DENARI], [8 OF COPPE]
Your hand: [5 OF BASTONI], [9 OF BASTONI], [2 OF BASTONI]
Stock: 30 cards.
It's PC turn.
Player PC plays [7 OF SPADE] taking [7 OF COPPE]
On the table: [6 OF DENARI], [2 OF DENARI], [8 OF COPPE]
Your hand: [5 OF BASTONI], [9 OF BASTONI], [2 OF BASTONI]
Stock: 30 cards.
It's HUMAN turn.
1) Play [2 OF BASTONI] taking [2 OF DENARI]
2) Play [5 OF BASTONI]
3) Play [9 OF BASTONI]
What do you want to do?
1
Player HUMAN plays [2 OF BASTONI] taking [2 OF DENARI]
On the table: [6 OF DENARI], [8 OF COPPE]
Your hand: [5 OF BASTONI], [9 OF BASTONI]
Stock: 30 cards.
It's PC turn.
Player PC plays [10 OF COPPE]
On the table: [6 OF DENARI], [8 OF COPPE], [10 OF COPPE]
Your hand: [5 OF BASTONI], [9 OF BASTONI]
Stock: 30 cards.
It's HUMAN turn.
1) Play [5 OF BASTONI]
2) Play [9 OF BASTONI]
What do you want to do?
2
Player HUMAN plays [9 OF BASTONI]
...
...
It's PC turn.
Player PC plays [4 OF DENARI]
On the table: [8 OF SPADE], [4 OF DENARI]
Your hand: [2 OF COPPE]
Stock: 0 cards.
It's HUMAN turn.
1) Play [2 OF COPPE]
What do you want to do?
1
Player HUMAN plays [2 OF COPPE]
Player HUMAN collect all the remaining cards on the table.
SCORE ASSIGNMENTS
Greatest number of cards: PC
Greatest number of denari cards: PC
Settebello: PC
Prime: PC
HUMAN
0 + 0 + 0 scopas = 0
-------
PC
0 + 4 + 0 scopas = 4
On the table: [5 OF SPADE], [6 OF DENARI], [3 OF BASTONI], [3 OF SPADE]
Your hand: [5 OF BASTONI], [7 OF SPADE], [10 OF SPADE]
Stock: 30 cards.
It's HUMAN turn.
1) Play [5 OF BASTONI] taking [5 OF SPADE]
2) Play [10 OF SPADE]
3) Play [7 OF SPADE]
What do you want to do?
1
Player HUMAN plays [5 OF BASTONI] taking [5 OF SPADE]
...
...
It's PC turn.
Player PC plays [5 OF DENARI]
Player PC collect all the remaining cards on the table.
SCORE ASSIGNMENTS
Greatest number of cards: PC
Greatest number of denari cards: PC
Settebello: HUMAN
Prime: PC
HUMAN
0 + 1 + 0 scopas = 1
-------
PC
4 + 3 + 2 scopas = 9
On the table: [4 OF DENARI], [5 OF SPADE], [9 OF DENARI], [10 OF SPADE]
Your hand: [7 OF BASTONI], [8 OF SPADE], [1 OF DENARI]
Stock: 30 cards.
It's HUMAN turn.
1) Play [8 OF SPADE]
2) Play [1 OF DENARI]
3) Play [7 OF BASTONI]
What do you want to do?
1
Player HUMAN plays [8 OF SPADE]
...
...
It's PC turn.
Player PC plays [6 OF SPADE] taking [2 OF SPADE], [4 OF BASTONI]
Player PC collect all the remaining cards on the table.
SCORE ASSIGNMENTS
Greatest number of cards: PC
Greatest number of denari cards: PC
Settebello: PC
Prime: HUMAN
HUMAN
1 + 1 + 1 scopa = 3
-------
PC
9 + 3 + 2 scopas = 14
The game is over!
The winner is PC with a score of 14!
NIL
[3]>