Example #1
0
        private static CheckerType[,] GetArrayBoard(string stringBoard)
        {
            var arrayBoard = new CheckerType[BoardLength, BoardLength];

            for (var i = 0; i < BoardSize; i++)
            {
                switch (stringBoard[i])
                {
                case WhiteChecker:
                    arrayBoard[i / 8, i % 8] = CheckerType.WhiteChecker;
                    break;

                case WhiteKing:
                    arrayBoard[i / 8, i % 8] = CheckerType.WhiteKing;
                    break;

                case BlackChecker:
                    arrayBoard[i / 8, i % 8] = CheckerType.BlackChecker;
                    break;

                case BlackKing:
                    arrayBoard[i / 8, i % 8] = CheckerType.BlackKing;
                    break;

                case Empty:
                    arrayBoard[i / 8, i % 8] = CheckerType.Empty;
                    break;

                default:
                    throw new Exception("Wrong board");
                }
            }

            return(arrayBoard);
        }
Example #2
0
 public Checker(Color _color, int _x, int _y, CheckerType _type)
 {
     color = _color;
     x     = _x;
     y     = _y;
     type  = _type;
 }
Example #3
0
 public Square(Rectangle location, CheckerType type) {
     this.location = location;
     this.squareType = type;
     this.highlighted = false;
     this.tl = null;
     this.tr = null;
     this.bl = null;
     this.br = null;
 }
Example #4
0
 public void Move(int _x, int _y)
 {
     x = _x;
     y = _y;
     if ((y == 7 && team == CheckerTeam.White) || (y == 0 && team == CheckerTeam.Black))
     {
         type = CheckerType.King;
     }
     //shape.setPosition(30 + 56 * x, 30 + 56 * y);
 }
Example #5
0
 public Square(Rectangle location, CheckerType type)
 {
     this.location    = location;
     this.squareType  = type;
     this.highlighted = false;
     this.tl          = null;
     this.tr          = null;
     this.bl          = null;
     this.br          = null;
 }
Example #6
0
        public Checker(int _x, int _y, CheckerTeam _team, CheckerType _type)
        {
            //shape.setTexture(texture);
            //shape.setScale(0.52, 0.52);
            //shape.setPosition(30, 30);
            x    = _x;
            y    = _y;
            team = _team;
            type = _type;
            //shape.setPosition(30 + 56 * x, 30 + 56 * y);

            unsetMark();
            created = true;
        }
Example #7
0
    private void OnGUI()
    {
        if (this.errorDirty)
        {
            this.errorDirty = false;
            this.RefreshErrorStatistics();
        }
        FieldInfo[] fields = typeof(CheckerType).GetFields();
        for (int i = 1; i < fields.Length; i++)
        {
            string      checkerName = fields[i].ToString().Split(' ')[1];
            CheckerType checkerType = (CheckerType)fields[i].GetValue(null);
            BaseChecker checker     = GetChecker(checkerType);
            checker.SetFileName(checkerName);

            GUILayout.BeginHorizontal();

            // 检查
            if (GUILayout.Button(checkerName + "Check"))
            {
                errorDirty = true;
                Debug.LogFormat("[AssetsChecker] Start Check {0}", checkerName);
                double start_time = EditorApplication.timeSinceStartup;
                checker.StartCheck();
                checker.Output();
                this.SaveCacheErrorCount(checkerName, checker.ErrorCount, checker.GetErrorDesc());

                Debug.LogFormat("[AssetsChecker] Check Complete, cost time{0}s, error count {1}",
                                Convert.ToInt32(EditorApplication.timeSinceStartup - start_time),
                                checker.ErrorCount);
            }

            // 修复
            if (this.GetCacheErrorCount(checkerName) > 0)
            {
                if (GUILayout.Button("Fix"))
                {
                    errorDirty = true;
                    checker.StartFix();
                }
            }

            GUILayout.EndHorizontal();
        }
    }
