void Start() { if (gameModeIndexSet) { gameMode = (GameMode)gameModeIndex; } if (gameMode == GameMode.Regular) { // GetComponent<ClockGround>().StartClock(); } BoardGround.SetPositionFromFen(DefinitionsGround.gameStartFen, true); ZobristKeyGround.Init(); EvaluationGround.Init(); if (regenerateOpeningBook) { OpeningBookGeneratorGround.GenerateBook(); } if (useOpeningBook) { OpeningBookReaderGround.Init(); } playerManager = GetComponent <MoveManagerGround> (); playerManager.CreatePlayers(); BoardGround.SetPositionFromFen(DefinitionsGround.gameStartFen, true); }
public override void RequestMove() { moveSearchStartTime = UnityEngine.Time.time; base.RequestMove(); bool bookMovePlayed = false; if (OpeningBookReaderGround.IsInBook() && GameManagerGround.instance.useOpeningBook) { UnityEngine.Debug.Log("In Book"); Random prng = new Random(); List <ushort> bookMoves = OpeningBookReaderGround.GetBookMoves(); ushort randomBookMove = bookMoves[prng.Next(0, bookMoves.Count)]; if (first) { first = false; //randomBookMove = sic; } if (moveGenerator.GetMoves(false, false).Contains(randomBookMove)) // ensure book move is legal (possible for zobrist keys to have hashed wrong position) { UnityEngine.Debug.Log("Book move"); HandleAIMove(randomBookMove); bookMovePlayed = true; } else { UnityEngine.Debug.LogError("Book error"); } } if (!bookMovePlayed) { moveRequested = true; searcher.StartSearch(); } }