/// <summary> /// Initialize the IA /// </summary> protected override void Initialize() { maxTime = maxTime * _dif; for (int i = 0; i<8; i++){ playerPattern.Add(i, new List<IPawn>()); computerPattern.Add(i, new List<IPawn>()); } /****************** * Initialize the reference of the teams and of kings (separately). * ****************/ computerTeam = _board.GetTeam(-1); playerTeam = _board.GetTeam(1); computerKing = _board.EnemyKing; playerKing = _board.PlayerKing; /*************************/ /************************** * Valutation table for the simple pawn. Gives a value for each pawn according to their positions. * ************************/ simplePawnEvaluate[0] = new int[]{100,100,100,100,100,100,100,100}; simplePawnEvaluate[1] = new int[]{170,170,170,170,170,170,170,170}; simplePawnEvaluate[2] = new int[]{150,150,150,150,150,150,150,150}; simplePawnEvaluate[3] = new int[]{130,130,130,130,130,130,130,130}; simplePawnEvaluate[4] = new int[]{125,130,130,130,130,130,130,125}; simplePawnEvaluate[5] = new int[]{110,110,110,110,110,110,110,110}; simplePawnEvaluate[6] = new int[]{110,110,110,80,80,110,110,110}; simplePawnEvaluate[7] = new int[]{0,0,0,0,0,0,0,0}; /**************************/ /************************** * Valutation table for the king. Gives a value for each pawn according to his positions. * ************************/ kingNormalEvaluate[0] = new int[]{0,0,0,0,0,0,0,0}; kingNormalEvaluate[1] = new int[]{30,30,30, 30, 30,30,30,30}; kingNormalEvaluate[2] = new int[]{40,40,40, 40, 40, 40,40,40}; kingNormalEvaluate[3] = new int[]{40,40, 60, 60, 60, 60,40,40}; kingNormalEvaluate[4] = new int[]{40,40, 60, 60, 60, 60,40,40}; kingNormalEvaluate[5] = new int[]{40,40,40,45, 45, 40,40,40}; kingNormalEvaluate[6] = new int[]{0,0, 0,0, 0, 0,0,0}; kingNormalEvaluate[7] = new int[]{-60,-60,-60,-60,-60,-60,-60,-60}; /*************************/ }
//Fill their reference public void SetPawns(IPawn[][] board) { _board = board; _teams[0] = new List<IPawn>(); _teams[1] = new List<IPawn>(); int i; /* Computer kings*/ i=0; foreach(IPawn cPawn in _board[i]){ if(cPawn != null){ EnemyKing = (King)cPawn; _teams[0].Add(cPawn); cPawn.SetBoard(this); } } /*Computer pawns*/ i=1; foreach(IPawn cPawn in _board[i]){ if(cPawn != null){ _teams[0].Add(cPawn); cPawn.SetBoard(this); } } /*Player King*/ i=7; foreach(IPawn cPawn in _board[i]){ if(cPawn != null){ PlayerKing = (King)cPawn; _teams[1].Add(cPawn); cPawn.SetBoard(this); } } /*Player pawns*/ i=6; foreach(IPawn cPawn in _board[i]){ if(cPawn != null){ _teams[1].Add(cPawn); cPawn.SetBoard(this); } } }