head	1.28;
access;
symbols
	tonic_4:1.28
	tonic_3:1.28
	tonic_2:1.28
	demo:1.28.0.2
	design_report:1.28
	oral_presentation_freeze:1.20.0.2
	DAVEG_CDP:1.16.0.2
	template_integ:1.15.0.2;
locks; strict;
comment	@ * @;


1.28
date	95.12.11.08.21.06;	author daveg;	state Exp;
branches;
next	1.27;

1.27
date	95.12.09.23.25.02;	author daveg;	state Exp;
branches;
next	1.26;

1.26
date	95.12.09.22.36.27;	author daveg;	state Exp;
branches;
next	1.25;

1.25
date	95.12.09.07.54.54;	author daveg;	state Exp;
branches;
next	1.24;

1.24
date	95.12.05.10.54.07;	author daveg;	state Exp;
branches;
next	1.23;

1.23
date	95.12.03.05.00.42;	author hartmans;	state Exp;
branches;
next	1.22;

1.22
date	95.12.02.05.58.51;	author hartmans;	state Exp;
branches;
next	1.21;

1.21
date	95.12.01.23.03.02;	author hartmans;	state Exp;
branches;
next	1.20;

1.20
date	95.11.30.06.32.11;	author hartmans;	state Exp;
branches;
next	1.19;

1.19
date	95.11.30.05.03.55;	author jered;	state Exp;
branches;
next	1.18;

1.18
date	95.11.28.04.47.37;	author hartmans;	state Exp;
branches;
next	1.17;

1.17
date	95.11.28.03.31.23;	author hartmans;	state Exp;
branches;
next	1.16;

1.16
date	95.11.24.17.07.07;	author hartmans;	state Exp;
branches
	1.16.2.1;
next	1.15;

1.15
date	95.11.23.05.07.36;	author hartmans;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	95.11.22.22.58.24;	author daveg;	state Exp;
branches;
next	1.13;

1.13
date	95.11.21.07.38.44;	author jered;	state Exp;
branches;
next	1.12;

1.12
date	95.11.21.05.22.49;	author hartmans;	state Exp;
branches;
next	1.11;

1.11
date	95.11.21.03.46.48;	author jered;	state Exp;
branches;
next	1.10;

1.10
date	95.11.21.00.00.48;	author jered;	state Exp;
branches;
next	1.9;

1.9
date	95.11.20.08.14.01;	author daveg;	state Exp;
branches;
next	1.8;

1.8
date	95.11.20.08.10.18;	author daveg;	state Exp;
branches;
next	1.7;

1.7
date	95.11.20.00.52.43;	author hartmans;	state Exp;
branches;
next	1.6;

1.6
date	95.11.19.22.44.39;	author hartmans;	state Exp;
branches;
next	1.5;

1.5
date	95.11.19.21.56.24;	author hartmans;	state Exp;
branches;
next	1.4;

1.4
date	95.11.19.19.49.44;	author jered;	state Exp;
branches;
next	1.3;

1.3
date	95.11.19.17.23.50;	author hartmans;	state Exp;
branches;
next	1.2;

1.2
date	95.11.19.17.22.01;	author hartmans;	state Exp;
branches;
next	1.1;

1.1
date	95.11.19.04.13.44;	author hartmans;	state Exp;
branches;
next	;

1.15.2.1
date	95.11.24.05.53.59;	author hartmans;	state Exp;
branches;
next	;

1.16.2.1
date	95.11.28.03.41.58;	author hartmans;	state Exp;
branches;
next	;


desc
@description of abstract board
@


1.28
log
@added suggest_time
@
text
@// This is -*- c++ -*- code


// $Id: board.h,v 1.27 1995/12/09 23:25:02 daveg Exp $


#ifndef __BOARD_H__ 
#define __BOARD_H__

#include <6170.h>
#include <limits.h>
#include <typeinfo.h>
#include <ps5/web_node.h>

#include "game.h"
#include "move_generator.h"

class move;

class board: public web_node {
  // Overview: This class represents the abstract interface of a
  // game board required by the game and player abstractions.
  
