Beispiel #1
0
        public static void FillTableOfStans(Stan[] tableOfStans)
        {
            int i = 0;

            for (int j = N; j >= -N; j--)
            {
                for (int k = -N; k <= N; k++)
                {
                    if (!((j == k) || (j == 0) || (k == 0)))
                    {
                        tableOfStans[i] = new Stan(j, k, 1, true);
                        i++;
                        tableOfStans[i] = new Stan(j, k, 2, true);
                        i++;
                    }
                }
            }

            for (int j = N; j >= -N; j--)
            {
                if (j != 0)
                {
                    tableOfStans[i] = new Stan(j, j, 1, true);
                    i++;
                    tableOfStans[i] = new Stan(j, j, 2, true);
                    i++;
                }
            }
        }
Beispiel #2
0
        public static void PrintUsedStansForStan(Stan stan)
        {
            Stan[] usedItemsForGivenStan = stan.usedItems;

            Console.WriteLine("Używane stany przez dany stan");
            for (int i = 0; i < Stan.numberOfCubeWalls; i++)
            {
                Console.WriteLine("Stan {0}: P{1}({2},{3})", i + 1, usedItemsForGivenStan[i].playerMove, usedItemsForGivenStan[i].firstPlayerField, usedItemsForGivenStan[i].secondPlayerField);
            }
        }
Beispiel #3
0
 public Stan(int firstPlayerField, int secondPlayerField, int playerMove, bool flag)
 {
     this.firstPlayerField  = firstPlayerField;
     this.secondPlayerField = secondPlayerField;
     this.playerMove        = playerMove;
     usedItems = new Stan[numberOfCubeWalls];
     //cubeValues = new double[,] { { 0, 0.05 }, { 1, 0.15 }, { 2, 0.20 }, { 3, 0.10 }, { -3, 0.25 }, { -2, 0.13 }, { -1, 0.12 } };
     cubeValues = new double[, ] {
         { -3, 1.0 / 7 }, { -2, 1.0 / 7 }, { -1, 1.0 / 7 }, { 0, 1.0 / 7 }, { 1, 1.0 / 7 }, { 2, 1.0 / 7 }, { 3, 1.0 / 7 }
     };
     //cubeValues = new double[,] { { -1, 1.0 / 3 }, { 0, 1.0 / 3 }, { 1, 1.0 / 3 } };
     //cubeValues = new double[,] { { -2, 2.0 / 5 }, { 0, 1.0 / 5 }, { 1, 1.0 / 5 }, { 3, 1.0 / 5 } };
     if (flag == true)
     {
         SetUsedItemTable();
     }
 }
Beispiel #4
0
        public void SetUsedItemTable()
        {
            int i = 0;

            for (int j = 0; j < (int)(cubeValues.Length / 2); j++, i++)
            {
                int whichFieldForPlayer;
                if (playerMove == 1)
                {
                    whichFieldForPlayer = firstPlayerField;
                }
                else
                {
                    whichFieldForPlayer = secondPlayerField;
                }

                if (whichFieldForPlayer + cubeValues[j, 0] < -Program.N)
                {
                    whichFieldForPlayer = Program.N - ((-(whichFieldForPlayer + (int)cubeValues[j, 0]) - Program.N) - 1);
                }
                else if (whichFieldForPlayer + cubeValues[j, 0] > Program.N)
                {
                    whichFieldForPlayer = -Program.N + (((whichFieldForPlayer + (int)cubeValues[j, 0]) - Program.N) - 1);
                }
                else
                {
                    whichFieldForPlayer += (int)cubeValues[j, 0];
                }

                if (playerMove == 1)
                {
                    usedItems[i] = new Stan(whichFieldForPlayer, secondPlayerField, 2, false);
                }
                else
                {
                    usedItems[i] = new Stan(firstPlayerField, whichFieldForPlayer, 1, false);
                }
            }
        }
Beispiel #5
0
 public static int FindIndexOfStanInElements(Stan[] tableOfStans, int numberOfColumn, Stan stan)
 {
     for (int i = 0; i < numberOfColumn; i++)
     {
         if (tableOfStans[i].firstPlayerField == stan.firstPlayerField &&
             tableOfStans[i].secondPlayerField == stan.secondPlayerField &&
             tableOfStans[i].playerMove == stan.playerMove)
         {
             return(i);
         }
     }
     return(-10000);
 }