~ubuntu-branches/ubuntu/karmic/brutalchess/karmic

« back to all changes in this revision

Viewing changes to chessplayer.h

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2006-04-07 10:41:25 UTC
  • Revision ID: james.westby@ubuntu.com-20060407104125-18mnxbl1yzju7e84
Tags: upstream-0.0.20060314cvs
Import upstream version 0.0.20060314cvs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Brutal Chess
 
2
//
 
3
// File : chessplayer.h
 
4
// Date : 05/03/2005
 
5
// Authors : Maxwell Lazaroff and Michael Cook, fixed by Joe Flint
 
6
//
 
7
// Description : Implements how a player works
 
8
 
 
9
#ifndef __CHESSPLAYER_H_IS_INCLUDED__
 
10
#define __CHESSPLAYER_H_IS_INCLUDED__
 
11
 
 
12
#include "boardmove.h"
 
13
#include "board.h"
 
14
#include <string>
 
15
#include <vector>
 
16
 
 
17
using namespace std;
 
18
 
 
19
typedef unsigned int uint;
 
20
 
 
21
class ChessPlayer {
 
22
 
 
23
public :
 
24
    ChessPlayer();
 
25
    ChessPlayer( const string & name ) { _name = name; };
 
26
    virtual ~ChessPlayer() {};
 
27
    
 
28
    static bool is_in(const BoardMove & move, const Board & board);
 
29
    static bool is_valid(const BoardMove & move, const Board & board, bool is_white);
 
30
    static bool inCheckmate(const Board &board, bool is_white);
 
31
    static bool inStalemate(const Board &board, bool is_white);
 
32
    
 
33
        virtual bool requiresInput() { return true; }
 
34
    virtual BoardMove decide_move(const Board & board, bool & white) = 0;
 
35
        virtual void opponent_move(const BoardMove & move, bool white ) {};
 
36
        static bool check_move(const BoardMove & move, const Board &board, bool white);
 
37
    
 
38
    static ChessPlayer* get_player(const string& player_name);
 
39
    
 
40
    static void add_player(ChessPlayer* player);
 
41
    
 
42
    virtual ChessPlayer* dup() const = 0;
 
43
    
 
44
    static ChessPlayer* lookup(const string& player_name);
 
45
 
 
46
    static vector<string> names();
 
47
                
 
48
        string getName() { return _name; }
 
49
        
 
50
        void append_name(string appender) { _name += appender; }
 
51
 
 
52
protected :
 
53
    string _name;
 
54
    static vector<ChessPlayer*> _players;
 
55
};
 
56
 
 
57
#endif