[comp.sources.games] v05i031: yahtzee - curses based game of yahtzee, Part02/02

games@tekred.TEK.COM (07/27/88)

Submitted by: lsuc!hcr!hcrvax!stacey (Stacey Campbell)
Comp.sources.games: Volume 5, Issue 31
Archive-name: yahtzee/Part02


#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 2)."
# Contents:  boxup.c comp_select.c defs.h dice.h dis_dice.c eval.c
#   find.c finish.c get_m.c help.c makefile misc.c opthelp.c rools.c
#   rools.h shell.c side.h update_score.c values.c yahtzee.6
# Wrapped by billr@saab on Tue Jul 26 11:42:43 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'boxup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'boxup.c'\"
else
echo shar: Extracting \"'boxup.c'\" \(956 characters\)
sed "s/^X//" >'boxup.c' <<'END_OF_FILE'
X/* This thing turns on standout mode, draws a box, then turns
X * standout mode off. Sys5.2 curses box() doesn't draw boxes in
X * standout mode, and other curses box() don't allow for corner
X * characters.
X */
X
X#include <curses.h>
X
X#define SideWall '|'
X#define TopWall '-'
X#define TopLeftCorner '.'
X#define TopRightCorner '.'
X#define BottomLeftCorner '`'
X#define BottomRightCorner '\''
X
Xextern int BadStandout;
X
XBoxUp(AWindow, Y, X)
X
XWINDOW *AWindow;
Xint Y, X;
X
X	{
X	int i;
X
X	--Y;
X	--X;
X	if (! BadStandout)
X		wstandout(AWindow);
X	mvwaddch(AWindow, 0, 0, TopLeftCorner);
X	mvwaddch(AWindow, 0, X, TopRightCorner);
X	mvwaddch(AWindow, Y, 0, BottomLeftCorner);
X	mvwaddch(AWindow, Y, X, BottomRightCorner);
X	for (i = 1; i < Y; ++i)
X		{
X		mvwaddch(AWindow, i, 0, SideWall);
X		mvwaddch(AWindow, i, X, SideWall);
X		}
X	for (i = 1; i < X; ++i)
X		{
X		mvwaddch(AWindow, 0, i, TopWall);
X		mvwaddch(AWindow, Y, i, TopWall);
X		}
X	if (! BadStandout)
X		wstandend(AWindow);
X	}
END_OF_FILE
if test 956 -ne `wc -c <'boxup.c'`; then
    echo shar: \"'boxup.c'\" unpacked with wrong size!
fi
# end of 'boxup.c'
fi
if test -f 'comp_select.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'comp_select.c'\"
else
echo shar: Extracting \"'comp_select.c'\" \(937 characters\)
sed "s/^X//" >'comp_select.c' <<'END_OF_FILE'
X/* comp_select.c
X *	determines in which category the heuristics will place a
X *	set of dice.
X */
X#include <stdio.h>
X#include "defs.h"
X
X#define three_of_a_kind 7
X#define four_of_a_kind 8
X
Xextern float cost_list[13][51];
Xextern int machine[max_players];
Xextern int scoreboard[max_players][max_marks];
X
Xint computer_select(player, dice, available, avail_count)
X
Xint player, dice[Five_Dice], available[13], avail_count;
X
X	{
X	int i, best_mark, value;
X	float benefit, best_benefit = -1000.0;
X
X	for (i = 0; i < avail_count; ++i)
X		{
X
X/* determine the value of the dice for each available category */
X		value = eval(available[i], dice);
X
X/* offset the value with the heuristic cost table */
X		benefit = value + cost_list[available[i] - 1][value];
X		if (benefit > best_benefit)
X			{
X
X/* remember best category thus far */
X			best_benefit = benefit;
X			best_mark = available[i];
X			}
X		}
X
X/* return overall best category */
X	return(best_mark);
X	}
END_OF_FILE
if test 937 -ne `wc -c <'comp_select.c'`; then
    echo shar: \"'comp_select.c'\" unpacked with wrong size!
fi
# end of 'comp_select.c'
fi
if test -f 'defs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'defs.h'\"
else
echo shar: Extracting \"'defs.h'\" \(2166 characters\)
sed "s/^X//" >'defs.h' <<'END_OF_FILE'
X/* default scores for categories with fixed scores, do not
X * change these */
X#define full_house_score 25
X#define small_straight_score 30
X#define large_straight_score 40
X#define yahtzee_score 50
X
X/*	Stuff for the high score file. Max_entries is the number
X *	of entries any single user can have.
X */
X#define player_name_len 50
X#define max_entries 3
X
X#if defined(pyr) || defined(cyber)
X#define THRASH_THAT_CPU
X#endif
X#ifdef vax
X#define BE_GENTLE_WITH_ME
X#endif
X
X/*	STAT_COUNT is the number of iterations of the heuristic
X *	evaluation function, low values (around 20) means there
X *	will be a fair amount of variance in what it considers
X *	the best dice to hold, high values (around 200) greatly
X *	decrease this variance, adjust according to CPU availability
X *	and level of unpredictability required
X */
X
X#ifdef THRASH_THAT_CPU
X# define STAT_COUNT 150
X#else
X# ifdef BE_GENTLE_WITH_ME
X#  define STAT_COUNT 60
X# else
X#  define STAT_COUNT 90
X# endif
X#endif
X
X/*	Alter anything below here and you are probably
X *	asking for trouble.
X */
X
X#define dicey 5
X#define dicex 11
X#define Five_Dice 5
X#define DICE_COPY_N (Five_Dice * sizeof(int))
X#define dicecount 6
X#define sidey 17
X#define sidex 30
X#define max_players 6
X#define Max_Players_Ch '6'
X#define max_marks 14
X#define run_size 3
X#define wrap(A, B, C) ((A) < (B) ? (C) : ((A) > (C) ? (B) : (A)))
X#define Form_Feed (char) 12
X#define max_hs_count 15
X#define category_available -1
X#define eval(feval, dice) (*eval_table[feval])(eval_kind[feval], dice)
X#define find_best_hold(dice, mark, hold) \
X	(*find_table[mark])(dice, find_kind[mark], hold)
X
Xextern int (*eval_table[])();
Xextern int eval_kind[];
Xextern void (*find_table[])();
Xextern int find_kind[];
X#ifdef BSD
Xextern long random();
X#else
Xextern long lrand48();
X#endif
X
X#ifdef BSD
X#define roll_dice(dice, hold) \
X	{ \
X	register int dice_i; \
X	for (dice_i = 0; dice_i < Five_Dice; ++dice_i) \
X		if (! hold[dice_i]) \
X			dice[dice_i] = (random() % dicecount) + 1; \
X	}
X#else
X#define roll_dice(dice, hold) \
X	{ \
X	register int dice_i; \
X	for (dice_i = 0; dice_i < Five_Dice; ++dice_i) \
X		if (! hold[dice_i]) \
X			dice[dice_i] = (lrand48() % dicecount) + 1; \
X	}
X#endif
END_OF_FILE
if test 2166 -ne `wc -c <'defs.h'`; then
    echo shar: \"'defs.h'\" unpacked with wrong size!
