示例#1
0
        public string MyHashCode()
        {
            string hash = "";

            Pieces.OrderBy(e => e.Row).ThenBy(e => e.Col).ToList().ForEach(e => {
                hash += e.Color.ToString().Substring(0, 1);
                switch (e.Name)
                {
                case "Rook":
                    {
                        hash += "R";
                        break;
                    }

                case "Queen":
                    {
                        hash += "Q";
                        break;
                    }

                case "Knight":
                    {
                        hash += "N";
                        break;
                    }

                case "King":
                    {
                        hash += "K";
                        break;
                    }

                case "Pawn":
                    {
                        hash += "P";
                        break;
                    }

                case "Bishop":
                    {
                        hash += "B";
                        break;
                    }
                }
                hash += e.Row.ToString() + e.Col.ToString() + "~";
            });
            hash = hash.Remove(hash.Length - 1, 1);

            return(hash);
        }
示例#2
0
        private void GenerateRandomOrder()
        {
            while (nextPieces.Count < 3)
            {
                // generate random bag order (all pieces in random order) and add to nextpieces
                Pieces[] temp = new Pieces[(int)Pieces.Length];
                for (int i = 0; i < (int)Pieces.Length; i++)
                {
                    temp[i] = (Pieces)i;
                }

                Pieces[] tempArray = temp.OrderBy(x => rand.Next()).ToArray();

                foreach (Pieces p in tempArray)
                {
                    nextPieces.Add(p);
                }
            }

            nextPiece = nextPieces[0];
            nextPieces.Remove(nextPiece);
        }
示例#3
0
 public void RecalculateValidMoves()
 {
     Pieces.OrderBy(x => (RoundManager.CurrentActor.Color == PlayerColor.Black ? -1 : 1) * (int)(x.Owner))
     .ToList()
     .ForEach(p => p.RecalculateValidMoves(this));
 }