Example #8
0
    // 根据类型获得检查器
    public static BaseChecker GetChecker(CheckerType type)
    {
        BaseChecker checker;

        if (!checkerDic.TryGetValue(type, out checker))
        {
            // UI相关
            if (CheckerType.UIAtlas == type)
            {
                checker = new UIAtlasChecker();
            }
            if (CheckerType.UITexture == type)
            {
                checker = new UITextureChecker();
            }
        }

        return(checker);
    }
        protected override List <List <string> > GetCheckerPositions(List <List <string> > positions, int i, int j)
        {
            var position  = new List <string>();
            var tempBoard = new CheckerType[BoardLength, BoardLength];

            Array.Copy(ArrayBoard, tempBoard, BoardSize);
            if (i - 1 > -1 && j - 1 > -1 && tempBoard[i - 1, j - 1] == CheckerType.Empty)
            {
                if (i - 1 == 0)
                {
                    tempBoard[i - 1, j - 1] = CheckerType.BlackKing;
                }
                else
                {
                    tempBoard[i - 1, j - 1] = tempBoard[i, j];
                }
                tempBoard[i, j] = CheckerType.Empty;
                position.Add(GetStringBoard(tempBoard));
                positions.Add(position);
            }

            Array.Copy(ArrayBoard, tempBoard, BoardSize);
            position = new List <string>();
            if (i - 1 > -1 && j + 1 < BoardLength && tempBoard[i - 1, j + 1] == CheckerType.Empty)
            {
                if (i - 1 == 0)
                {
                    tempBoard[i - 1, j + 1] = CheckerType.BlackKing;
                }
                else
                {
                    tempBoard[i - 1, j + 1] = tempBoard[i, j];
                }
                tempBoard[i, j] = CheckerType.Empty;
                position.Add(GetStringBoard(tempBoard));
                positions.Add(position);
            }

            return(positions);
        }
Example #10
0
 public void UpgradeChecker()
 {
     checkerType      = CheckerType.King;
     theSprite.sprite = kingSprite;
 }
Example #11
0
 public void ProceedLeftClick(float _x, float _y)
 {
     _x = Game1.DeabsoluteX(_x);
     _y = Game1.DeabsoluteY(_y);
     if ((isOnline == false || gameState == (int)myTeam) && _x >= 30 && _x < 478 && _y >= 30 && _y < 478)
     {
         int gX = (int)Math.Floor(_x - 30) / 56;
         int gY = (int)Math.Floor(_y - 30) / 56;
         if (gX == sx && gY == sy)
         {
             selected.unsetMark();
             subState = 1;
             sx       = -1;
             sy       = -1;
             return;
         }
         System.Diagnostics.Debug.WriteLine("Pos: " + gX + " " + gY);
         if (subState == 1)
         {
             //cout << "sub: 1" << endl;
             selected = null;
             foreach (var s in entity)
             {
                 if (s.checkIntersection(gX, gY) && (int)s.getTeam() == gameState)
                 {
                     selected = s;
                     selected.setMark();
                     break;
                 }
             }
             if (selected != null)
             {
                 subState = 2;
                 sx       = gX;
                 sy       = gY;
             }
         }
         else if (subState == 2)
         {
             //cout << "sub: 2" << endl;
             int         x = 0, y = 0;
             CheckerType type = selected.getType();
             CheckerTeam team = selected.getTeam();
             selected.getPosition(ref x, ref y);
             int x_diff = (gX - x);
             int y_diff = (gY - y);
             //cout << x_diff << " " << y_diff << endl;
             if (Math.Abs(x_diff) != Math.Abs(y_diff) || x_diff == 0)
             {
                 return;
             }
             //cout << x << " " << y << endl;
             int cx = x + Math.Sign(x_diff), cy = y + Math.Sign(y_diff);
             if (type == CheckerType.Default)
             {
                 if (x_diff > 2)
                 {
                     return;
                 }
                 Checker toRemove = null;
                 //cout << cx << " " << cy << endl;
                 bool invalid = false, remove = false;;
                 foreach (var s in entity)
                 {
                     if (s.checkIntersection(cx, cy))
                     {
                         if (s.getTeam() != selected.getTeam())
                         {
                             toRemove = s;
                             remove   = true;
                         }
                         else
                         {
                             invalid = true;
                         }
                         break;
                     }
                 }
                 if (invalid)
                 {
                     return;
                 }
                 if ((Math.Abs(x_diff) == 1 && remove == false && ((team == CheckerTeam.White && gY > y) || (team == CheckerTeam.Black && gY < y))) || (Math.Abs(x_diff) == 2 && remove == true))
                 {
                     char[] s = new char[3];
                     selected.Move(gX, gY);
                     selected.unsetMark();
                     if (remove == true)
                     {
                         teams[3 - gameState]--;
                         int ttx = 0, tty = 0;
                         toRemove.getPosition(ref ttx, ref tty);
                         socket.sendMessage(MessageType.Remove, ttx, tty);
                         entity.Remove(toRemove);
                     }
                     socket.sendMessage(MessageType.Move, x, y, gX, gY);
                     gameState = 3 - gameState;
                     socket.sendMessage(MessageType.ChangeState, gameState);
                     subState = 1;
                     sx       = -1;
                     sy       = -1;
                     if (teams[gameState] == 0)
                     {
                         EndGame();
                     }
                 }
             }
             else if (type == CheckerType.King)
             {
                 Checker toRemove = null;
                 int     tx = 0, ty = 0;
                 int     dist_c = Math.Abs(x_diff) + Math.Abs(y_diff);
                 //cout << cx << " " << cy << endl;
                 bool invalid = false, remove = false;;
                 foreach (var sp in entity)
                 {
                     sp.getPosition(ref tx, ref ty);
                     int dist_t = Math.Abs(tx - x) + Math.Abs(ty - y);
                     if (Math.Abs(tx - x) == Math.Abs(ty - y) && tx != x && cx == x + Math.Sign(tx - x) && cy == y + Math.Sign(ty - y) && dist_t < dist_c)
                     {
                         if (sp.getTeam() != selected.getTeam())
                         {
                             if (remove)
                             {
                                 remove  = false;
                                 invalid = true;
                                 //cout << "more";
                                 break;
                             }
                             else
                             {
                                 toRemove = sp;
                                 remove   = true;
                                 //cout << tx << " " << ty << endl;
                             }
                         }
                         else
                         {
                             invalid = true;
                         }
                     }
                 }
                 //cout << "inv";
                 if (invalid)
                 {
                     return;
                 }
                 selected.unsetMark();
                 char[] s = new char[10];
                 if (remove == true)
                 {
                     int ttx = 0, tty = 0;
                     toRemove.getPosition(ref ttx, ref tty);
                     gX = ttx + Math.Sign(ttx - x);
                     gY = tty + Math.Sign(tty - y);
                     selected.Move(gX, gY);
                     socket.sendMessage(MessageType.Remove, tx, ty);
                     socket.sendMessage(MessageType.Move, x, y, gX, gY);
                     teams[3 - gameState]--;
                     entity.Remove(toRemove);
                 }
                 else
                 {
                     selected.Move(gX, gY);
                     socket.sendMessage(MessageType.Move, x, y, gX, gY);
                 }
                 gameState = 3 - gameState;
                 socket.sendMessage(MessageType.ChangeState, gameState);
                 subState = 1;
                 sx       = -1;
                 sy       = -1;
                 if (teams[gameState] == 0)
                 {
                     EndGame();
                 }
             }
         }
     }
 }
Example #12
0
        private List <List <string> > GetKingAttackPositions(List <List <string> > positions, CheckerType[] enemies,
                                                             int i, int j, List <string> position, CheckerType[,] board)
        {
            var i1        = i + 1;
            var j1        = j + 1;
            var tempBoard = new CheckerType[BoardLength, BoardLength];

            Array.Copy(board, tempBoard, BoardSize);
            while (i1 < BoardLength && j1 < BoardLength)
            {
                var variantsAfterFight = new List <Tuple <int, int> >();
                if (enemies.Contains(tempBoard[i1, j1]))
                {
                    var i2 = i1 + 1;
                    var j2 = j1 + 1;
                    while (i2 < 8 && j2 < 8 && tempBoard[i2, j2] == CheckerType.Empty)
                    {
                        variantsAfterFight.Add(Tuple.Create(i2, j2));
                        i2++;
                        j2++;
                    }

                    if (variantsAfterFight.Count > 0)
                    {
                        var current = tempBoard[i, j];
                        var enemy   = tempBoard[i1, j1];
                        foreach (var(i3, j3) in variantsAfterFight)
                        {
                            tempBoard[i, j]   = CheckerType.Empty;
                            tempBoard[i1, j1] = CheckerType.Empty;
                            tempBoard[i3, j3] = current;
                            position.Add(GetStringBoard(tempBoard));
                            positions         = GetKingAttackPositions(positions, enemies, i3, j3, position, tempBoard);
                            tempBoard[i3, j3] = CheckerType.Empty;
                            tempBoard[i, j]   = current;
                            tempBoard[i1, j1] = enemy;
                            position.RemoveAt(position.Count - 1);
                        }
                    }

                    break;
                }

                if (!enemies.Contains(tempBoard[i1, j1]) && tempBoard[i1, j1] != CheckerType.Empty)
                {
                    break;
                }

                i1++;
                j1++;
            }

            i1 = i - 1;
            j1 = j + 1;
            Array.Copy(board, tempBoard, BoardSize);
            while (i1 > -1 && j1 < BoardLength)
            {
                var variantsAfterFight = new List <Tuple <int, int> >();
                if (enemies.Contains(tempBoard[i1, j1]))
                {
                    var i2 = i1 - 1;
                    var j2 = j1 + 1;
                    while (i2 > -1 && j2 < 8 && tempBoard[i2, j2] == CheckerType.Empty)
                    {
                        variantsAfterFight.Add(Tuple.Create(i2, j2));
                        i2--;
                        j2++;
                    }

                    if (variantsAfterFight.Count > 0)
                    {
                        var current = tempBoard[i, j];
                        var enemy   = tempBoard[i1, j1];
                        foreach (var(i3, j3) in variantsAfterFight)
                        {
                            tempBoard[i, j]   = CheckerType.Empty;
                            tempBoard[i1, j1] = CheckerType.Empty;
                            tempBoard[i3, j3] = current;
                            position.Add(GetStringBoard(tempBoard));
                            positions         = GetKingAttackPositions(positions, enemies, i3, j3, position, tempBoard);
                            tempBoard[i3, j3] = CheckerType.Empty;
                            tempBoard[i, j]   = current;
                            tempBoard[i1, j1] = enemy;
                            position.RemoveAt(position.Count - 1);
                        }
                    }

                    break;
                }

                if (!enemies.Contains(tempBoard[i1, j1]) && tempBoard[i1, j1] != CheckerType.Empty)
                {
                    break;
                }

                i1--;
                j1++;
            }

            i1 = i - 1;
            j1 = j - 1;
            Array.Copy(board, tempBoard, BoardSize);
            while (i1 > -1 && j1 > -1)
            {
                var variantsAfterFight = new List <Tuple <int, int> >();
                if (enemies.Contains(tempBoard[i1, j1]))
                {
                    var i2 = i1 - 1;
                    var j2 = j1 - 1;
                    while (i2 > -1 && j2 > -1 && tempBoard[i2, j2] == CheckerType.Empty)
                    {
                        variantsAfterFight.Add(Tuple.Create(i2, j2));
                        i2--;
                        j2--;
                    }

                    if (variantsAfterFight.Count > 0)
                    {
                        var current = tempBoard[i, j];
                        var enemy   = tempBoard[i1, j1];
                        foreach (var(i3, j3) in variantsAfterFight)
                        {
                            tempBoard[i, j]   = CheckerType.Empty;
                            tempBoard[i1, j1] = CheckerType.Empty;
                            tempBoard[i3, j3] = current;
                            position.Add(GetStringBoard(tempBoard));
                            positions         = GetKingAttackPositions(positions, enemies, i3, j3, position, tempBoard);
                            tempBoard[i3, j3] = CheckerType.Empty;
                            tempBoard[i, j]   = current;
                            tempBoard[i1, j1] = enemy;
                            position.RemoveAt(position.Count - 1);
                        }
                    }

                    break;
                }

                if (!enemies.Contains(tempBoard[i1, j1]) && tempBoard[i1, j1] != CheckerType.Empty)
                {
                    break;
                }

                i1--;
                j1--;
            }

            i1 = i + 1;
            j1 = j - 1;
            Array.Copy(board, tempBoard, BoardSize);
            while (i1 < BoardLength && j1 > -1)
            {
                var variantsAfterFight = new List <Tuple <int, int> >();
                if (enemies.Contains(tempBoard[i1, j1]))
                {
                    var i2 = i1 + 1;
                    var j2 = j1 - 1;
                    while (i2 < 8 && j2 > -1 && tempBoard[i2, j2] == CheckerType.Empty)
                    {
                        variantsAfterFight.Add(Tuple.Create(i2, j2));
                        i2++;
                        j2--;
                    }

                    if (variantsAfterFight.Count > 0)
                    {
                        var current = tempBoard[i, j];
                        var enemy   = tempBoard[i1, j1];
                        foreach (var(i3, j3) in variantsAfterFight)
                        {
                            tempBoard[i, j]   = CheckerType.Empty;
                            tempBoard[i1, j1] = CheckerType.Empty;
                            tempBoard[i3, j3] = current;
                            position.Add(GetStringBoard(tempBoard));
                            positions         = GetKingAttackPositions(positions, enemies, i3, j3, position, tempBoard);
                            tempBoard[i3, j3] = CheckerType.Empty;
                            tempBoard[i, j]   = current;
                            tempBoard[i1, j1] = enemy;
                            position.RemoveAt(position.Count - 1);
                        }
                    }

                    break;
                }

                if (!enemies.Contains(tempBoard[i1, j1]) && tempBoard[i1, j1] != CheckerType.Empty)
                {
                    break;
                }

                i1++;
                j1--;
            }

            foreach (var pos in positions)
            {
                var c = 0;
                for (var k = 0; k < Math.Min(pos.Count, position.Count); k++)
                {
                    if (pos[k] == position[k])
                    {
                        c++;
                    }
                }

                if (c == Math.Min(pos.Count, position.Count))
                {
                    return(positions);
                }
            }

            if (position.Count == 0)
            {
                return(positions);
            }

            var tempPos = new string[position.Count];

            Array.Copy(position.ToArray(), tempPos, tempPos.Length);
            positions.Add(tempPos.ToList());

            return(positions);
        }