  // This is a heap abstraction
  
public:
// Constructors and destructors:

  board();
  // Effects:  Constructs a board that is not associated with any game.
  
  virtual ~board();
  // Effects: Frees any resources associated with the board.
  // Because garbage collection is performed, calling this
  // destructor is not strictly necessary, but if it is known that a
  // board wil not be needed, destroying it may avoid heap
  // fragmentation.

  virtual bool is_associated() const;
  // Effects: Returns true if this board is associated with a game.


    virtual bool is_legal_move(move &m, int player_num) const = 0 ;
  // Checks: 0 <= player_num < players()
  // Effects: return true if m is a move compatible with this type
  // of board and player player_num (from game) applying m to this board in the current
  // state would be legal, else return false. If this is not
  // associated with a game, the return value is undefined, but this
  // shall remain in a well-defined state.  This method does not
  // expect m to exist after the call.
  
    virtual game::move_result  apply(move &m, int player_num) = 0;
    // Checks: 0 <= player_num < players()
    // Modifies: this
  // Effects: applies m to this if possible, or
  // returns a failure reason.  The applicability of m shall be
  // defined by the rules of the game this implements and the
  // current state of this.  If is_legal_move(m, p) is true, then m
  // must be applicable If m is
  // applied, returns ok In no event shall m be assumed to exist
  // beyond the call to apply.  Apply will not call any non-const
  // methods of game.  It is illegal to return game_already_done.
  

  virtual bool unapply(move &m, int player_num) = 0;
  // Checks: 0 <= player_num < players()
  // Modifies: this
  // Requires: m is the last move that was applied to this by player player_num
  // Effects: Reverts this to the state before m was applied if
  // possible, returning true, else returns false.  The behavior is
  // undefined if m isn't the most-recent move applied to this,
  // although after m is unapplied, the move applied before m is
  // most recent.  I.E.  If a series of moves is applied then
  // unapplied, unapply must either unapply the move, modifying
  // this, or return false, leaving this unchanged.  However, if a
  // move three moves back is unapplied, the behavior is completely
  // undefined.  Unapply_move will not call any non-const methods of
  // game.   Unapply must return true and successfully a move just after a call to apply.
  // I.E.  It must be possible to write a machine player that examines the
  // effect of applying moves then unapplies them if the results are not desirable.
  
  virtual int winner() = 0;
  // Modifies: this
  // Effects: Checks to see if the game has been won.  If so,
  // returns the player who won the game, else returns -1.  If the game is a draw, returns -2.
  // Note that
  // successful unapplication can revert this to -1.
  // Requires: There must be
  // no valid moves for any players if winner() is non-null.
  

  virtual http_response *get(string request, extensions *extras) = 0;
  // Modifies: this, and possibly players and games associated with
  // this
  // Effects: Processes a web request as defined by the
  // protocol for the game this implements.  Requests defined in
  // Section \tex{\ref{p:board}} must be implemented. If a move is returned
  // by the request, game::apply shall be called; in no other
  // event shall an object outside of this be modified.  If the
  // request is not supported, an error is returned.  It is always
  // an error to make a web request of a board not associated with a
  // particular game.
  
  virtual void display(extensions *ext, ostream &body, int player_num) const = 0;
  // Checks: 0 <= player_num < players()
  // Effects: returns an html representation of this from the point of 
  // view of player_num.  The headers
  // in extensions (if extensions is non-null) can be used to
  // determine the capabilities of the web client.
  
  virtual bool valid_move_available( int player_num) const = 0;
  // Checks: 0 <= player_num < players()
  // Effects: returns true if player p has any current legal moves,
  // returns true, else returns false.


  virtual  move_generator * valid_moves(int player_num) const = 0 ;
// Checks: 0 <= player_num < players()
  // Effects: returns a generator that returns in arbitrary order
  // the valid moves for player p at this point; if p cannot
  // currently move, then the generator will initially be empty.
  // The generator returns valid moves only once.
  // Requires: the generator not be used after apply is used, the generator be deleted
  // when no longer needed.
  