fi
# end of 'defs.h'
fi
if test -f 'dice.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dice.h'\"
else
echo shar: Extracting \"'dice.h'\" \(504 characters\)
sed "s/^X//" >'dice.h' <<'END_OF_FILE'
Xstatic char dices[dicecount][dicey][dicex] = {
X	{".-------.",
X	 "|       |",
X	 "|   O   |",
X	 "|       |",
X	 "`-------'"},
X	{".-------.",
X	 "| O     |",
X	 "|       |",
X	 "|     O |",
X	 "`-------'"},
X	{".-------.",
X	 "| O     |",
X	 "|   O   |",
X	 "|     O |",
X	 "`-------'"},
X	{".-------.",
X	 "| O   O |",
X	 "|       |",
X	 "| O   O |",
X	 "`-------'"},
X	{".-------.",
X	 "| O   O |",
X	 "|   O   |",
X	 "| O   O |",
X	 "`-------'"},
X	{".-------.",
X	 "| O   O |",
X	 "| O   O |",
X	 "| O   O |",
X	 "`-------'"}};
END_OF_FILE
if test 504 -ne `wc -c <'dice.h'`; then
    echo shar: \"'dice.h'\" unpacked with wrong size!
fi
# end of 'dice.h'
fi
if test -f 'dis_dice.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dis_dice.c'\"
else
echo shar: Extracting \"'dis_dice.c'\" \(1380 characters\)
sed "s/^X//" >'dis_dice.c' <<'END_OF_FILE'
X/* dis_dice.c
X *	display dice on default screen.
X */
X#include <curses.h>
X#include "defs.h"
X#include "dice.h"
X
X#define hold_fix(dice_num, hold_string) \
X	{ \
X	mvwaddstr(screen, diey[dice_num], diex[dice_num] + 4, hold_string); \
X	mvwaddstr(screen, diey[dice_num] + 4, diex[dice_num] + 1, \
X		hold_string); \
X	}
X
Xextern int BadStandout;
Xextern int diey[Five_Dice], diex[Five_Dice];
Xextern WINDOW *screen;
X
Xint old_dice[Five_Dice];
Xstatic int old_hold[Five_Dice] = {-1, -1, -1, -1};
X
Xdis_dice(dice, hold)
X
Xint dice[Five_Dice], hold[Five_Dice];
X
X	{
X	register int i, j, die;
X
X/* iterate through each dice value */
X	for (i = 0; i < Five_Dice; ++i)
X		{
X
X/* die is the index for the dices display strings */
X		die = dice[i] - 1;
X
X/* use standout mode (or "hold") for held dice */
X		if (! BadStandout)
X			if (! hold[i])
X				wstandend(screen);
X			else
X				wstandout(screen);
X		else
X			if (hold[i])
X				hold_fix(i, "hold")
X			else
X				hold_fix(i, "----")
X
X/* this test stops redraw of dice already on screen (curses will
X * look after this but not as efficiently */
X		if (dice[i] != old_dice[i] || (! BadStandout && old_hold[i]
X			!= hold[i]))
X			{
X			for (j = 0; j < dicey; ++j)
X				mvwaddstr(screen, diey[i] + j, diex[i],
X					dices[die][j]);
X			old_dice[i] = dice[i];
X			old_hold[i] = hold[i];
X			}
X		}
X	if (! BadStandout)
X		wstandend(screen);
X	wmove(screen, 5, 0);
X	wrefresh(screen);
X	}
END_OF_FILE
if test 1380 -ne `wc -c <'dis_dice.c'`; then
    echo shar: \"'dis_dice.c'\" unpacked with wrong size!
fi
# end of 'dis_dice.c'
fi
if test -f 'eval.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'eval.c'\"
else
echo shar: Extracting \"'eval.c'\" \(3081 characters\)
sed "s/^X//" >'eval.c' <<'END_OF_FILE'
X/* eval.c
X *	contains routines to determine the score achieved by
X *	a set of dice for any yahtzee category, these functions
X *	are called very frequently by the heuristic functions.
X */
X#include "defs.h"
X
X#define sortd(dice) \
X	{ \
X	register int i, j, tmp; \
X	for (i = 0; i < Five_Dice; ++i) \
X		for (j = i; j < Five_Dice; ++j) \
X			if (dice[i] < dice[j]) \
X				{ \
X				tmp = dice[i]; \
X				dice[i] = dice[j]; \
X				dice[j] = tmp; \
X				} \
X	}
X
Xint eval_kind[14] = {0, 1, 2, 3, 4, 5, 6, 3, 4, 0, 4, 5, 5, 0};
Xstatic run_score[2] = {small_straight_score, large_straight_score};
X
Xextern int abs();
X
X/* if all dice are identical then return yahtzee_score, otherwise 0 */
Xstatic int yahtzee(number, dice)
X
Xint number, dice[Five_Dice];
X
X	{
X	return(of_a_kind(Five_Dice, dice) ? yahtzee_score : 0);
X	}
X
X/* return score based on size of a straight */
Xstatic int run(size, dice)
X
Xint size, dice[Five_Dice];
X
X	{
X#ifdef BSD
X	register int i, max_dist = 0, dist = 0, score;
X	int new_dice[Five_Dice];
X#else
X	register int i, new_dice[Five_Dice], max_dist = 0, dist = 0, score;
X#endif
X
X/* duplicate dice */
X	memcpy(new_dice, dice, DICE_COPY_N);
X
X/* sort new dice */
X	sortd(new_dice);
X
X/* determine size of the largest run in the dice */
X	for (i = 0; i < 4; ++i)
X		{
X		while (i < 4 && new_dice[i] == new_dice[i + 1])
X			++i;
X		if (i < 4)
X			if (abs(new_dice[i] - new_dice[i + 1]) == 1)
X				++dist;
X			else
X				{
X				if (dist > max_dist)
X					max_dist = dist;
X				dist = 0;
X				}
X		}
X	if (dist > max_dist)
X		max_dist = dist;
X
X/* determine score based on size of largest run and expected size of run */
X	if (max_dist + 1 >= size)
X		score = run_score[size - 4];
X	else
X		score = 0;
X	return(score);
X	}
X
Xstatic int full_house(dummy, dice)
X
Xint dummy, dice[Five_Dice];
X
X	{
X#ifdef BSD
X	int new_dice[Five_Dice];
X#else
X	register int new_dice[Five_Dice];
X#endif
X
X	memcpy(new_dice, dice, DICE_COPY_N);
X	sortd(new_dice);
X
X/* kwik and dirty */
X	if ((new_dice[0] == new_dice[1] && new_dice[1] == new_dice[2] &&
X	     new_dice[3] == new_dice[4]) ||
X	    (new_dice[2] == new_dice[3] && new_dice[3] == new_dice[4] &&
X	     new_dice[0] == new_dice[1]))
X		return(full_house_score);
X	return(0);
X	}
X
Xstatic int of_a_kind(count, dice)
X
Xint count, dice[Five_Dice];
X
X	{
X	register int marks[dicecount], i, j;
X
X	for (i = 0; i < dicecount; ++i)
X		marks[i] = 0;
X	for (i = 0; i < Five_Dice; ++i)
X		{
X		j = dice[i] - 1;
X		++marks[j];
X		if (marks[j] == count)
X			return(addup(0, dice));
X		}
X	return(0);
X	}
X
X/* sum all dice values matching number, if number is zero then sum all dice */
Xstatic int addup(number, dice)
X
Xint number, *dice;
X
X	{
X	register int i, score = 0;
X
X	if (number)
X		for (i = 0; i < Five_Dice; ++i, ++dice)
X			{
X			if (*dice == number)
X				score += *dice;
X			}
X	else
X		for (i = 0; i < Five_Dice; ++i)
X			score += (*dice++);
X	return(score);
X	}
X
X/* calls to the above functions are made via a table of function
X * calls, this is done to avoid an expensive switch statement */
X
Xint (*eval_table[])() = {addup, addup, addup, addup, addup, addup, addup,
X	of_a_kind, of_a_kind, full_house, run, run, yahtzee, addup};
END_OF_FILE
if test 3081 -ne `wc -c <'eval.c'`; then
    echo shar: \"'eval.c'\" unpacked with wrong size!