Example #13
0
        private List <List <string> > GetCheckerAttackPositions(List <List <string> > positions, CheckerType[] enemies,
                                                                int i, int j, List <string> position, CheckerType[,] board)
        {
            var tempBoard = new CheckerType[BoardLength, BoardLength];

            Array.Copy(board, tempBoard, BoardSize);
            if (i + 1 < BoardLength && j + 1 < BoardLength && enemies.Contains(board[i + 1, j + 1]) &&
                i + 2 < BoardLength && j + 2 < BoardLength && board[i + 2, j + 2] == CheckerType.Empty)
            {
                if (tempBoard[i, j] == CheckerType.WhiteChecker && i + 2 == BoardLength - 1)
                {
                    tempBoard[i + 2, j + 2] = CheckerType.WhiteKing;
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i + 1, j + 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetKingAttackPositions(positions, enemies, i + 2, j + 2, tempPositionList, tempBoard);
                }
                else
                {
                    tempBoard[i + 2, j + 2] = tempBoard[i, j];
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i + 1, j + 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetCheckerAttackPositions(positions, enemies, i + 2, j + 2, tempPositionList,
                                                          tempBoard);
                }
            }

            Array.Copy(board, tempBoard, BoardSize);
            if (i + 1 < BoardLength && j - 1 > -1 && enemies.Contains(board[i + 1, j - 1]) &&
                i + 2 < BoardLength && j - 2 > -1 && board[i + 2, j - 2] == CheckerType.Empty)
            {
                if (tempBoard[i, j] == CheckerType.WhiteChecker && i + 2 == BoardLength - 1)
                {
                    tempBoard[i + 2, j - 2] = CheckerType.WhiteKing;
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i + 1, j - 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetKingAttackPositions(positions, enemies, i + 2, j - 2, tempPositionList, tempBoard);
                }
                else
                {
                    tempBoard[i + 2, j - 2] = tempBoard[i, j];
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i + 1, j - 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetCheckerAttackPositions(positions, enemies, i + 2, j - 2, tempPositionList,
                                                          tempBoard);
                }
            }

            Array.Copy(board, tempBoard, BoardSize);
            if (i - 1 > -1 && j - 1 > -1 && enemies.Contains(board[i - 1, j - 1]) &&
                i - 2 > -1 && j - 2 > -1 && board[i - 2, j - 2] == CheckerType.Empty)
            {
                if (tempBoard[i, j] == CheckerType.BlackChecker && i - 2 == 0)
                {
                    tempBoard[i - 2, j - 2] = CheckerType.BlackKing;
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i - 1, j - 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetKingAttackPositions(positions, enemies, i - 2, j - 2, tempPositionList, tempBoard);
                }
                else
                {
                    tempBoard[i - 2, j - 2] = tempBoard[i, j];
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i - 1, j - 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetCheckerAttackPositions(positions, enemies, i - 2, j - 2, tempPositionList,
                                                          tempBoard);
                }
            }

            Array.Copy(board, tempBoard, BoardSize);
            if (i - 1 > -1 && j + 1 < BoardLength && enemies.Contains(board[i - 1, j + 1]) &&
                i - 2 > -1 && j + 2 < BoardLength && board[i - 2, j + 2] == CheckerType.Empty)
            {
                if (tempBoard[i, j] == CheckerType.BlackChecker && i - 2 == 0)
                {
                    tempBoard[i - 2, j + 2] = CheckerType.BlackKing;
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i - 1, j + 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetKingAttackPositions(positions, enemies, i - 2, j + 2, tempPositionList, tempBoard);
                }
                else
                {
                    tempBoard[i - 2, j + 2] = tempBoard[i, j];
                    tempBoard[i, j]         = CheckerType.Empty;
                    tempBoard[i - 1, j + 1] = CheckerType.Empty;
                    var tempPositionArr = new string[position.Count];
                    Array.Copy(position.ToArray(), tempPositionArr, tempPositionArr.Length);
                    var tempPositionList = tempPositionArr.ToList();
                    tempPositionList.Add(GetStringBoard(tempBoard));
                    positions = GetCheckerAttackPositions(positions, enemies, i - 2, j + 2, tempPositionList,
                                                          tempBoard);
                }
            }

            foreach (var pos in positions)
            {
                var c = 0;
                for (var k = 0; k < Math.Min(pos.Count, position.Count); k++)
                {
                    if (pos[k] == position[k])
                    {
                        c++;
                    }
                }

                if (c == Math.Min(pos.Count, position.Count))
                {
                    return(positions);
                }
            }

            if (position.Count == 0)
            {
                return(positions);
            }

            var tempPos = new string[position.Count];

            Array.Copy(position.ToArray(), tempPos, tempPos.Length);
            positions.Add(tempPos.ToList());

            return(positions);
        }