  // Type for static evaluator values:
  typedef long value;
  const value infinity = LONG_MAX;

  virtual value eval_move_delta (int p_pov, move &, int p_mover) const = 0;
  // Checks: 0 <= p_pov, p_mover < players()
  // Effects: returns the change in value from p_pov's point of view,
  // after the given move was applied by player p_mover.
 
  
  virtual value evaluate( int player1) const = 0;
    // Checks: 0 <= player_num < players()
  // Effects: returns a static evaluation of the currentate.  A value
  // of 0 indicates that player p is tied with other players or not
  // involved in the game represented by board.  A positive value
  // indicates that player p is ahead of other players--the more
  // positive the value, the farther ahead player p is.  A negative
  // value indicates that p is behind other players; the more
  // negative the value, the farther behind.  Ideally, the values
  // will be scaled such that winning the game results in
  // approximately the largest value representable in value, but this
  // is not required.


  virtual board * clone() const = 0 ;
  // Effects: Returns a cloned board of this.  (See design document
  // for implications of cloning).
  // Implementation-comment:  To implement this method, see the protected method clone_part.
    
  bool is_clone() const;
  // Effects: returns true if this is a clone else false.
    
  virtual long suggest_time(long time_left) const = 0;
    // Effects: Returns an amount of time appropriate to spend on a
    // move during this turn.
  
  virtual void * force (typeinfo_t &t) = 0;

  virtual const void *force(typeinfo_t &type) const;
    

protected:
  virtual void associate( game *g);
  // Modifies: this 
  // Effects: Associates this with a particular game.
  // This method should only be called by game::game or overiding methods in subclasses, and never by
  // using code.  A board that is not associated with a particular
  // game can be used, but no web requests can be sent to it.
  // Associate will not call any non-const methods of game.
  
friend game::game(board *b, player *p1, player *p2, string uri, 
		  string image_base, bool player1_is_default);
  //friendship-extent: game::game is a friend of board so it can
  //call board::associate.  game::game shall not access other
  //private or protected methods or state of board.

    game * get_game() const;
    // Effects: returns a pointer to game so that web requests and
    // other methods of board and subtypes of board can find the game this is
    //  associated with.  If this is not associated, returns null.

    void clone_part (board &b) const;
    // Effects Copies state into b from this as appropriate for a
    // clone of b.  To implement clone, construct the right board,
// then call the clone_part of the implementing subclass.
        // Modifies: b

    
private:
  void operator = (const board &);
  board(const board &);
  
  // Abstraction function: The only permanent state at this level of
  // the class hierarchy is the association with a particular game; g
  // contains a pointer to this game.  In addition, i_am_clone returns
  // true if and only if the clone method was used to prduce this.
  
  // Rep invariant: If g is non-null, g->get_board() == this
  game *g;
    bool i_am_clone;
};

inline bool board::is_associated()const  {return g != 0;}

inline game * board::get_game() const {return g;};

inline bool board::is_clone() const {return i_am_clone;}

#endif
@


1.27
log
@fixed previous commit
@
text
@d4 1
a4 1
// $Id: board.h,v 1.26 1995/12/09 22:36:27 daveg Exp $
d158 4
a161 2


d208 1
a208 1
inline bool board::is_associated()const  {return g == 0;}
@


1.26
log
@updated headers, added infinity
@
text
@d4 1
a4 1
// $Id: board.h,v 1.25 1995/12/09 07:54:54 daveg Exp $
d128 1
a128 1

@


1.25
log
@changed eval_move_delta header
@
text
@d4 1
a4 1
// $Id: board.h,v 1.24 1995/12/05 10:54:07 daveg Exp $
d11 1
@


1.24
log
@bug fix
@
text
@d4 1
a4 1
// $Id: board.h,v 1.23 1995/12/03 05:00:42 hartmans Exp $
d129 5
a133 6
  virtual value eval_move_delta (move &m, int player_num) const = 0;
  // Checks: 0 <= p < players()
  // Effects: returns the change in the static value of player p
  // applying m to this.  If m applied by p is not applicable, then
  // zero is returned.  