fi
# end of 'eval.c'
fi
if test -f 'find.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'find.c'\"
else
echo shar: Extracting \"'find.c'\" \(3135 characters\)
sed "s/^X//" >'find.c' <<'END_OF_FILE'
X/* find.c
X *	contains the heuristic function to determine which
X *	dice should be held to achieve the highest possible
X *	score.
X */
X#include <curses.h>
X#include "defs.h"
X#ifdef BSD
X#ifdef register
X#undef register
X#endif
X#define register
X#endif
X
X#define Chance_Category 13
X
Xextern int scoreboard[max_players][max_marks];
Xextern int available[13], avail_count;
Xextern float cost_list[13][51];
Xextern WINDOW *screen;
X
X/* computer_move() forms a list of available categories then passes
X * that list to the heuristic function find_hold() */
Xcomputer_move(player, dice, hold)
X
Xint player, dice[Five_Dice], hold[Five_Dice];
X
X	{
X	int mark;
X
X	wmove(screen, 5, 0);
X	avail_count = 0;
X
X/*	form list of available categories,
X *	keep 'chance' category out of list of available
X *	categories, otherwise the heuristics treat it as
X *	a sure bet instead of a last resort */
X	for (mark = 1; mark < Chance_Category; ++mark)
X		if (scoreboard[player][mark] == category_available)
X			available[avail_count++] = mark;
X
X/*	...but slide it in if nothing else is available */
X	if (avail_count == 0)
X		{
X		available[0] = Chance_Category;
X		avail_count = 1;
X		}
X
X/* call heuristic function */
X	find_hold(dice, available, avail_count, hold);
X
X/* restore chance category to list of available categories */
X	if (scoreboard[player][Chance_Category] == category_available
X	    && available[0] != Chance_Category)
X		{
X		available[avail_count] = Chance_Category;
X		++avail_count;
X		}
X	}
X
X/* find_hold() is the heuristic function to determine the best hold */
Xint find_hold(dice, available, avail_count, new_hold)
X
Xint dice[Five_Dice], available[13], avail_count, new_hold[Five_Dice];
X
X	{
X	register int i, avail_mark, holds[Five_Dice], new_dice[Five_Dice],
X		mark; 
X
X/* set best to an impossibly bad value */
X	register float sum, evaluation, best = -1000.0, average;
X
X/* iterate mark through all available categories */
X	for (mark = 0; mark < avail_count; ++mark)
X		{
X
X/* preserve old dice by using a new copy */
X		memcpy(new_dice, dice, DICE_COPY_N);
X		avail_mark = available[mark];
X
X/* determine best hold for the given category, find_best_hold is
X * converted to a table of function calls (indexed by avail_mark)
X * by /lib/cpp at compile time (see defs.h) */
X		find_best_hold(new_dice, avail_mark, holds);
X
X		sum = 0.0;
X		for (i = 0; i < STAT_COUNT; ++i)
X			{
X
X/* roll dice STAT_COUNT times (dice held by call to find_best_hold()
X * will not be altered) */
X			roll_dice(new_dice, holds);
X
X/* sum the evaluation of the dice (based on the current category aval_mark) */
X			sum += eval(avail_mark, new_dice);
X			}
X
X/* calculate the projected average score based on the above trials */
X		average = sum / STAT_COUNT;
X
X/* offset this by cost_list so that the evaluation is aware of the
X * bonus for 63, the perils of chasing straights, the escape route
X * of the 1 and 2 categories, etc. */
X		evaluation = average + cost_list[mark][(int) average];
X
X/* if this category has produced the best evaluation... */
X		if (best < evaluation)
X			{
X
X/* ...then store best evaluation and store best holds */
X			best = evaluation;
X			memcpy(new_hold, holds, DICE_COPY_N);
X			}
X		}
X	}
END_OF_FILE
if test 3135 -ne `wc -c <'find.c'`; then
    echo shar: \"'find.c'\" unpacked with wrong size!
