Server: euchred
The server is written in C, and is based on a version I wrote in 1999, with parts reworked as I wrote the client package. The server code is hosted on GitHub, and can be cloned with this command:
git clone git@github.com:Thump/euchredClient: peuchre
The client package is written in Python, and can emulate up to 4 players. (It can also do fewer, so a manual client could be used with peuchre in order to allow a human player to play against peuchre's emulated players.) The peuchre code can be cloned with this command:
git clone git@github.com:Thump/peuchreBuilding It
The euchred package can be built with these commands from inside the cloned source directory:
makeThe binary can be found in src/euchred
The peuchre package doesn't need to be built, it's just an executable script in the root of the peuchre source directory, ./peuchre.
Running It
The server can be run from the euchred source directory with:
./src/euchredIt will open a listen socket on port 1234, and wait for clients to connect
The client can be run from the peuchre source directory with:
./peuchredPlayer Logic
By default, peuchre will instantiate 4 player objects based on the Player object in the randomplayer.py file. This implements a player with the following behaviour:
- always orders, never goes alone
- never defends alone
- when ordered up, it will drop a random card from its hand in place of the card being ordered
- when offered to lead, it will lead a random card
- when offered to follow, it will follow with a random legal card
It's clearly not a very smart algorithm, but it has the benefit of being easy to code, and can hopefully produce some interesting results.
New Player Logic
The mechanics of the client-server interaction for each player is in the EuchrePlayer object, in the euchreplayer.py file. New player logic can be created by sub-classing this object, as the Player object in the randomplayer.py file does. A new player class must meet these requirements:
- regardless of the name of the file, the object inside the file must be called Player
- the object must implement the following methods:
# returns one of ORDER, ORDERALONE, or PASSIn this way, more intelligent players can be developed using peuchre. A new player logic file called foo.py can be passed to peuchre via the --team1 or --team2 command line switch:
def decideOrderPass(self):
# returns a card from self.hand to drop when ordered up
def decideDrop(self):
# returns either DEFEND or DEFENDPASS
def decideDefend(self):
# returns a card from self.hand to lead play
def decidePlayLead(self):
# returns a card from self.hand to follow play
def decidePlayFollow(self):
./peuchre --team1 fooNote that you need to remove the .py extension from the filename when passing it to the --team1 or --team2 switches.
Stats
With no options, the peuchre client will create 4 player objects, run a game, then delete the players, re-create them, run another game, etc. Unless limited by the --numgames option, it will continue looping and running games.
The normal output from the peuchre client is a stream of log messages showing the interaction with the euchred server:
root@thistle 368> ./peuchre
2016-07-22 18:42:45 :: This is peuchre
2016-07-22 18:42:45 :: p0t1 g0h0t0 : join successful
2016-07-22 18:42:45 :: p1t2 g0h0t0 : join successful
2016-07-22 18:42:45 :: p2t1 g0h0t0 : join successful
2016-07-22 18:42:45 :: p3t2 g0h0t0 : join successful
2016-07-22 18:42:45 ::
2016-07-22 18:42:45 :: game: everyone is joined, sending start 0
2016-07-22 18:42:45 ::
2016-07-22 18:42:45 :: p2t1 g0h0t0 : cards: Jc Tc 9c Th Js
2016-07-22 18:42:45 :: p2t1 g0h0t0 : I will order Qh to p1t2
2016-07-22 18:42:45 ::
2016-07-22 18:42:45 :: p1t2 g0h0t0 : cards: Ac Qc Qd Td Ah
2016-07-22 18:42:45 :: p1t2 g0h0t0 : gonna drop: Ac
The peuchre client collects stats from various parts of the game as it runs. These stats include:
- games/s
- hands/s
- % of possible hands seen
- % of hands ending euchre
- % of hand playable at each trick
When run with the --stats option, the peuchre client will not show the stream of log messages, and will instead show a live view of these stats:
Peuchre Stats ( 0d 00:02:08 ) Team 1: randomplayer Team 2: randomplayer
Games:
Total: 48
Games/s: 0.37
Hands:
Total: 493 Euchres: 297
Hands/s: 3.83 %euchres: 60.24
Hands/g: 10.27
Call Hands:
Total: 493 Max Reps: 2
Unique: 488 Avg Reps: 1.01
%cover: 2.18
License
Both euchred and peuchre are licensed under GPL version 2.