// Checks: 0 <= p < players()
d135 1
a135 1
  virtual value evaluate( int player_num) const = 0;
@


1.23
log
@Tidy up human_player,
implement machine_player::get

clarify associate specs.
@
text
@d4 1
a4 1
// $Id: board.h,v 1.22 1995/12/02 05:58:51 hartmans Exp $
d104 3
a106 2
// Checks: 0 <= player_num < players()
  // Effects: returns an html representation of this from the point of view of player_num.  The headers
d111 1
a111 1
// Checks: 0 <= player_num < p
@


1.22
log
@Fix errors bringing in David's changes.
@
text
@d4 1
a4 1
// $Id: board.h,v 1.21 1995/12/01 23:03:02 hartmans Exp $
d168 1
a168 1
  // This method should only be called by game::game, and never by
d174 1
a174 1
		  bool player1_is_default);
@


1.21
log
@Integrate Antichess boarrd from DAVEG_CPD
@
text
@d4 1
a4 1
// $Id: board.h,v 1.20 1995/11/30 06:32:11 hartmans Exp $
d51 3
a53 8
<<<<<<< board.h
  virtual game::move_result  apply(move &m, int player_num) = 0;
  // Checks: 0 <= player_num < players()
=======
  virtual game::move_result  apply(move &m, int player_num) = 0;
// Checks: 0 <= player_num < players()
>>>>>>> 1.16.2.1
  // Modifies: this
@


1.20
log
@Fix bugs so it builds
@
text
@a2 1
// $Id: board.h,v 1.19 1995/11/30 05:03:55 jered Exp $
d4 3
d41 2
a42 1
  virtual bool is_legal_move(move &m, int player_num) const = 0 ;
d51 1
d54 4
d68 1
d119 1
d132 1
d138 1
d153 1
d162 2
@


1.19
log
@Added machine_player.{h,C}. Other minor things.
@
text
@d3 1
a3 1
// $Id: board.h,v 1.18 1995/11/28 04:47:37 hartmans Exp $
d146 1
a146 1
  bool is_cloned() const;
d174 1
a174 1
    voide clone_part (board &b) const;
d197 1
a197 1
inline game * board::get_game() const {return g};
@


1.18
log
@Integrate move_generator
@
text
@d3 1
a3 1
// $Id: board.h,v 1.17 1995/11/28 03:31:23 hartmans Exp $
d40 1
a40 1
// Checks: 0 <= player_num < players()
d49 1
a49 1
// Checks: 0 <= player_num < players()
d61 1
a61 1
// Checks: 0 <= player_num < players()
d123 1
a126 1
// Checks: 0 <= p < players()
d141 4
a144 7
    virtual board * clone() const = 0 ;
    // Effects: Returns a cloned board of this.  (See design document
    // for implications of cloning).
    // Implementation-comment:  To implement this method, see the protected method clone_part.
    
    bool is_cloned() const;
    // Effects: returns true if this is a clone else false.
d146 2
d151 1
a151 1
    virtual const void *force(typeinfo_t &type) const;
@


1.17
log
@Change players to be indexes, add a few new methods.
@
text
@d3 1
a3 1
// $Id: board.h,v 1.16 1995/11/24 17:07:07 hartmans Exp $
d13 2
d110 1
a110 1
  virtual generator <move *> * valid_moves(int player_num) const = 0 ;
@


1.16
log
@Add prototype for const force method to board,
fix bug in move.h.

(These are the changes I accidentally checked on on template_inetg)
@
text
@d3 1
a3 1
// $Id: board.h,v 1.15.2.1 1995/11/24 05:53:59 hartmans Exp $
d14 1
a14 1
class player;
d37 2
a38 1
  virtual bool is_legal_move(move &m, const player *p) const = 0 ;
d40 1
a40 1
  // of board and player p applying m to this board in the current
d46 2
a47 1
  virtual game::move_result  apply(move &m, const player *p) = 0;
d58 2
a59 1
  virtual bool unapply(move &m, const player *p) = 0;
d61 1
a61 1
  // Requires: m is the last move that was applied to this by p