Example #14
0
        protected List <List <string> > GetKingsPosition(List <List <string> > positions, int i, int j)
        {
            var position  = new List <string>();
            var tempBoard = new CheckerType[BoardLength, BoardLength];

            Array.Copy(ArrayBoard, tempBoard, BoardSize);
            var i1 = i;
            var j1 = j;

            while (i1 + 1 < BoardLength && j1 + 1 < BoardLength && tempBoard[i1 + 1, j1 + 1] == CheckerType.Empty)
            {
                tempBoard[i1 + 1, j1 + 1] = tempBoard[i1, j1];
                tempBoard[i1, j1]         = CheckerType.Empty;
                position.Add(GetStringBoard(tempBoard));
                positions.Add(position);
                position = new List <string>();
                i1++;
                j1++;
            }

            Array.Copy(ArrayBoard, tempBoard, BoardSize);
            i1 = i;
            j1 = j;
            while (i1 + 1 < BoardLength && j1 - 1 > -1 && tempBoard[i1 + 1, j1 - 1] == CheckerType.Empty)
            {
                tempBoard[i1 + 1, j1 - 1] = tempBoard[i1, j1];
                tempBoard[i1, j1]         = CheckerType.Empty;
                position.Add(GetStringBoard(tempBoard));
                positions.Add(position);
                position = new List <string>();
                i1++;
                j1--;
            }

            Array.Copy(ArrayBoard, tempBoard, BoardSize);
            i1 = i;
            j1 = j;
            while (i1 - 1 > -1 && j1 - 1 > -1 && tempBoard[i1 - 1, j1 - 1] == CheckerType.Empty)
            {
                tempBoard[i1 - 1, j1 - 1] = tempBoard[i1, j1];
                tempBoard[i1, j1]         = CheckerType.Empty;
                position.Add(GetStringBoard(tempBoard));
                positions.Add(position);
                position = new List <string>();
                i1--;
                j1--;
            }

            Array.Copy(ArrayBoard, tempBoard, BoardSize);
            i1 = i;
            j1 = j;
            while (i1 - 1 > -1 && j1 + 1 < BoardLength && tempBoard[i1 - 1, j1 + 1] == CheckerType.Empty)
            {
                tempBoard[i1 - 1, j1 + 1] = tempBoard[i1, j1];
                tempBoard[i1, j1]         = CheckerType.Empty;
                position.Add(GetStringBoard(tempBoard));
                positions.Add(position);
                position = new List <string>();
                i1--;
                j1++;
            }

            return(positions);
        }
Example #15
0
 public void TurnToQueen()
 {
     type = CheckerType.Queen;
 }