fi
# end of 'find.c'
fi
if test -f 'finish.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'finish.c'\"
else
echo shar: Extracting \"'finish.c'\" \(1368 characters\)
sed "s/^X//" >'finish.c' <<'END_OF_FILE'
X/* finish.c
X *	contains tasks to complete at the end of each game.
X */
X#include "defs.h"
X#include <curses.h>
X
X#define BONUS 35
X#define BONUS_TARGET 63
X
Xextern int scoreboard[max_players][max_marks];
Xextern int subtotals[max_players];
Xextern WINDOW *screen;
X
Xfinish(totals, player_count)
X
Xint totals[max_players], player_count;
X
X	{
X	int i, categories1_6, categories7_13, player, col, best_player = 0;
X
X	for (player = 0; player < player_count; ++player)
X		{
X		categories7_13 = 0;
X		col = player * 10 + 25;
X
X/* if the player's score in the categories 1 to 6 is greater than or equal to
X * BONUS_TARGET then award BONUS */
X		categories1_6 = subtotals[player];
X		if (categories1_6 >= BONUS_TARGET)
X			{
X			categories1_6 += BONUS;
X			wmove(screen, 21, col);
X			wprintw(screen, "%3d", BONUS);
X			}
X		totals[player] = categories1_6;
X
X/* sum the rest of the player's score */
X		for (i = 7; i <= 13; ++i)
X			categories7_13 += scoreboard[player][i];
X
X/* display sub-total for categories 7 to 13 */
X		mvwprintw(screen, 22, col, "%3d", categories7_13);
X		totals[player] += categories7_13;
X		if (totals[player] > totals[best_player])
X			best_player = player;
X
X/* display player's score for the game */
X		mvwprintw(screen, 23, col, "%3d", totals[player]);
X		}
X
X/* return the number of the player with the best score (for update of
X * the high score file) */
X	return(best_player);
X	}
END_OF_FILE
if test 1368 -ne `wc -c <'finish.c'`; then
    echo shar: \"'finish.c'\" unpacked with wrong size!
fi
# end of 'finish.c'
fi
if test -f 'get_m.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'get_m.c'\"
else
echo shar: Extracting \"'get_m.c'\" \(4383 characters\)
sed "s/^X//" >'get_m.c' <<'END_OF_FILE'
X/* get_m.c
X *	contains routine to get the given players hold pattern
X *	for the current dice.
X */
X#include <stdio.h>
X#include <curses.h>
X#include "defs.h"
X
X#define NTOP 6
X
Xextern int machine[max_players], diey[Five_Dice], diex[Five_Dice];
Xextern int scoreboard[max_players][max_marks];
Xextern WINDOW *screen;
X
Xstatic int human_available[13], human_avail_count;
X
X/* call the relevant move routine based on whether player is human or
X * computer simulation */
Xget_move(player, dice, hold)
X
Xint player, dice[Five_Dice], hold[Five_Dice];
X
X	{
X	dis_dice(dice, hold);
X	machine[player] ? computer_move(player, dice, hold) :
X		human_move(player, dice, hold);
X	dis_dice(dice, hold);
X	}
X
X/* prompt human for which dice to hold */
Xhuman_move(player, dice, hold)
X
Xint player, dice[Five_Dice], hold[Five_Dice];
X
X	{
X	int i, cur_dice = 0;
X	char ch;
X
X	do
X		{
X
X/* put cursor in middle of current dice */
X		wmove(screen, diey[cur_dice] + 2, diex[cur_dice] + 4);
X#ifndef SYS5_3
X
X/* System 5.3 Curses performs better if it isn't forced to refresh
X * directly before a getch */
X		wrefresh(screen);
X#endif
X
X/* get user input */
X		ch = wgetch(screen);
X		switch(ch)
X			{
X
X/* toggles dice between held and free */
X			case ' ' : hold[cur_dice] = ! hold[cur_dice];
X				   dis_dice(dice, hold);
X				   ++cur_dice;
X				   cur_dice = wrap(cur_dice, 0, 4);
X				   break;
X
X/* move cursor left */
X			case 'h' : --cur_dice;
X				   cur_dice = wrap(cur_dice, 0, 4);
X				   break;
X
X/* move cursor right */
X			case 'l' : ++cur_dice;
X				   cur_dice = wrap(cur_dice, 0, 4);
X				   break;
X
X/* hold all dice and quit this procedure by setting ch to
X * loop termination character */
X			case 'a' : for (i = 0; i < Five_Dice; ++i)
X					hold[i] = TRUE;
X				   ch = '\n';
X				   break;
X
X/* human player request for computer simulation recommendation */
X			case 'r' : computer_move(player, dice, hold);
X				   dis_dice(dice, hold);
X				   break;
X
X/* display score that can be obtained with the current dice */
X			case 't' : dice_values(screen, player, dice);
X				   break;
X
X			case 'q' : dis_score((WINDOW *) 0);
X				   yahtzee_exit(0);
X				   break;
X			case '?' : help_out(2, screen);
X				   break;
X			case 's' : dis_score(screen);
X				   break;
X			case Form_Feed : redraw(screen);
X				   break;
X			case 'b' : rools(screen);
X				   break;
X			case '!' : shell(screen);
X				   break;
X			case 'v' : version(screen);
X				   break;
X#if defined(SYS5) || defined(SYS5_3)
X			case '$' : shwin(screen);
X				   break;
X			case '\n' : break;
X			default : flash();
X				  break;
X#endif
X			}
X		} while (ch != '\n');
X	}
X
Xextern char side[sidey][sidex];
X
X/* select which category to place the dice */
Xint human_select(player, dice)
X
Xint player, dice[Five_Dice];
X
X	{
X	int side_no = 0, best;
X	char ch;
X
X	do
X		{
X		wmove(screen, human_available[side_no] + NTOP, 0);
X#ifndef SYS5_3
X		wrefresh(screen);
X#endif
X		ch = wgetch(screen);
X		switch(ch)
X			{
X
X/* move up one category */
X			case 'k' : --side_no;
X				   side_no = wrap(side_no, 0,
X					human_avail_count - 1);
X				   break;
X
X/* move down one category */
X			case 'j' : ++side_no;
X				   side_no = wrap(side_no, 0,
X					human_avail_count - 1);
X				   break;
X
X/* get computer's recommendation of best category */
X			case 'r' : best = computer_select(player, dice,
X					human_available, human_avail_count);
X				   side_no = 0;
X				   while (side_no < human_avail_count &&
X					human_available[side_no] != best)
X					++side_no;
X				   break;
X
X/* display score that can be obtained with the current dice */
X			case 't' : dice_values(screen, player, dice);
X				   break;
X
X			case 'q' : dis_score((WINDOW *) 0);
X				   yahtzee_exit(0);
X				   break;
X			case '?' : help_out(3, screen);
X				   break;
X			case 's' : dis_score(screen);
X				   break;
X			case Form_Feed : redraw(screen);
X				   break;
X			case 'b' : rools(screen);
X				   break;
X			case '!' : shell(screen);
X				   break;
X			case 'v' : version(screen);
X				   break;
X#if defined(SYS5) || defined(SYS5_3)
X			case '$' : shwin(screen);
X				   break;
X			case '\n' : break;
X			default : flash();
X				  break;
X#endif
X			}
X		} while (ch != '\n');
X	return(human_available[side_no]);
X	}
X
X/* form the list of categories available to the given player */
Xhuman_availability(player)
X
Xint player;
X
X	{
X	int i;
X
X	human_avail_count = 0;
X	for (i = 1; i < 14; ++i)
X		if (scoreboard[player][i] == category_available)
X			human_available[human_avail_count++] = i;
X	}
END_OF_FILE
if test 4383 -ne `wc -c <'get_m.c'`; then
    echo shar: \"'get_m.c'\" unpacked with wrong size!
fi
# end of 'get_m.c'
fi
if test -f 'help.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'help.c'\"
else
echo shar: Extracting \"'help.c'\" \(1923 characters\)
sed "s/^X//" >'help.c' <<'END_OF_FILE'
X/* help.c
X *	interactive help routines available at all stages of play.
X */
X#include <curses.h>
X#include "defs.h"
X#include "help.h"
X
Xextern int BadStandout;
X
X/* help_out is the main help routine, 'help_scr' is the number of the
X * help page to be displayed (see help.h), the window that help is
X * requested for is 'screen' (this will be overwritten and must be
X * redrawn at the end of this procedure) */
Xhelp_out(help_scr, screen)
X
Xint help_scr;
XWINDOW *screen;
X
X	{
X	int tmp_y, tmp_x, i;
X	char ch;
X	WINDOW *help;
X
X/* move the cursor to the top of the back window as initialisation
X * of this routine can take a few seconds on a slow machine (leaving
X * an impatient user wondering what key to hit to get help working) */
X	getyx(screen, tmp_y, tmp_x);
X	wmove(screen, 0, 0);
X	wrefresh(screen);
X
X/* create the help window */
X	help = newwin(max_lines, max_cols, 4, 15);
X	BoxUp(help, max_lines, max_cols);
X
X/* move the relevant data to the window */
X	for (i = 0; help_words[help_scr][i][0] != '\0'; ++i)
X		mvwaddstr(help, i + 1, 1, help_words[help_scr][i]);
X	mvwaddstr(help, max_lines - 2, 1, "--(q)uit--");
X#ifndef SYS5_3
X	wrefresh(help);
X#endif
X	do
X		{
X		ch = wgetch(help);
X		switch (ch)
X			{
X			case Form_Feed : redraw(help);
X				   break;
X			case '?' : help_out(5, help);
X				   break;
X			case 'b' : rools(help);
X				   break;
X			case 's' : dis_score(help);
X				   break;
X			case '!' : shell(help);
X				   break;
X			case 'v' : version(help);
X				   break;
X#if defined(SYS5) || defined(SYS5_3)
X			case '$' : shwin(help);
X				   break;
X			case 'q' :
X			case ' ' : break;
X			default : flash();
X				  break;
X#endif
X			}
X		} while (ch != 'q' && ch != ' ');
X
X/* remove the input prompt */
X	mvwaddstr(help, max_lines - 2, 1, "               ");
X	wmove(help, 0, 0);
X	wrefresh(help);
X
X/* get rid of help window */
X	delwin(help);
X
X/* restore previous window */
X	touchwin(screen);
X	wmove(screen, tmp_y, tmp_x);
X	wrefresh(screen);
X	}
END_OF_FILE
if test 1923 -ne `wc -c <'help.c'`; then
    echo shar: \"'help.c'\" unpacked with wrong size!
fi
# end of 'help.c'
fi
if test -f 'makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'makefile'\"
else
echo shar: Extracting \"'makefile'\" \(1662 characters\)
sed "s/^X//" >'makefile' <<'END_OF_FILE'
X# Define your brand of Unix here.
X
X#### Berkeley Unix systems should use this
X#UNIX_BRAND= BSD
X#
X#### any System 5 less than 5.3 should define this
X#UNIX_BRAND= SYS5
X#
X#### define this for 5.3 or (gulp) later
XUNIX_BRAND= SYS5_3
X
X# BIN - final resting place for yahtzee
XBIN= $(HOME)/bin
X
X# HSFILE - path for high score file, file will be created automatically
X#	   by yahtzee and will need write permission for those using it
XHSFILE= $(HOME)/lib/yahtzee.HS
X
X# LDLIBS - libraries to get curses(3X) working
X#  BSD people require -ltermcap and -lcurses, SYS5 people only need -lcurses
XLDLIBS= -lcurses
X#LDLIBS= -lcurses -ltermcap
X
X# LDFLAGS - flags for the loader
X#  BSD people should leave this empty
XLDFLAGS= $(CFLAGS)
X#LDFLAGS=
X
X# FINAL - basename for program
XFINAL= yahtzee
X
X#
X#  ****** No real need to change anything below this line ******
X#
X
X# HSSTRING - use this to get past sh(1) which will strip quotes
XHSSTRING= '"$(HSFILE)"'
X
XMANENTRY= yahtzee.6
XCFLAGS= -O -D$(UNIX_BRAND)
XHIGHFLAG= -DHSFILE=$(HSSTRING)
X
XOBJECTS = best.o boxup.o comp_select.o dis_dice.o eval.o find.o finish.o\
X	get_m.o help.o high.o misc.o opthelp.o play_info.o rools.o\
X	shwin.o update_score.o yz.o costs.o shell.o values.o
X
X$(FINAL): $(OBJECTS)
X	cc $(LDFLAGS) -o $(FINAL) $(OBJECTS) $(LDLIBS)
X
X$(OBJECTS): defs.h
X
Xmisc.o: side.h
X
Xcosts.o: costs.h
X
Xdis_dice.o: dice.h
X
Xhelp.o: help.h
X
Xhigh.o: makefile
X	cc -c $(CFLAGS) $(HIGHFLAG) high.c
X
Xrools.o: rools.h
X
Xinstall: $(FINAL)
X	cp $(FINAL) $(BIN)
X	strip $(BIN)/$(FINAL)
X
Xman:
X	nroff -man $(MANENTRY) > $(FINAL).man
X
Xcleanup:
X	rm -f $(OBJECTS) $(FINAL) $(FINAL).man
X
Xshar:
X	xshar -v -c -l32 -oyahtzee README $(MANENTRY) makefile *.c *.h
END_OF_FILE
if test 1662 -ne `wc -c <'makefile'`; then
    echo shar: \"'makefile'\" unpacked with wrong size!