d75 1
a75 1
  virtual player *winner() = 0;
d78 3
a80 2
  // returns the player who won the game, else returns 0.  Note that
  // successful unapplication can revert this pointer to null.
d89 3
a91 2
  // protocol for the game this implements.  If a move is returned
  // by the request, game::apply_move shall be called; in no other
d97 3
a99 2
  virtual void display(extensions *ext, ostream &body) const = 0;
  // Effects: returns an html representation of this.  The headers
d103 2
a104 1
  virtual bool valid_move_available(const player *p) const = 0;
d108 2
a109 1
  virtual generator <move *> * valid_moves(const player *p) const = 0 ;
d120 1
a120 1
  virtual value eval_move_delta (move &m, const player *p) const = 0;
d124 1
d126 2
a127 1
  virtual value evaluate(const player *p) const = 0;
d138 10
a147 1
  
d152 1
d167 13
a179 1
  
d185 3
a187 2
  // the class hierarchy is the association with a particular game;
  // g contains a pointer to this game.
d191 1
d196 4
@


1.16.2.1
log
@Merge in most of my changes so diff is cleaner
@
text
@d3 1
a3 1
// $Id: board.h,v 1.17 1995/11/28 03:31:23 hartmans Exp $
d14 1
a14 1

d37 1
a37 2
  virtual bool is_legal_move(move &m, int player_num) const = 0 ;
// Checks: 0 <= player_num < players()
d39 1
a39 1
  // of board and player player_num (from game) applying m to this board in the current
d45 1
a45 2
  virtual game::move_result  apply(move &m, int player_num) = 0;
// Checks: 0 <= player_num < players()
d56 1
a56 2
  virtual bool unapply(move &m, int player_num) = 0;
// Checks: 0 <= player_num < players()
d58 1
a58 1
  // Requires: m is the last move that was applied to this by player player_num
d72 1
a72 1
  virtual int winner() = 0;
d75 2
a76 3
  // returns the player who won the game, else returns -1.  If the game is a draw, returns -2.
  // Note that
  // successful unapplication can revert this to -1.
d85 2
a86 3
  // protocol for the game this implements.  Requests defined in
  // Section \tex{\ref{p:board}} must be implemented. If a move is returned
  // by the request, game::apply shall be called; in no other
d92 2
a93 3
  virtual void display(extensions *ext, ostream &body, int player_num) const = 0;
// Checks: 0 <= player_num < players()
  // Effects: returns an html representation of this from the point of view of player_num.  The headers
d97 1
a97 2
  virtual bool valid_move_available( int player_num) const = 0;
// Checks: 0 <= player_num < p
d101 1
a101 2
  virtual generator <move *> * valid_moves(int player_num) const = 0 ;
// Checks: 0 <= player_num < players()
d112 1
a112 1
  virtual value eval_move_delta (move &m, int player_num) const = 0;
a115 1
// Checks: 0 <= p < players()
d117 1
a117 2
  virtual value evaluate( int player_num) const = 0;
    // Checks: 0 <= player_num < players()
d128 1
a128 10

    virtual board * clone() const = 0 ;
    // Effects: Returns a cloned board of this.  (See design document
    // for implications of cloning).
    // Implementation-comment:  To implement this method, see the protected method clone_part.
    
    bool is_cloned() const;
    // Effects: returns true if this is a clone else false.
    
    
a132 1

d147 1
a147 13

    game * get_game() const;
    // Effects: returns a pointer to game so that web requests and
    // other methods of board and subtypes of board can find the game this is
    //  associated with.  If this is not associated, returns null.

    voide clone_part (board &b) const;
    // Effects Copies state into b from this as appropriate for a
    // clone of b.  To implement clone, construct the right board,
// then call the clone_part of the implementing subclass.
        // Modifies: b

    
d153 2
a154 3
  // the class hierarchy is the association with a particular game; g
  // contains a pointer to this game.  In addition, i_am_clone returns
  // true if and only if the clone method was used to prduce this.
a157 1
    bool i_am_clone;
a161 4
inline game * board::get_game() const {return g};

inline bool board::is_clone() const {return i_am_clone;}

