00001
00002
00003
00004
#ifndef __TREE_H
00005
#define __TREE_H
00006
00007
#include <vector>
00008
#include <allegro.h>
00009
#include "board.h"
00010
00011
using namespace std;
00012
00014
const float infinity = boardWidth*boardHeight*1000.0;
00015
00017
00020 class TreeNode{
00021
protected:
00023 Board data;
00025 TreeNode *
parent;
00027 TreeNode *
brother;
00029 TreeNode *
child;
00031 float alpha;
00033 float beta;
00034
public:
00036
00040
TreeNode(
Board data);
00042
00047
TreeNode(
Board data,
TreeNode *parent);
00049
00052
virtual ~TreeNode();
00053
00055
00058
Board getData();
00060
00063
void setData(
Board data);
00065
00069
void addChild(
Board data);
00071
00074 void setBrother(
TreeNode *bro){
brother=bro; };
00075
00077
00080
TreeNode*
getBrother();
00082
00085
TreeNode*
getParent();
00086
00088
00091
TreeNode*
getChild();
00093
00097
void createChilds(
int count,
Board* data);
00098
00100
00103
void createChilds(vector<Board> data);
00104
00106
00110
TreeNode* expand(
int no);
00111
00113
00118
TreeNode* expand(
int no, vector<int> &moveAt);
00119
00121
00128
float minimaxABMin(
float a,
float b,
int no,
int level);
00129
00130
00132
00139
float minimaxABMax(
float a,
float b,
int no,
int level);
00140
00142
00149
float depthSearch(
int level,
int stopLevel,
int no,
int moveAt);
00150
00151
00152 };
00153
00155 class AITree{
00156
protected:
00157
TreeNode* root;
00158
int countChilds(
TreeNode* node);
00159
int countWidth(
TreeNode* node,
int grid_space);
00160
int drawNode(BITMAP *b,
TreeNode* node,
int off_x,
int off_y,
int field_width,
int grid_space);
00161
public:
00162
AITree();
00163
void setRoot(
TreeNode* new_root);
00164
TreeNode* getRoot();
00165
void draw(BITMAP *b,
int filed_width,
int grid_space);
00166
00167
static void show(
Board data,
unsigned char plNo);
00168 };
00169
00170
void AITree_Test(BITMAP *scr);
00171
00172
#endif // __TREE_H