fi
# end of 'makefile'
fi
if test -f 'misc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'misc.c'\"
else
echo shar: Extracting \"'misc.c'\" \(1201 characters\)
sed "s/^X//" >'misc.c' <<'END_OF_FILE'
X/* misc.c
X *	various miscellaneous routines.
X */
X#include <curses.h>
X#include <signal.h>
X#include "defs.h"
X#include "side.h"
X
X/* gets called on interrupts */
Xbyebye()
X	{
X	signal(SIGINT, SIG_IGN);
X	signal(SIGTERM, SIG_IGN);
X	dis_score((WINDOW *) 0);
X	yahtzee_exit(0);
X	}
X
X/* display categories */
Xdis_side()
X
X	{
X	int i;
X
X	for (i = 0; i < sidey; ++i)
X		mvwaddstr(screen, i + top, 0, side[i]);
X	}
X
X/* general purpose exit routine */
Xint yahtzee_exit(status)
X
Xint status;
X
X	{
X#ifdef BSD
X	wmove(screen, 23, 0);
X	wrefresh(screen);
X#endif
X	nocrmode();
X	echo();
X	endwin();
X	exit(status);
X	}
X
X/* redraw a window in cases where garbage hits the screen */
Xredraw(win)
X
XWINDOW *win;
X
X	{
X	clear();
X	refresh();
X	touchwin(win);
X	wrefresh(win);
X	return(0);
X	}
X
Xstatic char versionID[] =
X	{"yahtzee V1.0 Beta - Stacey Campbell - {utzoo,utcsri}!hcr!stacey"};
X
Xversion(back_window)
X
XWINDOW *back_window;
X
X	{
X	WINDOW *v_window;
X	int mess_len = strlen(versionID) + 3;
X
X	v_window = newwin(3, mess_len, 11, (COLS - mess_len) / 2);
X	BoxUp(v_window, 3, mess_len);
X	mvwaddstr(v_window, 1, 1, versionID);
X	touchwin(v_window);
X	wrefresh(v_window);
X	sleep(3);
X	touchwin(back_window);
X	wrefresh(back_window);
X	delwin(v_window);
X	}
END_OF_FILE
if test 1201 -ne `wc -c <'misc.c'`; then
    echo shar: \"'misc.c'\" unpacked with wrong size!
fi
# end of 'misc.c'
fi
if test -f 'opthelp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'opthelp.c'\"
else
echo shar: Extracting \"'opthelp.c'\" \(415 characters\)
sed "s/^X//" >'opthelp.c' <<'END_OF_FILE'
X/* opthelp.c
X *	dianostic for bad options.
X */
Xoption_message(prog_name)
X
Xchar *prog_name;
X
X	{
X	printf("%s: The game of Yahtzee\n\n", prog_name);
X	printf("options:\n\n");
X	printf("%s [-s] [-h] [-N] [-d]\n\n", prog_name);
X	printf(" -s  print high-score file to stdout\n");
X	printf(" -h  get this message\n");
X	printf(" -N  play games non-stop (forever)\n");
X	printf(" -d  don't use standout mode of terminal\n");
X	}
END_OF_FILE
if test 415 -ne `wc -c <'opthelp.c'`; then
    echo shar: \"'opthelp.c'\" unpacked with wrong size!
fi
# end of 'opthelp.c'
fi
if test -f 'rools.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rools.c'\"
else
echo shar: Extracting \"'rools.c'\" \(3437 characters\)
sed "s/^X//" >'rools.c' <<'END_OF_FILE'
X/* rools.c
X *	put the rules of yahtzee on the screen in neatly overlayed
X *	curses windows (makes a vax look like an Amiga!).
X */
X#include <curses.h>
X#include <stdio.h>
X#include "defs.h"
X#include "rools.h"
X
X/* length and width of each window */
X#define Rule_Window_Length 18
X#define Rule_Window_Width (RULE_WIDTH + 2)
X
X/* length of the text that will appear on each window */
X#define Text_Length (Rule_Window_Length - 2)
X
X/* number of windows required to display all the rules (all constants) */
X#define Window_Count ((RULE_LENGTH / Text_Length) + 1)
X
Xrools(Screen)
X
XWINDOW *Screen;
X
X	{
X	int i, j, Y_Move_Increment, X_Move_Increment, y = 0, x = 0,
X		Text_Counter = 0, Window_Up, Window_Demanded, tmp_y, tmp_x;
X	WINDOW *Rules_Window[Window_Count];
X	char ch;
X
X	getyx(Screen, tmp_y, tmp_x);
X	wmove(Screen, 0, 0);
X	wrefresh(Screen);
X
X/* determine how far each window will overlap the next */
X	X_Move_Increment = (COLS - Rule_Window_Width) / Window_Count;
X	Y_Move_Increment = (LINES - Rule_Window_Length) / Window_Count;
X
X	for (i = 0; i < Window_Count; ++i)
X		{
X
X/* create a new rules window */
X		Rules_Window[i] = newwin(Rule_Window_Length, Rule_Window_Width,
X			y, x);
X		werase(Rules_Window[i]);
X
X/* load the text for that window */
X		for (j = 1; j < Text_Length && Text_Counter < RULE_LENGTH; ++j)
X			{
X			mvwaddstr(Rules_Window[i], j, 1, rules[Text_Counter]);
X			++Text_Counter;
X			}
X		BoxUp(Rules_Window[i], Rule_Window_Length, Rule_Window_Width);
X
X/* determine position on screen for next window */
X		y += Y_Move_Increment;
X		x += X_Move_Increment;
X		}
X
X/* display each window as it is demanded, the first window is
X * displayed without being demanded */
X	Window_Up = -1;
X	Window_Demanded = 0;
X	do
X		{
X		if (Window_Demanded != Window_Up)
X			{
X
X/* if window is demanded then bring it to the fore with touchwin */
X			touchwin(Rules_Window[Window_Demanded]);
X			wrefresh(Rules_Window[Window_Demanded]);
X			Window_Up = Window_Demanded;
X			}
X
X/* give prompt to move through windows */
X		mvwaddstr(Rules_Window[Window_Up], Rule_Window_Length - 2, 1,
X			"--(m)ore, (q)uit, (b)ack or ?--");
X#ifndef SYS5_3
X		wrefresh(Rules_Window[Window_Up]);
X#endif
X		ch = wgetch(Rules_Window[Window_Up]);
X
X/* erase prompt */
X		mvwaddstr(Rules_Window[Window_Up], Rule_Window_Length - 2, 1,
X			"                               ");
X		wmove(Rules_Window[Window_Up], Rule_Window_Length - 2, 1);
X		wrefresh(Rules_Window[Window_Up]);
X		switch (ch)
X			{
X
X/* display next window */
X			case ' ' : ++Window_Demanded;
X				   break;
X
X/* display next window */
X			case 'm' : ++Window_Demanded;
X				   break;
X
X/* display previous window */
X			case 'b' : --Window_Demanded;
X				   break;
X			case Form_Feed : redraw(Rules_Window[Window_Up]);
X				   break;
X			case '?' : help_out(4, Rules_Window[Window_Up]);
X				   break;
X			case 's' : dis_score(Rules_Window[Window_Up]);
X				   break;
X			case '!' : shell(Rules_Window[Window_Up]);
X				   break;
X			case 'v' : version(Rules_Window[Window_Up]);
X				   break;
X#if defined(SYS5) || defined(SYS5_3)
X			case '$' : shwin(Rules_Window[Window_Up]);
X				   break;
X			case 'q' : break;
X			default : flash();
X				  break;
X#endif
X			}
X
X/* ensure wraparound */
X		Window_Demanded = wrap(Window_Demanded, 0, Window_Count - 1);
X		} while (ch != 'q');
X
X/* remove rule windows */
X	for (i = 1; i < Window_Count; ++i)
X		delwin(Rules_Window[i]);
X
X/* restore previous screen */
X	touchwin(Screen);
X	wmove(Screen, tmp_y, tmp_x);
X	wrefresh(Screen);
X	}
END_OF_FILE
if test 3437 -ne `wc -c <'rools.c'`; then
    echo shar: \"'rools.c'\" unpacked with wrong size!