@


1.15
log
@Lots of changes as per our discussions.
@
text
@d3 1
a3 1
// $Id: board.h,v 1.14 1995/11/22 22:58:24 daveg Exp $
d131 1
a131 1
    virtual void *force(typeinfo_t &type) const;
@


1.15.2.1
log
@Add support for no-implicit-templates
and build ../lib/libbase.a
@
text
@d3 1
a3 1
// $Id: board.h,v 1.15 1995/11/23 05:07:36 hartmans Exp $
d131 1
a131 1
    virtual const void *force(typeinfo_t &type) const;
@


1.14
log
@fixed valid_moves param, added valid_moves_available
@
text
@d3 1
a3 1
// $Id: board.h,v 1.13 1995/11/21 07:38:44 jered Exp $
d45 2
a46 2
  virtual game::move_result  apply(move &m, player *p) = 0;
  // Modifies: this, p
d51 1
a51 3
  // must be applicable.  If m is applicable, p is not modified;
  // otherwise, p may be modified to assess a penalty.  If m is not
  // applicable, this may be modified to assess a penalty.  If m is
d54 1
a54 1
  // methods of game.
d57 1
a57 1
  // Modifies: this, p
d68 3
a70 3
  // game. It is never legal for a board to return
  // game_already_won; in this state, the board should return
  // invalid_move.
d83 2
a84 1
  // this Effects: Processes a web request as defined by the
d106 2
a107 1
  // Requires: the generator not be used after apply is used.
d115 1
a115 1
  // zero is returned.
d131 2
@


1.13
log
@Fixed some fill and spacing stuff, other minor things in board, test_board.
@
text
@d3 1
a3 1
// $Id: board.h,v 1.12 1995/11/21 05:22:49 hartmans Exp $
d98 5
a102 1
  virtual generator <move *> * valid_moves() const = 0 ;
@


1.12
log
@Lots of fixes to make stuff compile
@
text
@d3 1
a3 1
// $Id: board.h,v 1.11 1995/11/21 03:46:48 jered Exp $
d16 6
a21 8

    // Overview: This class represents the abstract interface of a
    // game board required by the game and player abstractions.
    
    // This is a heap abstraction

    public:

d24 102
a125 101
    board();
    // Effects:  Constructs a board that is not associated with any game.
    virtual ~board();
    // Effects: Frees any resources associated with the board.
    // Because garbage collection is performed, calling this
    // destructor is not strictly necessary, but if it is known that a
    // board wil not be needed, destroying it may avoid heap
    // fragmentation.

    virtual bool is_associated() const;
    // Effects: Returns true if this board is associated with a game.

    virtual bool is_legal_move(move &m, const player *p) const = 0 ;
    // Effects: return true if m is a move compatible with this type
    // of board and player p applying m to this board in the current
    // state would be legal, else return false. If this is not
    // associated with a game, the return value is undefined, but this
    // shall remain in a well-defined state.  This method does not
    // expect m to exist after the call.

    virtual game::move_result  apply(move &m, player *p) = 0;
    // Modifies: this, p
    // Effects: applies m to this if possible, or
    // returns a failure reason.  The applicability of m shall be
    // defined by the rules of the game this implements and the
    // current state of this.  If is_legal_move(m, p) is true, then m
    // must be applicable.  If m is applicable, p is not modified;
    // otherwise, p may be modified to assess a penalty.  If m is not
    // applicable, this may be modified to assess a penalty.  If m is
    // applied, returns ok In no event shall m be assumed to exist
    // beyond the call to apply.  Apply will not call any non-const
    // methods of game.

    virtual bool unapply(move &m, const player *p) = 0;
    // Modifies: this, p
    // Requires: m is the last move that was applied to this by p
    // Effects: Reverts this to the state before m was applied if
    // possible, returning true, else returns false.  The behavior is
    // undefined if m isn't the most-recent move applied to this,
    // although after m is unapplied, the move applied before m is
    // most recent.  I.E.  If a series of moves is applied then
    // unapplied, unapply must either unapply the move, modifying
    // this, or return false, leaving this unchanged.  However, if a
    // move three moves back is unapplied, the behavior is completely
    // undefined.  Unapply_move will not call any non-const methods of
    // game. It is never legal for a board to return
    // game_already_won; in this state, the board should return
    // invalid_move.

    virtual player *winner() = 0;
    // Modifies: this
    // Effects: Checks to see if the game has been won.  If so,
    // returns the player who won the game, else returns 0.  Note that
