⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tree.h

📁 围棋游戏
💻 H
字号:
// Tree.h: interface for the Tree class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TREE_H__2B1ED113_D310_11D3_AB17_204C4F4F5020__INCLUDED_)
#define AFX_TREE_H__2B1ED113_D310_11D3_AB17_204C4F4F5020__INCLUDED_

#include "MyChess.h"	// Added by ClassView
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
const MAXSTEP=2; //Try MAXSTEP steps when thinking.
const MAXF=1000;  //The Max value about the value function
const MINF=-1000; //The Min value about the value function
const MAXTRY=400; //The maxmium depth of the searching tree

//const MAXSUN=100;

struct Node{
	//this structre is the tree's node 
	int MePos; //Mark this node's position in list
	int NextPos;  //The position of Next point
	int FatherPos; //The father node's position 
	int SonPos; //The son's position
	CPoint p; //Tree's node instead of the point.
	float v; //The value of this node
	int Depth; //Mark this node's depth
	
 //Point the father node
	BOOL Leaf;// marked whether this node is the leaf.
	BOOL AndOr;//Mark the node is and or
};

struct PS{
	//this structure is a member of create tree stack
	CPoint chessp; //the chess whitch is searched
	//int depth; //the tree's layer of this member
	//int pos; //The position of this layer 
	int node;//tree's node 
};

struct PSTWO{
	//this structure is a member of search stack
	Node * nd;
	BOOL open;
	float v;
};

typedef CList<PS, PS&> MyList;
typedef CArray<Node,Node&> MyList2;
class Tree  
{
public:
	int NodeCount;
	CPoint Result();
	int MyBW;
	MyChess CopyChess(MyChess *); //Copy the chess
	MyList2 nodes; //Use an array of list to memorise the node.
	int Deep; //the fact depth of tree (Although the depth can be defined 
	          //by the user but sometimes it can't get this depth anymore)
	         //so the deep can be counted as:
//tree:   *      0
	//  * * *    1 
	//  * * * *  2  deep=2 
	Tree(int,MyChess *); //Tell him a depth and a chess then it can create the tree
	virtual ~Tree();

private:
	void PSInsert(PS,float);
	CArray<CPoint,CPoint&> State;
	void CloneChess(MyChess*,MyChess*,CPoint*);
	MyChess* chessSource;
	void Insert(Node *,float,CList<PSTWO,PSTWO>*);
	void DelSubTree(Node*,CList<PSTWO,PSTWO>*);
	int ActDeep; //the max trying depth of the tree
	float Value(MyChess*,int); //it can value the node according to the chess
	MyList Stack; //this store the tree's searching state
	void MakeAllPosible(PS*); //Generate all posiblities of curent chess
    int MAXNODE;//The maxmium number of nodes
    int MIDNODE; //The maxmium number of nodes have value

};

#endif // !defined(AFX_TREE_H__2B1ED113_D310_11D3_AB17_204C4F4F5020__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -