/*
 *	File name:			strategy_gonzo.c
 *	Purpose:			Defines a robot strategy for playing poker.
 *	Functions:			computer_bet, computer_draw, strategy_init,
 *						strategy_exit, computer_outcome, computer_hear.
 *	Created:			23 Nov 89
 *	Last Modified:		25 Jul 93
 *	Comments:
 *		"Strategy" files must contain six externally visible functions:
 *
 *		strategy_init - called once during startup.
 *		strategy_exit - called once upon orderly exit.
 *		computer_bet - called whenever a bet is needed.
 *		computer_draw - called whenever a draw of cards is needed.
 *		computer_outcome - called at the end of each hand.
 *		computer_hear - called whenever anyone sends a text message.
 *
 *		The interfaces to these six functions are well-defined and should 
 *		remain stable.  You can use this file to entirely alter the playing 
 *		methods of a robot player without being concerned with server 
 *		communication or anything else.
 *
 *	History:
 *		23 Nov 89/JVE	Created.
 *		25 Nov 89/JVE	Added an empty strategy_init().
 *		25 Jul 93/JVE	Prototypes, new standard functions.
 */

# include	"cards.h"
# include	"whowon.h"		/* for eval() results */
# include	"5draw.h"		/* for RAISE_LIMIT */
# include	"robot.h"
# include	"knowledge.h"
# include	"strategy_protos.h"


/****************************************************************************/
/*	FUNCTION:	computer_bet												*/
/*																			*/
/*	PURPOSE:	Decide how much to bet.										*/
/*																			*/
/*	INPUT PARAMETERS:														*/
/*		NAME		I/O		DESCRIPTION										*/
/*		----		---		-----------										*/
/*		knowledge	 I		Everything we know about the current hand.		*/
/*		me			 I		Index in knowledge[] of this robot.				*/
/*		required	 I		Total $$ this hand to bet to stay in.			*/
/*																			*/
/*	RETURNS:																*/
/*		The additional amount to bet.										*/
/*																			*/
/*		-1		Fold.														*/
/*		0		Pass - only return this if already_bet == required.			*/
/*																			*/
/*	COMMENTS:																*/
/*		For Three Of A Kind or above, raise to the max.  For poorer hands,	*/
/*		either pass or fold.												*/
/*																			*/
/*	HISTORY:																*/
/*		1.	23 Nov 89		Created.										*/
/*																			*/
/****************************************************************************/

computer_bet( KNOWLEDGE knowledge[], int me, int required )

{
if ( eval( knowledge[me].cards ) < THREE )
	{
	if ( required - knowledge[me].bet > 0 )
		return -1;
	else
		return 0;
	}
else
	return ( required - knowledge[me].bet + RAISE_LIMIT );
}


/****************************************************************************/
/*	FUNCTION:	computer_draw												*/
/*																			*/
/*	PURPOSE:	Decide which cards to keep and which to toss.				*/
/*																			*/
/*	INPUT PARAMETERS:														*/
/*		NAME		I/O		DESCRIPTION										*/
/*		----		---		-----------										*/
/*		knowledge	 I		Everything we know about the current hand.		*/
/*		me			 I		Index in knowledge[] of this robot.				*/
/*		cmd			 O		Constructed "discard" command.					*/
/*																			*/
/*	RETURNS: none															*/
/*																			*/
/*	COMMENTS:																*/
/*		Uses the standard draw function.									*/
/*																			*/
/*	HISTORY:																*/
/*		1.	23 Nov 89		Created.										*/
/*																			*/
/****************************************************************************/

void computer_draw( KNOWLEDGE knowledge[], int me, char *cmd )

{
standard_draw( knowledge[me].cards, cmd );
}


/****************************************************************************/
/*	FUNCTION:	strategy_init												*/
/*																			*/
/*	PURPOSE:	Any initialization this strategy requires.					*/
/*																			*/
/*	INPUT PARAMETERS:														*/
/*		NAME		I/O		DESCRIPTION										*/
/*		----		---		-----------										*/
/*																			*/
/*	RETURNS: none															*/
/*																			*/
/*	COMMENTS:																*/
/*																			*/
/*	HISTORY:																*/
/*		1.	25 Nov 89		Created.										*/
/*																			*/
/****************************************************************************/

int strategy_init(void)

{
return TRUE;
}

/*
 ****************************************************************************
 *	FUNCTION:	strategy_exit
 *
 *	PURPOSE:	Called as this program exits.
 *
 *	INPUT PARAMETERS:
 *		NAME		I/O		DESCRIPTION
 *		----		---		-----------
 *
 *	RETURNS: none
 *
 *	COMMENTS:
 *
 *	HISTORY:
 *		1.	13 Mar 93/JVE		Created.
 *
 ****************************************************************************
 */

void strategy_exit(void)

{
}

/*
 ****************************************************************************
 *	FUNCTION:	computer_hear
 *
 *	PURPOSE:	Called when someone at the table speaks.
 *
 *	INPUT PARAMETERS:
 *		NAME		I/O		DESCRIPTION
 *		----		---		-----------
 *
 *	RETURNS: none
 *
 *	COMMENTS:
 *
 *	HISTORY:
 *		1.	13 Mar 93/JVE		Created.
 *
 ****************************************************************************
 */

void computer_hear(KNOWLEDGE knowledge[], char *from, char *text)

{
}

/*
 ****************************************************************************
 *	FUNCTION:	computer_outcome
 *
 *	PURPOSE:	Tells us the result of the hand.
 *
 *	INPUT PARAMETERS:
 *		NAME		I/O		DESCRIPTION
 *		----		---		-----------
 *
 *	RETURNS: none
 *
 *	COMMENTS:
 *
 *	HISTORY:
 *		1.	13 Mar 93/JVE		Created.
 *
 ****************************************************************************
 */

void computer_outcome(KNOWLEDGE knowledge[], int me, int winner)

{
}