// successful unapplication can revert this pointer to null.
// Requires: There must be
// no valid moves for any players if winner() is non-null.


    virtual http_response *get(string request, extensions *extras) = 0;
    // Modifies: this, and possibly players and games associated with
    // this Effects: Processes a web request as defined by the
    // protocol for the game this implements.  If a move is returned
    // by the request, game::apply_move shall be called; in no other
    // event shall an object outside of this be modified.  If the
    // request is not supported, an error is returned.  It is always
    // an error to make a web request of a board not associated with a
    // particular game.

    virtual void display(extensions *ext, ostream &body) const = 0;
    // Effects: returns an html representation of this.  The headers
    // in extensions (if extensions is non-null) can be used to
    // determine the capabilities of the web client.

    virtual generator <move *> * valid_moves() const = 0 ;
    // Effects: returns a generator that returns in arbitrary order
    // the valid moves for player p at this point; if p cannot
    // currently move, then the generator will initially be empty.
    // The generator returns valid moves only once.
    // Requires: the generator not be used after apply is used.

    // Type for static evaluator values:
    typedef long value;

    virtual value eval_move_delta (move &m, const player *p) const = 0;
    // Effects: returns the change in the static value of player p
    // applying m to this.  If m applied by p is not applicable, then
    // zero is returned.

    virtual value evaluate(const player *p) const = 0;
    // Effects: returns a static evaluation of the currentate.  A value
    // of 0 indicates that player p is tied with other players or not
    // involved in the game represented by board.  A positive value
    // indicates that player p is ahead of other players--the more
    // positive the value, the farther ahead player p is.  A negative
    // value indicates that p is behind other players; the more
    // negative the value, the farther behind.  Ideally, the values
    // will be scaled such that winning the game results in
    // approximately the largest value representable in value, but this
    // is not required.

    virtual void * force (typeinfo_t &t) = 0;
d128 14
a141 13
    virtual void associate( game *g);
    // Modifies: this 
    // Effects: Associates this with a particular game.
    // This method should only be called by game::game, and never by
    // using code.  A board that is not associated with a particular
    // game can be used, but no web requests can be sent to it.
    // Associate will not call any non-const methods of game.

    friend game::game(board *b, player *p1, player *p2, string uri, bool player1_is_default);
    //friendship-extent: game::game is a friend of board so it can
    //call board::associate.  game::game shall not access other
    //private or protected methods or state of board.

d143 9
a151 12
    void operator = (const board &);
    board(const board &);
    
    // Abstraction function: The only permanent state at this level of
    // the class hierarchy is the association with a particular game;
    // g contains a pointer to this game.

    // Rep invariant: If g is non-null, g->get_board() == this
    game *g;
    

    
@


1.11
log
@Changed board unapply_move to unapply,
added test directory for test game.
@
text
@d3 1
a3 1
// $Id: board.h,v 1.10 1995/11/21 00:00:48 jered Exp $
d19 1
d21 3
a23 1
    
d71 12
a82 1
    // game. 
d157 1
a157 1
inline bool board::is_associated()const  {return g == 0};
@


1.10
log
@Revised player to associate with a board, other piddly changes.
@
text
@d3 1
a3 1
// $Id$
d56 1
a56 1
    virtual bool unapply_move(move &m, const player *p) = 0;
d85 1
a85 1
    virtual generator <move> * valid_moves() const = 0 ;
@


