home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
TOP
/
USR
/
SRC
/
yahtzee.t.Z
/
yahtzee.t
/
comp_select.c
< prev
next >
Wrap
Text File
|
1988-07-28
|
937b
|
43 lines
/* comp_select.c
* determines in which category the heuristics will place a
* set of dice.
*/
#include <stdio.h>
#include "defs.h"
#define three_of_a_kind 7
#define four_of_a_kind 8
extern float cost_list[13][51];
extern int machine[max_players];
extern int scoreboard[max_players][max_marks];
int computer_select(player, dice, available, avail_count)
int player, dice[Five_Dice], available[13], avail_count;
{
int i, best_mark, value;
float benefit, best_benefit = -1000.0;
for (i = 0; i < avail_count; ++i)
{
/* determine the value of the dice for each available category */
value = eval(available[i], dice);
/* offset the value with the heuristic cost table */
benefit = value + cost_list[available[i] - 1][value];
if (benefit > best_benefit)
{
/* remember best category thus far */
best_benefit = benefit;
best_mark = available[i];
}
}
/* return overall best category */
return(best_mark);
}