XHEARTS

Section: Games and Demos (6)
Index Return to Main Contents
 

NAME

xhearts - The card game of "hearts"  

SYNTAX

xhearts [-players player_file] [-goal points] [-jack] [-pass style]

         [-drop] [-wlm wlm_file] [-seed seed] [-sleep seconds] [-log file]  

DESCRIPTION

This program implements the card game "hearts". It is a game for four players, with any combination of human and computer opponents.

-player player_file

This file informs the program of who the players are. It is an ascii file with the following form:

name1
display1
name2
display2
name3
display3
name4
display4

The name serves only to label the positions at the table. If the name begins with a colon, the computer plays that hand and the display is ignored (but still required). Names must not have any white space. A human name must be first. The application's resources will be read from the .Xdefaults file of the first player.

For example, to play a game against me and two computer opponents: YourName
YourDisplay
:computer
ignored
Gene_Dykes
128.84.247.86:3
:computer
ignored

-goal points

The game ends whenever any player reaches this level. The winner is the person with the lowest number of points. The default is 100 points.

-jack

With this flag specified, the jack of diamonds is worth -10 points. The computer as an opponent has no strategy for dealing with it. The default is that the jack of diamonds is not special.

-pass style

There are four possibilities for determining where to pass three cards:

"leftright"
"leftrightacross"
"leftrightacrosskeep"
"leftrightkeep"

The default is Left_Right_Across.

As with other Xcu resources, spaces, underscores, and Capitalization may be arbitrarily part of the above strings.

-drop

When this flag is specified, points may be sloughed to the first trick. The default is that hearts and the queen of spades may not be played on the first trick.

-wlm wlm_file

The compiled layout description file may be specified with this flag. The default is to look for a file called "hearts.wc".

-seed integer

This option seeds the random number generator, thus allowing the exact game to be played again.

-sleep seconds

This option specifies how many seconds the computer should wait before allowing a player to play to the next trick. The default is two.

-log file

This option tells the computer where to save a log file of its strategy decisions. This allows the author to figure out why the computer occasionally plays with a bit of brain damage.  

RESOURCES

 
You may want to specify something other than your system's default font in your .Xdefaults file. Something along the lines of an 18 point font works well.

The program may need to be told where to find the bitmaps by setting the "bitmapFilePath" resource properly. You may want to install the four files (club.h, diamond.h, heart.h, spade.h) where they will be easy to find.

The following are resources introduced by the program.
xhearts resources
NameTypeDefaultDescription

XtNgoalInt100Game Limit
XtNpassingStylePassingStyleLeftRightAcross3-card passing rotation
XtNdropOnFirstBooleanFalsePoints on first trick allowed
XtNjackCountsBooleanFalseJack counts as minus ten points
XtNplayerFileString"players"The players file
XtNlogFileString"/dev/null"The strategy log file
XtNwlmString"hearts"The compiled layout file
XtNseedStringNULLThe random number generator seed
XtNsleepInt2The required wait between tricks

These four resources allow configuring the game to popular variations:

goal           When any player reaches this score the game is over

jackCounts     Whether the jack of diamonds counts minus 10

dropOnFirst    Whether or not points are allowed to be dropped on first trick

passingStyle   The discard passing direction cycle

These four resources control some of the game mechanics:

playerFile     The name and $DISPLAY for each player

wlm            The name of the compiled wlm file

seed           The seed for initializing the random number generator

sleep          Number of seconds that must be allowed to elapse before

               leading to next trick

xhearts*font :

This will be the font used for the cards, and maybe some others. The fonts of other things are hardcoded into the .wl files, where they can be changed and recompiled if desired. I can't figure out how to change the fonts of a select kind of widgets without specifying a path for each and every group of them... (Suppose you have label widgets scattered throughout the interface, and you want 10 of them to be green -- there doesn't seem to be any way to set the resource for them without specifying a resource for each individual widget.)

 

HOW TO PLAY

How to play this version of hearts really needs no explanation -- just point and click as appropriate. You can change your mind on discards, but "a card laid is a card played!"

I should have a quick summary of hearts rules here. Sorry!  

BUGS

I know of several dumb plays the computer occasionally makes, and I should have fixes for them soon, but in general the computer plays well, and so far as I know, always legally. It never tries to shoot the moon, but it does a fair job of moon prevention.  

FUTURE WORK

It would be nice to expand this thing so we could hold hearts tournaments! If anybody would like to take a stab at writing a strategy to compete against mine, I could also make that easier to do.  

AUTHOR

Gene W. Dykes, gwd@graphics.cornell.edu


 

Index

NAME
SYNTAX
DESCRIPTION
RESOURCES
HOW TO PLAY
BUGS
FUTURE WORK
AUTHOR

This document was created by man2html, using the manual pages.
Time: 23:33:06 GMT, February 06, 2023