head	1.5;
access;
symbols
	tonic_4:1.5
	tonic_3:1.5
	tonic_2:1.5
	demo:1.5.0.2
	design_report:1.5
	oral_presentation_freeze:1.4.0.2
	DAVEG_CDP:1.1.0.2;
locks; strict;
comment	@ * @;


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

1.4
date	95.11.30.07.16.26;	author jered;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	95.11.30.05.04.10;	author jered;	state Exp;
branches;
next	1.2;

1.2
date	95.11.28.03.01.48;	author jered;	state Exp;
branches;
next	1.1;

1.1
date	95.11.26.04.20.51;	author jered;	state Exp;
branches;
next	;

1.4.2.1
date	95.11.30.08.35.28;	author hartmans;	state Exp;
branches;
next	1.4.2.2;

1.4.2.2
date	95.11.30.08.49.56;	author jered;	state Exp;
branches;
next	1.4.2.3;

1.4.2.3
date	95.11.30.09.25.33;	author hartmans;	state Exp;
branches;
next	;


desc
@@


1.5
log
@Integrate oral presentation changes into main line.
@
text
@// This is -*- c++ -*- code

// $Id: tic_board.h,v 1.4.2.3 1995/11/30 09:25:33 hartmans Exp $

#ifndef __TIC_BOARD_H__
#define __TIC_BOARD_H__

#include <6170.h>
#include <typeinfo.h>
#include "board.h"

class tic_board : public board {
  // Overview: This class is a subtype of class board, for the purpose of
  // playing the game tic-tac-toe.  This is not a virtual subclass, it can be
  // instantiated. This is a heap abstraction. Valid positions are 'X' and 'O'
  // X always goes first.

  public:
    enum tic_piece {                      // Tic-tac-toe pieces
      no_piece,
      x_piece,
      o_piece
      };

    // Constructors and Destructors

    tic_board();
    // Effects: Constructs a tic_board that is not
    // associated with any game.  

    virtual ~tic_board();
    // Effects: Destroys anything in need of destroying. :-)

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

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

    virtual bool unapply(move &m, int player_num);

    virtual int winner();

    virtual http_response *get(string request, extensions *extras);

    virtual void display(extensions *ext, ostream& body, 
			 int player_num) const;

    virtual bool valid_move_available(int player_num) const;

    virtual move_generator* valid_moves(int player_num) const;

    virtual board::value eval_move_delta(move &m, int player_num) const;

    virtual board::value evaluate(int player_num) const;

    virtual board * clone() const;

    virtual void* force (typeinfo_t &t);

//Subclass specific methods:
    static char piece_to_name(tic_piece cpiece);
    // Effects: Returns a char corresponding to the piece cpiece.
 
    static tic_piece player_to_piece(int p);
    // Effects: Returns a piece corresponding to a player, or
    // no_piece if a player isn't mapped

    static int piece_to_player(tic_piece t);

    int check_for_winner();
    // Effects: Checks the board, if a winning player exists, returns
    // the index of the winning player. If the game is not over, returns
    // NULL. If the game has ended in a draw, returns a pointer to
    // the drawn_player. FIXME

    static typeinfo_t typeinfo;

  protected:
    virtual void associate(game *g);

    void clone_part(tic_board &b) const;
    
  private:
    void operator= (tic_board &);
    array<array <tic_piece> > board_rep;      // The tic-tac-toe board
    int won_player;                          // The player who has won
    int turn_token;                          // Player number
};
#endif
@


1.4
log
@Did enough that tic_board should work now.
@
text
@d3 1
a3 1
// $Id: tic_board.h,v 1.3 1995/11/30 05:04:10 jered Exp $
d81 2
d85 1
a85 1
    array<array <tic_piece>> board_rep;      // The tic-tac-toe board
@


1.4.2.1
log
@Make it compile if not link
@
text
@d3 1
a3 1
// $Id: tic_board.h,v 1.4 1995/11/30 07:16:26 jered Exp $
d83 1
a83 1
    array<array <tic_piece> > board_rep;      // The tic-tac-toe board
