示例#1
0
        public Tuple <int, int> GetTupleOfIndexes(Label label)
        {
            string labelName = label.Name;
            short  index     = GetIndexOfStone(labelName);

            return(Linking.GetIndexesOnBoard(index));
        }
示例#2
0
        public Move[] GetIndexesOfPossibleMoves(bool blackIsPLaying, PlaceOnBoardIs[,] board)
        {
            Move[]             indexesOfPossibleMoves  = new Move[36];
            Tuple <int, int>[] adjacentVacantPositions = new Tuple <int, int> [4];

            if (Form1.gamePhase == Form1.GamePhase.opening)
            {
                for (short i = 0; i < 36; i++)
                {
                    Tuple <int, int> tupleOfINdexes = Linking.GetIndexesOnBoard(i);
                    if (tupleOfINdexes.Item1 != -1)
                    {
                        if (board[tupleOfINdexes.Item1, tupleOfINdexes.Item2] == PlaceOnBoardIs.free)
                        {
                            indexesOfPossibleMoves[i] = new Move(tupleOfINdexes.Item1, tupleOfINdexes.Item2, -1, -1, false, blackIsPLaying);
                        }
                        else
                        {
                            indexesOfPossibleMoves[i] = new Move(-1, -1, -1, -1, false, blackIsPLaying);
                        }
                    }
                    else
                    {
                        indexesOfPossibleMoves[i] = new Move(-1, -1, -1, -1, false, blackIsPLaying);
                    }
                }
            }
            else
            {
                short helper1 = 0;
                short helper2 = 0;
                if (blackIsPLaying)
                {
                    for (short i = 0; i < 24; i++)
                    {
                        Tuple <int, int> tupleOfINdexes = Linking.GetIndexesOnBoard(i);
                        if (board[tupleOfINdexes.Item1, tupleOfINdexes.Item2] == PlaceOnBoardIs.blackOccupied)
                        {
                            adjacentVacantPositions = GetAdjacentVacantPositions(tupleOfINdexes.Item1, tupleOfINdexes.Item2, board);

                            for (int j = 0; j < 4; j++)
                            {
                                indexesOfPossibleMoves[helper2 * 4 + helper1] = new Move(adjacentVacantPositions[j].Item1,
                                                                                         adjacentVacantPositions[j].Item2, tupleOfINdexes.Item1,
                                                                                         tupleOfINdexes.Item2, false, blackIsPLaying);
                                helper1++;
                            }
                            helper2++;
                            helper1 = 0;
                        }
                    }
                }
                else
                {
                    for (short i = 0; i < 24; i++)
                    {
                        Tuple <int, int> tupleOfINdexes = Linking.GetIndexesOnBoard(i);
                        if (board[tupleOfINdexes.Item1, tupleOfINdexes.Item2] == PlaceOnBoardIs.whiteOccupied)
                        {
                            adjacentVacantPositions = GetAdjacentVacantPositions(tupleOfINdexes.Item1, tupleOfINdexes.Item2, board);

                            for (int j = 0; j < 4; j++)
                            {
                                indexesOfPossibleMoves[helper2 * 4 + helper1] = new Move(adjacentVacantPositions[j].Item1,
                                                                                         adjacentVacantPositions[j].Item2, tupleOfINdexes.Item1,
                                                                                         tupleOfINdexes.Item2, false, blackIsPLaying);
                                helper1++;
                            }
                            helper2++;
                            helper1 = 0;
                        }
                    }
                }
            }
            return(indexesOfPossibleMoves);
        }