1.9
log
@Modified Effects clause of apply and unappy_move
@
text
@d3 1
a3 23
<<<<<<< board.h
<<<<<<< board.h
<<<<<<< board.h
<<<<<<< board.h
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
||||||| 1.4
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
=======
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
>>>>>>> /tmp/T4a02612
||||||| 1.5
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
=======
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
>>>>>>> /tmp/T4a02694
||||||| 1.6
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
=======
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
>>>>>>> /tmp/T4a02831
=======
// $Id: board.h,v 1.8 1995/11/20 08:10:18 daveg Exp $
>>>>>>> 1.7
a13 1

a31 1

a84 1
    
d136 1
a136 1
    // Rep invarient: If g is non-null, g->get_board() == this
@


1.8
log
@Modified Effects clause of associate
@
text
@d7 1
a7 1
// $Id: board.h,v 1.1 95/11/19 04:13:44 hartmans Exp $
d9 1
a9 1
// $Id: board.h,v 1.1 1995/11/19 04:13:44 hartmans Exp $
d11 1
a11 1
// $Id: board.h,v 1.4 1995/11/19 19:49:44 jered Exp $
d14 1
a14 1
// $Id: board.h,v 1.4 1995/11/19 19:49:44 jered Exp $
d16 1
a16 1
// $Id: board.h,v 1.5 1995/11/19 21:56:24 hartmans Exp $
d19 1
a19 1
// $Id: board.h,v 1.5 1995/11/19 21:56:24 hartmans Exp $
d21 1
a21 1
// $Id: board.h,v 1.6 1995/11/19 22:44:39 hartmans Exp $
d24 1
a24 1
// $Id: board.h,v 1.7 1995/11/20 00:52:43 hartmans Exp $
d68 2
a69 1
    // Modifies: this, p Effects: applies m to this if possible, or
d77 2
a78 1
    // beyond the call to apply..
d91 2
a92 1
    // undefined.
@


1.7
log
@Support and changes for game
@
text
@d3 18
d22 4
d137 3
a139 2
        virtual void associate( game *g);
    // modifies: this Effects: Associates this with a particular game.
d142 2
a143 1
    // game can be used, but no web requests can be sent to it.  
@


1.6
log
@Add inline methods and private section
@
text
@d3 1
a3 1
// $Id: board.h,v 1.5 1995/11/19 21:56:24 hartmans Exp $
d42 2
a43 1
    // shall remain in a well-defined state.
d46 1
a46 2
    // Modifies: this, p
    // Effects: applies m to this if possible, or
d52 3
a54 1
    // applicable, this may be modified to assess a penalty.  If m is applied, returns ok.
@


1.5
log
@Add move.h and move board::associate as protected
@
text
@d3 1
a3 1
// $Id: board.h,v 1.4 1995/11/19 19:49:44 jered Exp $
d13 2
d123 13
d139 1
d141 1
@


1.4
log
@Fixed some speeling and fill errors, virtualized evaluate, and changed
display routines to use ostreams. (And changed get_info to display)
@
text
@d3 1
a3 1
// $Id: board.h,v 1.3 1995/11/19 17:23:50 hartmans Exp $
a30 5
    virtual void associate( game *g);
    // modifies: this Effects: Associates this with a particular game.
    // This method should only be called by game::game, and never by
    // using code.  A board that is not associated with a particular
    // game can be used, but no web requests can be sent to it.  
d108 8
a115 1
    void * force (typeinfo_t &t);
d117 4
a120 1
    static typeinfo_t typeinfo;
@


1.3
log
@Oops, forgot to save board before commit
@
text
@d3 1
a3 1
// $Id: board.h,v 1.1 1995/11/19 04:13:44 hartmans Exp $
d80 1
a80 1
    virtual string display( extensions *ext) const = 0;
d101 1
a101 1
    value evaluate(const player *p) const;
@


1.2
log
@player.h: random cleanup, optionalize postion, take time arugment to set_time
board.h: add force method, random cleanup
@
text
@d10 1
a10 1
#include <ps5/web_server.h>
@


1.1
log
@Add preliminary board abstraction.
Update game to work with board.
@
text
@d3 1
a3 1
// $Id$
d9 2
a11 2
#include <web_server.h>

d35 1
a35 1
    // game can be used, but no web requests can be sent to it.
d69 1
d113 4
d118 2
@
