예제 #1
0
파일: Game.cs 프로젝트: piplay/SharpChess
        /// <summary>
        ///   Make the specified move. For internal use only.
        /// </summary>
        /// <param name="moveName"> The move name. </param>
        /// <param name="piece"> The piece to move. </param>
        /// <param name="square"> The square to move to. </param>
        private static void MakeAMoveInternal(Move.MoveNames moveName, Piece piece, Square square)
        {
            MoveRedoList.Clear();
            Move move = piece.Move(moveName, square);

            move.EnemyStatus = move.Piece.Player.OpposingPlayer.Status;
            PlayerToPlay.Clock.Stop();
            MoveHistory.Last.TimeStamp = PlayerToPlay.Clock.TimeElapsed;
            if (PlayerToPlay.Intellegence == Player.PlayerIntellegenceNames.Computer)
            {
                WinBoard.SendMove(move);
                if (!PlayerToPlay.OpposingPlayer.CanMove)
                {
                    if (PlayerToPlay.OpposingPlayer.IsInCheckMate)
                    {
                        WinBoard.SendCheckMate();
                    }
                    else if (!PlayerToPlay.OpposingPlayer.IsInCheck)
                    {
                        WinBoard.SendCheckStaleMate();
                    }
                }
                else if (PlayerToPlay.OpposingPlayer.CanClaimThreeMoveRepetitionDraw == true)
                {
                    WinBoard.SendDrawByRepetition();
                }
                else if (PlayerToPlay.OpposingPlayer.CanClaimFiftyMoveDraw == true)
                {
                    WinBoard.SendDrawByFiftyMoveRule();
                }
                else if (PlayerToPlay.OpposingPlayer.CanClaimInsufficientMaterialDraw == true)
                {
                    WinBoard.SendDrawByInsufficientMaterial();
                }
            }

            BroadcastMovedName(move);
            CheckGameStatus();
            PlayerToPlay = PlayerToPlay.OpposingPlayer;
            PlayerToPlay.Clock.Start();
        }
예제 #2
0
        /// <summary>
        /// The start thinking.
        /// </summary>
        public void StartThinking()
        {
            // Bail out if unable to move
            if (!this.MyPlayer.CanMove)
            {
                return;
            }

            // Send draw result is playing WinBoard
            if (WinBoard.Active && this.MyPlayer.Intellegence == Player.PlayerIntellegenceNames.Computer)
            {
                if (this.MyPlayer.CanClaimThreeMoveRepetitionDraw)
                {
                    WinBoard.SendDrawByRepetition();
                    return;
                }

                if (this.MyPlayer.CanClaimFiftyMoveDraw)
                {
                    WinBoard.SendDrawByFiftyMoveRule();
                    return;
                }

                if (this.MyPlayer.CanClaimInsufficientMaterialDraw)
                {
                    WinBoard.SendDrawByFiftyMoveRule();
                    return;
                }
            }

            this.threadThought      = new Thread(this.Think);
            this.threadThought.Name = (++Game.ThreadCounter).ToString();

            this.ThinkingBeginningEvent();
            this.threadThought.Priority = ThreadPriority.Normal;

            this.threadThought.Start();
        }