Exemple #1
0
        private void ServerBegin(int total)
        {
            int x = total / 8;
            int y = total % 8;

            EnemyMatch(x, y);        //Update current;
            UpdateChessBoard(Current);
            Current.GenerateChild(); //Initialzie the states which self may put, the available position is also calculated
            Steps++;

            /*for (int i = 0; i < Current.Child.Count; i++)
             * {
             *  Current.Child[i].GenerateChild();//Initialize all the enemy's state after each self state;
             * }*/
        }
Exemple #2
0
        public void generateLevelChild(State aState, int currentLevel)
        {
            if (currentLevel == SearchLeve - 1)
            {
                return;
            }
            aState.GenerateChild();

            if (aState.AvailablePosition[0].Count != 0)
            {
                for (int i = 1; i < aState.AvailablePosition[0].Count + 1; i++)
                {
                    generateLevelChild(aState.Child[i], currentLevel + 1);
                }
            }
            else//No step to go;
            {
                generateLevelChild(aState.Child[0], currentLevel + 1);
            }
        }
Exemple #3
0
 private void Reset()
 {
     counter           = 0;
     Steps             = 4;
     Start             = new State();
     Start.Board[3][3] = 0;
     Start.Board[4][3] = 7;
     Start.Board[4][4] = 0;
     Start.Board[3][4] = 7;
     if (CurrentPlayer == PlayerRole.White)
     {
         Start.NextPlayer = 7;
     }
     else
     {
         Start.NextPlayer = 7;
     }
     Rules.getAvailableList(Start.NextPlayer, Start.Board, Start.AvailablePosition);
     Start.GenerateChild();
     Current = Start;
     UpdateChessBoard(Current);
 }
Exemple #4
0
 public void AddTwoLevelChild(State aState, int CurrentLevel)
 {
     if (CurrentLevel == SearchLeve - 2)
     {
         aState.GenerateChild();
         Numberr1++;
         if (aState.AvailablePosition[0].Count != 0)
         {
             for (int i = 1; i < aState.AvailablePosition[0].Count + 1; i++)
             {
                 aState.Child[i].GenerateChild();
                 Numberr2++;
                 Numberr3 += aState.Child[i].AvailablePosition[0].Count;
             }
         }
         else//No step to go;
         {
             aState.Child[0].GenerateChild();
             Numberr2++;
         }
         return;
     }
     else
     {
         if (aState.AvailablePosition[0].Count != 0)
         {
             for (int i = 1; i < aState.AvailablePosition[0].Count + 1; i++)
             {
                 AddTwoLevelChild(aState.Child[i], CurrentLevel + 1);
             }
         }
         else//No step to go;
         {
             AddTwoLevelChild(aState.Child[0], CurrentLevel + 1);
         }
     }
 }
Exemple #5
0
 private void Reset()
 {
     counter = 0;
     Steps = 4;
     Start = new State();
     Start.Board[3][3] = 0;
     Start.Board[4][3] = 7;
     Start.Board[4][4] = 0;
     Start.Board[3][4] = 7;
     if (CurrentPlayer == PlayerRole.White)
         Start.NextPlayer = 7;
     else
         Start.NextPlayer = 7;
     Rules.getAvailableList(Start.NextPlayer, Start.Board, Start.AvailablePosition);
     Start.GenerateChild();
     Current = Start;
     UpdateChessBoard(Current);
 }
Exemple #6
0
        public void generateLevelChild(State aState,int currentLevel )
        {
            if (currentLevel == SearchLeve-1) return;
            aState.GenerateChild();

            if (aState.AvailablePosition[0].Count != 0)
            {
                for (int i = 1; i < aState.AvailablePosition[0].Count + 1; i++)
                {
                    generateLevelChild(aState.Child[i], currentLevel + 1);
                }
            }
            else//No step to go;
            {
                generateLevelChild(aState.Child[0], currentLevel + 1);
            }
        }
Exemple #7
0
 public void AddTwoLevelChild(State aState, int CurrentLevel)
 {
     if (CurrentLevel == SearchLeve - 2)
     {
         aState.GenerateChild();
         Numberr1++;
         if (aState.AvailablePosition[0].Count != 0)
         {
             for (int i = 1; i < aState.AvailablePosition[0].Count + 1; i++)
             {
                 aState.Child[i].GenerateChild();
                 Numberr2++;
                 Numberr3 += aState.Child[i].AvailablePosition[0].Count;
             }
         }
         else//No step to go;
         {
             aState.Child[0].GenerateChild();
             Numberr2++;
         }
         return;
     }
     else
     {
         if (aState.AvailablePosition[0].Count != 0)
         {
             for (int i = 1; i < aState.AvailablePosition[0].Count + 1; i++)
             {
                 AddTwoLevelChild(aState.Child[i], CurrentLevel + 1);
             }
         }
         else//No step to go;
         {
             AddTwoLevelChild(aState.Child[0], CurrentLevel + 1);
         }
     }
 }