internal void Restart() { if (IsGameOver) { return; } _polygame.Restart(); _polygame.Reseed(Seed); // FIX: should not be needed TimePlayed = TimeSpan.Zero; UpdatePieces(); }
//========================================================================== internal void PlayMe(bool mefirst = true, int initseed = 0, int nsteps = 300) { var maxdepth = 9; _out.WriteLine("\nPlay me '{0}' seed={1} steps={2} maxdepth={3} first={4}\n", Game.Title, initseed, nsteps, maxdepth, mefirst); // play a series of games var myplayer = Game.FirstPlayer; // FIX: var input = "i"; while (true) { if (input == "i") { Game.Reseed(initseed); Game.NewBoard(); Game.StepCount = nsteps; Game.MaxDepth = maxdepth; } else if (input == "n") { Game.NewBoard(); } else if (input == "r") { Game.Restart(); } if (Logger.Level >= 2) { ShowState(); } // for each move var pick = -1; for (int moveno = 0; input != ""; moveno++) { if (Game.GameResult != ResultKinds.None) { break; } if (Game.TurnPlayer == myplayer) { ShowBoard(); ShowMoves(); do { var prompt = String.Format("[{0}] Your move (of {1}): ", Logger.Level, Game.LegalMoves.Count); input = Program.GetInput(prompt, "|[rn]?[0-9]+"); if (input == "") { break; } else if (input.StartsWith("n")) { Logger.Level = input.Substring(1).SafeIntParse() ?? Logger.Level; } else { pick = input.SafeIntParse() ?? -1; } } while (!(pick >= 0 && pick < Game.LegalMoves.Count)); } else { Game.UpdateChooser(); var done = Game.UpdateChooser(); Logger.WriteLine(3, "Update returns {0}", done); pick = Game.ChosenMove.Index; } if (pick >= 0) { Logger.WriteLine(1, "{0} make move {1} of {2}: {3}", Game.TurnPlayer, pick, Game.LegalMoves.Count, Game.GetLegalMove(pick).ToString("P")); Game.MakeMove(pick); } } Logger.WriteLine("Game result: {0}", Game.GameResult); while (true) { var prompt = String.Format("[{0}] Init, New or Restart game: ", Logger.Level); input = Program.GetInput(prompt, "[inr]?"); if (input == "") { return; } else { break; } } } }