head	1.15;
access;
symbols
	tonic_4:1.15
	tonic_3:1.15
	tonic_2:1.15
	demo:1.15.0.2
	design_report:1.15
	oral_presentation_freeze:1.3.0.2
	DAVEG_CDP:1.2.0.4
	template_integ:1.2.0.2;
locks; strict;
comment	@ * @;


1.15
date	95.12.11.09.24.07;	author hartmans;	state Exp;
branches;
next	1.14;

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

1.13
date	95.12.10.08.29.33;	author daveg;	state Exp;
branches;
next	1.12;

1.12
date	95.12.09.22.36.24;	author daveg;	state Exp;
branches;
next	1.11;

1.11
date	95.12.05.10.45.51;	author hartmans;	state Exp;
branches;
next	1.10;

1.10
date	95.12.04.18.42.13;	author daveg;	state Exp;
branches;
next	1.9;

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

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

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

1.6
date	95.12.01.13.59.12;	author daveg;	state Exp;
branches;
next	1.5;

1.5
date	95.12.01.04.28.16;	author daveg;	state Exp;
branches;
next	1.4;

1.4
date	95.11.30.10.26.44;	author daveg;	state Exp;
branches;
next	1.3;

1.3
date	95.11.30.00.15.11;	author daveg;	state Exp;
branches;
next	1.2;

1.2
date	95.11.22.22.59.24;	author daveg;	state Exp;
branches;
next	1.1;

1.1
date	95.11.20.23.27.47;	author daveg;	state Exp;
branches;
next	;


desc
@@


1.15
log
@bug fixes
@
text
@// This is -*- c++ -*- code

#ifndef __ANTICHESS_BOARD_H__
#define __ANTICHESS_BOARD_H__

#include <6170.h>
#include "chess_display_board.h"
#include <chess_capture_move.h>
#include <chess_capture_move.h>

class antichess_board : public chess_display_board {
    
    // Overview: This class is the actual level at which an antichess
    // board will be seen.  It is a subtype of board and
    // chess_display_board, but actuates their purely virtual methods.

  public:

    // Constructors and Destructors

    antichess_board(istream &initial_format);
    // Effects: Constructs an antichess_board that is not associated
    // with any game.  If initial_format fails to meet the description
    // stated in the design document, this will be initialized to meet
    // the empty board, and calls to initialized_correctly will return
    // false.  Otherwise, the board will correspond to the description
    // in initial_format, and initialized_correctly will return true.

    virtual ~antichess_board();
    // Effects: Frees any resources associated with the antichess_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.


    // Methods

    bool is_legal_move(move &m, int player_num) const;

    game::move_result  apply(move &m, int player_num);

    bool unapply(move &m, int player_num);
    
    int winner();
    
    move_generator * valid_moves(int player_num) const;

    bool valid_move_available(int player_num) const;
    
    bool are_valid_move_available(int player_num, bool check_turn) const;
    // Checks 0 <= player_num < players()
    // Effects: Returns true if this player has valid moves available,
    // checking if it is his turn depending upon the status of
    // check_turn, else returns false.

    value eval_move_delta (int p_pov, move &m, int p_mover) const;
    
    value evaluate( int player_num) const;
    
    board * clone() const;

    long suggest_time(long time_left) const;

    static typeinfo_t typeinfo;
    
    void * force (typeinfo_t &t);

  protected:

    void clone_part(antichess_board &ab) const;
    
  private:

    game::move_result  apply_internal(chess_capture_move *m, int player_num);
    value evaluation;
    
    antichess_board();
    // Effects: Creates a blank antichess_board.
    
    antichess_board(const antichess_board &);
    void operator= (antichess_board &);
};

void add_to_array(chess_capture_move mv,array<chess_capture_move> *forces,
		  array<chess_capture_move> *normal);

#endif
@


1.14
log
@added suggest_time
@
text
@d9 1
@


1.13
log
@added apply_internal
@
text
@d62 2
@


1.12
log
@updated headers, added infinity
@
text
@d72 1
@


1.11
log
@Template fixups
@
text
@d56 1
a56 1
    value eval_move_delta (move &m, int player_num) const;
@


1.10
log
@bug fixes
@
text
@d50 6
@


1.9
log
@bug fixes
@
text
@d75 2
@


1.8
log
@bug fixes
@
text
@d40 1
a40 1
    game::move_result  apply(chess_capture_move &m, int player_num);
d42 1
a42 1
    bool unapply(chess_capture_move &m, int player_num);
d48 1
a48 1
    bool valid_moves_avail(int player_num) const;
d60 4
d67 1
d69 2
@


1.7
log
@Rearrange constructors for chess_capture_move,
provide method to find out who has active turn
@
text
@a45 3
    
    void display(extensions *ext, ostream &body, int player_num) const;
    
@


1.6
log
@finished evaluate
@
text
@d46 1
a46 2
    http_response *get(string request, extensions *extras);

@


1.5
log
@cleanup
@
text
@d66 1
@


1.4
log
@changed stuff
@
text
@d51 2
@


1.3
log
@updated to match board changes
@
text
@d6 1
a6 1
#include <6.170.h>
d8 1
d40 1
a40 1
    game::move_result  apply(move &m, int player_num);
d42 1
a42 1
    bool unapply(move &m, int player_num);
d57 2
d60 1
a60 1
    virtual void * force (typeinfo_t &t);
d63 1
a63 1
    
d67 4
a70 2
    typeinfo_t typeinfo;
}
@


1.2
log
@fixed valid_moves param, added valid_moves_available
@
text
@d37 1
a37 7
    virtual bool is_legal_move(move &m, const player *p) const;
    // 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.
d39 1
a39 12
    virtual game::move_result  apply(move &m, player *p);
    // 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.
d41 5
a45 56
    virtual bool unapply_move(move &m, const player *p);
    // 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. 

    virtual http_response *get(string request, extensions *extras);
    // 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;
    // 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 bool valid_move_available(const player *p) const;
    // Effects: returns true if player p has any current legal moves,
    // returns true, else returns false.

    virtual generator <move> * valid_moves(const player *p) const;
    // 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.

    virtual value eval_move_delta (move &m, const player *p) const;
    // 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;
    // 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.
d47 10
d64 1
a64 1

@


1.1
log
@Version 1.0 of antichess board abstraction
@
text
@d87 5
a91 2
    
    virtual generator <move> * valid_moves() const;
@