@


1.4.2.2
log
@Fixed clone, clone_part on tic_board.
@
text
@d3 1
a3 1
// $Id: tic_board.h,v 1.4.2.1 1995/11/30 08:35:28 hartmans Exp $
a80 2
    void clone_part(board &b) const;
    
@


1.4.2.3
log
@Fix typo
@
text
@d3 1
a3 1
// $Id: tic_board.h,v 1.4.2.2 1995/11/30 08:49:56 jered Exp $
d81 1
a81 1
    void clone_part(tic_board &b) const;
@


1.3
log
@Added machine_player.{h,C}. Other minor things.
@
text
@d3 1
a3 1
// $Id: tic_board.h,v 1.2 1995/11/28 03:01:48 jered Exp $
d13 4
a16 5
 
    // Overview: This class is a subtype of class board, for the purpose of
    // playing the game tic-tac-toe.  This is not a virtual subclass, it can be
    // instantiated. This is a heap abstraction. Valid positions are 'X' and 'O'.
    // X always goes first.
d43 1
a43 2
    virtual http_response *get(string request, extensions *extras,
			       int player_num);
d45 2
a46 1
    virtual void display(extensions *ext, ostream& body) const;
d50 1
a50 1
    virtual generator <move *> * valid_moves(int player_num) const;
d52 1
a52 1
    virtual board::value eval_move_delta(move &m, const int player_num) const;
a57 3
    virtual player *winner();
    // Effects: See board.h

a59 1
    virtual const void *force(typeinfo_t &type) const;
d61 1
a61 2

    char piece_to_name(tic_piece cpiece);
d64 3
a66 3
    tic_piece pos_to_piece(string &ppos);
    // Effects: Returns a piece corresponding to a player's position, or
    // no_piece if the position isn't mapped.
d68 3
a70 1
    player* check_for_winner();
d72 1
a72 1
    // a pointer to the winning player. If the game is not over, returns
d78 3
d82 1
a82 1
    void operator= (test_board &);
d84 2
a85 2
    player *won_player;                      // The player who has won
    char turn_token;                         // X or O.
@


1.2
log
@tic_board changes I made on the airplane. More implementation
on check_if_won, I think.
@
text
@d3 1
a3 1
// $Id: tic_board.h,v 1.1 1995/11/26 04:20:51 jered Exp $
d36 1
a36 4
    virtual bool is_legal_move(move &m, const player *p) const; 
    // Effects: return true if m is a tic_move, and player p applying m to this board 
    // in the current state would be legal, else return false. Additionally, see
    // board.h
d38 1
a38 2
    virtual game::move_result apply(move &m, player *p);
    // Effects: Plays move m by player p on this.  See board.h
d40 1
a40 2
    virtual bool unapply(move &m, const player *p);
    // Effects: See board.h
d42 1
a42 2
    virtual player *winner();
    // Effects: See board.h
d44 2
a45 2
    virtual http_response *get(string request, extensions *extras);
    // Effects: See board.h
a47 1
    // Effects: See board.h
d49 5
a53 2
    virtual bool valid_move_available(const player *p) const = 0;
    // Effects: See board.h
d55 1
a55 2
    virtual generator <move *> * valid_moves(const player *p) const;
    // Effects: See board.h
d57 1
a57 5
    virtual board::value eval_move_delta(move &m, const player *p) const;
    // Effects: See board.h
    
    virtual board::value evaluate(const player *p) const;
    // Effects: See board.h
d63 2
@


1.1
log
@Implementation and interface changes, see ChangLog.
(Attempting to commit again.)
#$@@$@@ Linux-AFS over SLIP.
@
text
@d3 1
a3 1
// $Id$
d17 1
d93 1
a93 1
    //FIXME There should be some state indicating the current player, I'd imagine.
@