fi
# end of 'rools.c'
fi
if test -f 'rools.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rools.h'\"
else
echo shar: Extracting \"'rools.h'\" \(2380 characters\)
sed "s/^X//" >'rools.h' <<'END_OF_FILE'
Xstatic char *rules[] = {
X	"Rules of Yahtzee",
X	" ",
X	"Object:",
X	" The object of Yahtzee is to make the highest",
X	" score of all players in each game.  This is",
X	" achieved by rolling dice and placing the",
X	" dice in the category likely to result in the",
X	" highest possible score.",
X	" ",
X	"Rolling the Dice:",
X	" The dice are rolled three times per turn for",
X	" each player.  Between rolls the player is able",
X	" to hold dice so that those dice will not",
X	" participate in the next roll.",
X	" ",
X	"Selection of Best Category:",
X	" When the dice roll has been completed the player",
X	" must select a category for the final set of",
X	" dice. The rules regarding scoring for each",
X	" category are as follows:",
X	" ",
X	" - one, two, ..., six: dice matching the",
X	"     number of the category are summed, this",
X	"     sum is the score (e.g. dice values of",
X	"     1 4 4 5 6 will score 8 in the 'four'",
X	"     category; 1 in the 'one' category etc.).",
X	" - three/four of a kind: if at least three/four",
X	"     of the dice are of one kind then the score",
X	"     will be the summation of all dice, otherwise",
X	"     the score is zero",
X	" - full house: a full house is scored when there",
X	"     exists a pair of dice AND a triplet of dice",
X	"     (e.g. dice values 4 4 4 1 1 represent a full",
X	"     house; 5 of a kind is also a full house).",
X	" - small straight: a small straight is scored when",
X	"     at least four dice have consecutive values",
X	"     (e.g. 1 2 3 4 2 is a small straight).",
X	" - large straight: a large straight is scored when",
X	"     at least five dice have consecutive values.",
X	" - Yahtzee: a Yahtzee is scored when all dice have",
X	"     the same value",
X	" - chance: the score for chance is the summation",
X	"     of all dice, it is impossible to score less",
X	"     than 5 for chance.",
X	" ",
X	" If the dice are placed in a category where they do",
X	" not satisfy the requirements of that category, they",
X	" will score zero. The player must select a category",
X	" in every turn.",
X	" ",
X	"End of Game:",
X	" ",
X	" When all players have completed their score cards",
X	" the totals of their scores are calculated and the",
X	" player with the highest score wins. A bonus of 35",
X	" is awarded to any player who achieves a sub-total",
X	" of 63 or more across the categories 'one' to 'six'."};
X
X#define RULE_WIDTH 53
X#define RULE_LENGTH 57
END_OF_FILE
if test 2380 -ne `wc -c <'rools.h'`; then
    echo shar: \"'rools.h'\" unpacked with wrong size!
fi
# end of 'rools.h'
fi
if test -f 'shell.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'shell.c'\"
else
echo shar: Extracting \"'shell.c'\" \(2119 characters\)
sed "s/^X//" >'shell.c' <<'END_OF_FILE'
X/* shell.c
X *	a simple shell escape available at all times.
X */
X#include <signal.h>
X#include <curses.h>
X
X/* default shell */
Xstatic char *shell_name = {"/bin/sh"};
Xstatic char *default_base = {"(yahtzee)"};
X
Xshell(BackWindow)
X
XWINDOW *BackWindow;
X
X	{
X	int pid, wait_status, fork_status;
X	char *shell_choice, *getenv(), *basename, *strrchr();
X#ifdef BSD
X	int (*oldint)(), (*oldquit)();
X#else
X	void (*oldint)(), (*oldquit)();
X#endif
X
X#if (defined(SYS5) || defined(SYS5_3)) && ! defined(cyber)
X	extern int shell_window_active;
X	WINDOW *BadNews;
X
X	if (shell_window_active)
X		{
X		BadNews = newwin(3, 46, 11, 20);
X		BoxUp(BadNews, 3, 46);
X		mvwaddstr(BadNews, 1, 1,
X			"Cannot exec shell with shell window active.");
X		touchwin(BadNews);
X		flash();
X		wrefresh(BadNews);
X		sleep(3);
X		touchwin(BackWindow);
X		wrefresh(BackWindow);
X		delwin(BadNews);
X		return;
X		}
X#endif
X
X/* move cursor to bottom of screen */
X	wmove(stdscr, LINES - 1, 0);
X	refresh();
X
X/* save the curses terminal state */
X	savetty();
X
X/* set the terminal to the 'out of curses' state */
X#ifdef BSD
X	echo();
X	nocbreak();
X#else
X	resetterm();
X#endif
X
X/* create the new process */
X	if((pid = fork()) == 0)
X
X/* code executed by the child... */
X		{
X
X/* see if the user has a preference for a shell */
X		if (((shell_choice = getenv("SHELL"))) == NULL ||
X		    (strlen(shell_choice) == 0))
X			shell_choice = shell_name;
X
X/* determine the basename for use as the 2nd parm to execl */
X		if ((basename = strrchr(shell_choice, '/')) == NULL)
X			basename = default_base;
X		else
X			++basename;
X
X/* zap what is left of yahtzee and start a shell */
X		(void) execl(shell_choice, basename, "-i", 0);
X		exit(-1);
X		}
X
X/* parent process */
X
X/* ignore pesky signals */
X	oldint = signal(SIGINT, SIG_IGN);
X	oldquit = signal(SIGQUIT, SIG_IGN);
X
X/* wait for child process to terminate */
X	while((wait_status = wait(&fork_status)) != pid && wait_status != -1);
X
X/* reset (pesky) signals */
X	(void) signal(SIGINT, oldint);
X	(void) signal(SIGQUIT, oldquit);
X
X/* set terminal back to 'in curses' state */
X	resetty();
X
X/* complete redraw of the previous window */
X	redraw(BackWindow);
X	}
END_OF_FILE
if test 2119 -ne `wc -c <'shell.c'`; then
    echo shar: \"'shell.c'\" unpacked with wrong size!
