예제 #1
0
파일: Table.cs 프로젝트: GenryMacros/Chess
        public void MoveFigure(Vector2i mouse, RenderWindow win)
        {
            for (int i = 1; i < selectedTiles.Count; i++)
            {
                int index = selectedTiles[i];
                if (actualDeck[index].sp.GetGlobalBounds().Contains(mouse.X, mouse.Y))
                {
                    if (TableSelectors.FigureMover(index, selectedTiles[0], win) == false)
                    {
                        break;
                    }
                    for (int k = 0; k < selectedTiles.Count; k++)
                    {
                        int indexK = selectedTiles[k];
                        actualDeck[indexK].ChangeTitle();
                    }
                    selectedTiles.Clear();
                    Select(index);
                    selectedTiles.RemoveAt(0);
                    actualDeck[index].ChangeTitle();
                    TableSelectors.ChangeFigureTargets(actualDeck[index], index);

                    return;
                }
            }
            for (int k = 0; k < selectedTiles.Count; k++)
            {
                int indexK = selectedTiles[k];
                actualDeck[indexK].ChangeTitle();
            }
            selectedTiles.Clear();
        }
예제 #2
0
 public static bool calculateIfProtected(string color, title[] arr)
 {
     if (color == "white")
     {
         //   if (Table.isCheckmateWhite == false) return false;
         return(TableSelectors.Plunk("black", arr, PhantomWhiteKingIndex));
     }
     else
     {
         //   if (Table.isCheckmateBlack == false) return false;
         return(TableSelectors.Plunk("white", arr, PhantomBlackKingIndex));
     }
 }
예제 #3
0
파일: AI.cs 프로젝트: RePlatonium/Chess
        public static void MakeAEasyMove(RenderWindow win)
        {
            table = Table.actualDeck;

            int[] move = AICalculations_2.CalculateBestMove(table);
            if (move[1] == move[0])
            {
                MakeARandoMmove(win);
                return;
            }
            if (!TableSelectors.FigureMover(move[1], move[0], win) || (move[0] == 7 && move[1] == 6))
            {
                MakeARandoMmove(win);
                return;
            }
            TableSelectors.ChangeFigureTargets(Table.actualDeck[move[1]], move[1]);
        }
예제 #4
0
파일: AI.cs 프로젝트: RePlatonium/Chess
        public static void MakeARandoMmove(RenderWindow win)
        {
            bool selectedIndex = false;

            table = Table.actualDeck;


            Random rand = new Random();

            int[] arr = new int[64];
            int   j   = 1;

            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = i;
            }
            int ControlledRandom = 64;

            for (int i = 0; ; i++)
            {
                int index = rand.Next(0, ControlledRandom);
                if (table[index].colorOfFigure != "black")
                {
                    continue;
                }
                int[] indexes = CanMove(index);
                if (indexes.Length == 0 || indexes[0] == -1)
                {
                    continue;
                }
                int newTitle = ChooseRandomly(indexes);
                if (TableSelectors.FigureMover(newTitle, index, win))
                {
                    break;
                }
                int a = index;
                arr[index]          = arr[arr.Length - j];
                arr[arr.Length - j] = index;
                j++;
                ControlledRandom--;
            }
        }