CLAW Library (a C++ Library Absolutely Wonderful) 1.5.5
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Attributes
claw::ai::game::game_state< Action, Numeric > Class Template Reference

A state of a game. More...

#include <game_ai.hpp>

List of all members.

Public Types

typedef Numeric score
 The type used for evaluationg the players' scores.
typedef Action action
 A type representing an action of a player.

Public Member Functions

virtual ~game_state ()
 Destructor.
virtual score evaluate () const =0
 Evaluate this state of the game.
virtual void next_actions (std::list< action > &l) const =0
 Get all actions that can be done from this state.
virtual game_statedo_action (const action &a) const =0
 Get a new state obtained when applying an action.
virtual bool final () const =0
 Tell if the game is over.

Static Public Member Functions

static score min_score ()
 Get the minimal score a state can get.
static score max_score ()
 Get the maximal score a state can get.

Protected Member Functions

score fit (score score_val) const
 Truncate a score to fit in the range (min_score(), max_score()).

Static Protected Attributes

static const score s_min_score
 Minimal score that can be given to a state.
static const score s_max_score
 Maximal score that can be given to a state.

Detailed Description

template<typename Action, typename Numeric = int>
class claw::ai::game::game_state< Action, Numeric >

A state of a game.

Template parameters:

Definition at line 54 of file game_ai.hpp.


Member Typedef Documentation

template<typename Action, typename Numeric = int>
typedef Action claw::ai::game::game_state< Action, Numeric >::action

A type representing an action of a player.

Definition at line 61 of file game_ai.hpp.

template<typename Action, typename Numeric = int>
typedef Numeric claw::ai::game::game_state< Action, Numeric >::score

The type used for evaluationg the players' scores.

Definition at line 58 of file game_ai.hpp.


Constructor & Destructor Documentation

template<typename Action , typename Numeric >
claw::ai::game::game_state< Action, Numeric >::~game_state ( ) [virtual]

Destructor.

Definition at line 42 of file game_ai.tpp.

{
  // nothing to do
} // game_state::~game_state()

Member Function Documentation

template<typename Action, typename Numeric = int>
virtual game_state* claw::ai::game::game_state< Action, Numeric >::do_action ( const action a) const [pure virtual]

Get a new state obtained when applying an action.

Parameters:
aThe action to apply.
Returns:
The state resulting from this action.
template<typename Action, typename Numeric = int>
virtual score claw::ai::game::game_state< Action, Numeric >::evaluate ( ) const [pure virtual]

Evaluate this state of the game.

template<typename Action, typename Numeric = int>
virtual bool claw::ai::game::game_state< Action, Numeric >::final ( ) const [pure virtual]

Tell if the game is over.

template<typename Action , typename Numeric >
claw::ai::game::game_state< Action, Numeric >::score claw::ai::game::game_state< Action, Numeric >::fit ( score  score_val) const [protected]

Truncate a score to fit in the range (min_score(), max_score()).

Parameters:
score_valThe value to fit.

Definition at line 77 of file game_ai.tpp.

{ 
  if ( s_max_score < score_val ) 
    return s_max_score;
  else if ( score_val < s_min_score )
    return s_min_score;
  else
    return score_val;
} // game_state::fit()
template<typename Action , typename Numeric >
claw::ai::game::game_state< Action, Numeric >::score claw::ai::game::game_state< Action, Numeric >::max_score ( ) [static]

Get the maximal score a state can get.

Definition at line 64 of file game_ai.tpp.

{
  return s_max_score; 
} // game_state::max_score()
template<typename Action , typename Numeric >
claw::ai::game::game_state< Action, Numeric >::score claw::ai::game::game_state< Action, Numeric >::min_score ( ) [static]

Get the minimal score a state can get.

Definition at line 53 of file game_ai.tpp.

{
  return s_min_score; 
} // game_state::min_score()
template<typename Action, typename Numeric = int>
virtual void claw::ai::game::game_state< Action, Numeric >::next_actions ( std::list< action > &  l) const [pure virtual]

Get all actions that can be done from this state.

Parameters:
l(out) The actions.

Member Data Documentation

template<typename Action, typename Numeric = int>
const score claw::ai::game::game_state< Action, Numeric >::s_max_score [static, protected]

Maximal score that can be given to a state.

Definition at line 96 of file game_ai.hpp.

template<typename Action, typename Numeric = int>
const score claw::ai::game::game_state< Action, Numeric >::s_min_score [static, protected]

Minimal score that can be given to a state.

Definition at line 93 of file game_ai.hpp.


The documentation for this class was generated from the following files: