Beispiel #1
0
        } //game constructor

        public void ResetBoard() //set/reset board
        {
            active = true;

            //reset game fields
            selectedpiece = null;
            ischecked     = new bool[2];
            turn          = PSide.White;
            turn_count    = 1;

            //reset board
            PieceList.Clear();
            TakenList.Clear();
            Gameboard = new Peice[8, 8]
            {
                { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), },
                { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), },
                { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), },
                { new Peice(PType.Queen, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Queen, PSide.Black, this), },
                { new Peice(PType.King, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.King, PSide.Black, this), },
                { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), },
                { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), },
                { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), },
            };

            //prepare moves for 1st turn
            foreach (Peice peice in getPeices(Gameboard, PSide.White))
            {
                peice.UpdateMoves();
            }
        }
Beispiel #2
0
        } //game constructor

        public void ResetBoard() //set/reset board
        {
            active = true;

            //reset game fields
            selectedpiece = null;
            ischecked     = new bool[2];
            turn          = PSide.White;
            turn_count    = 1;

            //reset board
            PieceList.Clear();
            TakenList.Clear();
            if (!is960)
            {
                Gameboard = new Peice[8, 8]
                {
                    { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), },
                    { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), },
                    { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), },
                    { new Peice(PType.Queen, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Queen, PSide.Black, this), },
                    { new Peice(PType.King, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.King, PSide.Black, this), },
                    { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), },
                    { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), },
                    { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), },
                };
            }

            //if it is 960
            else
            {
                //get our types in an array to swap in
                PType[] pTypes = { PType.Rook, PType.Knight, PType.Bishop, PType.Queen, PType.King, PType.Bishop, PType.Knight, PType.Rook };;
                Random  rng    = new Random();
                //randomly swap places
                int rand = rng.Next(960);
                for (int i = 0; i < rand; i++)
                {
                    int first  = rng.Next(7);
                    int second = rng.Next(7);

                    //first
                    PType p1 = pTypes[first];
                    //second
                    PType p2 = pTypes[second];
                    //swap
                    pTypes[first]  = p2;
                    pTypes[second] = p1;
                }


                Gameboard = new Peice[8, 8]
                {
                    { new Peice(pTypes[0], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[0], PSide.Black, this), },
                    { new Peice(pTypes[1], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[1], PSide.Black, this), },
                    { new Peice(pTypes[2], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[2], PSide.Black, this), },
                    { new Peice(pTypes[3], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[3], PSide.Black, this), },
                    { new Peice(pTypes[4], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[4], PSide.Black, this), },
                    { new Peice(pTypes[5], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[5], PSide.Black, this), },
                    { new Peice(pTypes[6], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[6], PSide.Black, this), },
                    { new Peice(pTypes[7], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[7], PSide.Black, this), },
                };
            }

            //prepare moves for 1st turn
            foreach (Peice peice in getPeices(Gameboard, PSide.White))
            {
                peice.UpdateMoves();
            }
        }