Example #1
0
        /// <summary>
        /// Start a new game from the specified FEN string position. For internal use only.
        /// </summary>
        /// <param name="fenString">
        /// The str fen.
        /// </param>
        private static void NewInternal(string fenString)
        {
            if (fenString == string.Empty)
            {
                fenString = Fen.GameStartPosition;
            }

            Fen.Validate(fenString);

            HashTable.Clear();
            HashTablePawnKing.Clear();
            HashTableCheck.Clear();
            KillerMoves.Clear();
            History.Clear();

            UndoAllMovesInternal();
            MoveRedoList.Clear();
            saveGameFileName = string.Empty;
            Fen.SetBoardPosition(fenString);
            PlayerWhite.Clock.Reset();
            PlayerBlack.Clock.Reset();
        }
Example #2
0
        /// <summary>
        ///   Initializes static members of the <see cref = "Game" /> class.
        /// </summary>
        static Game()
        {
            ClockIncrementPerMove = new TimeSpan(0, 0, 0);
            ClockFixedTimePerMove = new TimeSpan(0, 0, 0);
            DifficultyLevel       = 1;
            ClockTime             = new TimeSpan(0, 5, 0);
            ClockMaxMoves         = 40;
            UseRandomOpeningMoves = true;
            MoveRedoList          = new Moves();
            MaximumSearchDepth    = 1;
            MoveAnalysis          = new Moves();
            MoveHistory           = new Moves();
            FenStartPosition      = string.Empty;
            HashTable.Initialise();
            HashTablePawnKing.Initialise();
            HashTableCheck.Initialise();

            PlayerWhite  = new PlayerWhite();
            PlayerBlack  = new PlayerBlack();
            PlayerToPlay = PlayerWhite;
            Board.EstablishHashKey();
            OpeningBookSimple.Initialise();

            PlayerWhite.Brain.ReadyToMakeMoveEvent += PlayerReadyToMakeMove;
            PlayerBlack.Brain.ReadyToMakeMoveEvent += PlayerReadyToMakeMove;

            RegistryKey registryKeySoftware = Registry.CurrentUser.OpenSubKey("Software", true);

            if (registryKeySoftware != null)
            {
                RegistryKey registryKeySharpChess = registryKeySoftware.CreateSubKey(@"PeterHughes.org\SharpChess");

                if (registryKeySharpChess != null)
                {
                    if (registryKeySharpChess.GetValue("FileName") == null)
                    {
                        saveGameFileName = string.Empty;
                    }
                    else
                    {
                        saveGameFileName = registryKeySharpChess.GetValue("FileName").ToString();
                    }

                    if (registryKeySharpChess.GetValue("ShowThinking") == null)
                    {
                        ShowThinking = true;
                    }
                    else
                    {
                        ShowThinking = registryKeySharpChess.GetValue("ShowThinking").ToString() == "1";
                    }

                    // Delete deprecated values
                    if (registryKeySharpChess.GetValue("EnablePondering") != null)
                    {
                        registryKeySharpChess.DeleteValue("EnablePondering");
                    }

                    if (registryKeySharpChess.GetValue("DisplayMoveAnalysisTree") != null)
                    {
                        registryKeySharpChess.DeleteValue("DisplayMoveAnalysisTree");
                    }

                    if (registryKeySharpChess.GetValue("ClockMoves") != null)
                    {
                        registryKeySharpChess.DeleteValue("ClockMoves");
                    }

                    if (registryKeySharpChess.GetValue("ClockMinutes") != null)
                    {
                        registryKeySharpChess.DeleteValue("ClockMinutes");
                    }
                }
            }

            // OpeningBook.BookConvert(Game.PlayerWhite);
        }