fi
# end of 'shell.c'
fi
if test -f 'side.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'side.h'\"
else
echo shar: Extracting \"'side.h'\" \(344 characters\)
sed "s/^X//" >'side.h' <<'END_OF_FILE'
X#define top 7
X
Xchar side[sidey][sidex] = {
X	"  1 one",
X	"  2 two",
X	"  3 three",
X	"  4 four",
X	"  5 five",
X	"  6 six",
X	"  7 3 of a kind",
X	"  8 4 of a kind",
X	"  9 full house",
X	" 10 small straight",
X	" 11 large straight",
X	" 12 yahtzee",
X	" 13 chance",
X	"sub-total 1-6",
X	"bonus for 63",
X	"sub-total 7-13",
X	"total"};
X
Xextern WINDOW *screen;
END_OF_FILE
if test 344 -ne `wc -c <'side.h'`; then
    echo shar: \"'side.h'\" unpacked with wrong size!
fi
# end of 'side.h'
fi
if test -f 'update_score.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'update_score.c'\"
else
echo shar: Extracting \"'update_score.c'\" \(807 characters\)
sed "s/^X//" >'update_score.c' <<'END_OF_FILE'
X/* update_score.c
X *	update the score board after a user has completed
X *	one turn with the dice.
X */
X#include "defs.h"
X#include <curses.h>
Xextern WINDOW *screen;
X
Xextern int scoreboard[max_players][max_marks];
Xextern int subtotals[max_players];
X
Xupdate_score(player, mark, dice)
X
Xint player, mark, dice[Five_Dice];
X
X	{
X	int score, col;
X
X	col = player * 10 + 25;
X
X/* evaluate the user's score */
X	score = eval(mark, dice);
X
X/* if the category is 1-6 then add to the 1-6 subtotal and display */
X	if (mark <= 6 && score != 0)
X		{
X		subtotals[player] += score;
X		wmove(screen, 20, col);
X		wprintw(screen, "%3d", subtotals[player]);
X		}
X
X/* update the scoreboard */
X	scoreboard[player][mark] = score;
X	wmove(screen, mark + 6, col);
X
X/* display the score */
X	wprintw(screen, "%3d", score);
X	wrefresh(screen);
X	}
END_OF_FILE
if test 807 -ne `wc -c <'update_score.c'`; then
    echo shar: \"'update_score.c'\" unpacked with wrong size!
fi
# end of 'update_score.c'
fi
if test -f 'values.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'values.c'\"
else
echo shar: Extracting \"'values.c'\" \(1031 characters\)
sed "s/^X//" >'values.c' <<'END_OF_FILE'
X#include <curses.h>
X#include "defs.h"
X
Xextern int scoreboard[max_players][max_marks];
Xextern int BadStandout;
X
Xdice_values(back_window, player, dice)
X
XWINDOW *back_window;
Xint dice[Five_Dice], player;
X
X	{
X	WINDOW *val_win;
X	int oldy, oldx, i, stand_flag;
X
X	getyx(back_window, oldy, oldx);
X	wmove(back_window, 0, 0);
X	wrefresh(back_window);
X	val_win = newwin(15, 4, 6, player * 10 + 22);
X	BoxUp(val_win, 15, 4);
X	if (BadStandout)
X		for (i = 0; i < 13; ++i)
X			{
X			wmove(val_win, i + 1, 1);
X			wprintw(val_win, "%2d", eval(i + 1, dice));
X			}
X	else
X		for (i = 0; i < 13; ++i)
X			{
X			wmove(val_win, i + 1, 1);
X			if (scoreboard[player][i + 1] != category_available)
X				{
X				wstandout(val_win);
X				stand_flag = TRUE;
X				}
X			wprintw(val_win, "%2d", eval(i + 1, dice));
X			if (stand_flag)
X				{
X				wstandend(val_win);
X				stand_flag = FALSE;
X				}
X			}
X	touchwin(val_win);
X	wmove(val_win, 0, 0);
X	wrefresh(val_win);
X	sleep(4);
X	touchwin(back_window);
X	wmove(back_window, oldy, oldx);
X	wrefresh(back_window);
X	delwin(val_win);
X	}
END_OF_FILE
if test 1031 -ne `wc -c <'values.c'`; then
    echo shar: \"'values.c'\" unpacked with wrong size!
fi
# end of 'values.c'
fi
if test -f 'yahtzee.6' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'yahtzee.6'\"
else
echo shar: Extracting \"'yahtzee.6'\" \(1039 characters\)
sed "s/^X//" >'yahtzee.6' <<'END_OF_FILE'
X.TH Yahtzee 6l
X.SH NAME
Xyahtzee \- the game of yahtzee
X.SH SYNOPSIS
X.B yahtzee
X.B [\-d] [\-N] [\-s] [\-h]
X.SH DESCRIPTION
X.I Yahtzee
Xis a computer simulation of the game of the same name.
XThis version of Yahtzee allows up to six players, where
Xplayers can be either users at the same terminal
Xor a computer simulation of a player.
X.PP
XFull on\-line help is available at all times by pressing
Xthe question mark character. If you are unfamiliar with
Xthe rules a rule book is also available at all times
Xby pressing the 'b' key.
X.PP
XOptions are:
X.TP
X.B  \-d
Xdon't use the standout mode of the terminal
X.TP
X.B  \-N
Xplay
X.I yahtzee
Xnon-stop, good if all players are computer simulations
X.TP
X.B  \-s
Xdisplay the high score file
X.TP
X.B  \-h
Xgive command line options
X.PP
XAt the end of each game the player with the highest score
Xis eligible to have their score recorded in the high
Xscore file.
X.SH BUGS
XUnknown, but please send bug problems to {utzoo,utcsri,lsuc}!hcr!stacey.
X.SH AUTHOR
XStacey Campbell \- HCR Corporation, Toronto, Canada, 1988.
END_OF_FILE
if test 1039 -ne `wc -c <'yahtzee.6'`; then
    echo shar: \"'yahtzee.6'\" unpacked with wrong size!
fi
# end of 'yahtzee.6'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0