/// <summary> /// Places the fixed handicap stones based on the game info /// </summary> protected void PlaceHandicapStones() { var gameInfo = Controller.Info; if (gameInfo.NumberOfHandicapStones > 0) { Controller.OnDebuggingMessage("Placing " + gameInfo.NumberOfHandicapStones + " fixed handicap stones..."); GameBoard gameBoard = new GameBoard(Controller.Info.BoardSize); var positions = FixedHandicapPositions.GetHandicapStonePositions(gameInfo.BoardSize, gameInfo.NumberOfHandicapStones).ToArray(); GroupState groupState = Controller.Ruleset.RulesetInfo.GroupState; //set game board stones foreach (var position in positions) { gameBoard[position.X, position.Y] = StoneColor.Black; groupState.AddStoneToBoard(position, StoneColor.Black); } //reflect the number of placed stones to listeners StonesPlaced = gameInfo.NumberOfHandicapStones; //add the board to game Controller.GameTree.AddToEnd(positions, new Position[0], gameBoard, new GroupState(groupState, Controller.Ruleset.RulesetInfo)); } }
public void ResumeWorking() { Controller.OnDebuggingMessage("KGS fixed handicap: Waking up..."); if (_gameController.HandicapPositions.Count == _gameController.Info.NumberOfHandicapStones) { Controller.OnDebuggingMessage("KGS fixed handicap: Placing stones..."); GameBoard gameBoard = new GameBoard(Controller.Info.BoardSize); GroupState groupState = Controller.Ruleset.RulesetInfo.GroupState; var positions = _gameController.HandicapPositions; //set game board stones foreach (var position in positions) { gameBoard[position.X, position.Y] = StoneColor.Black; groupState.AddStoneToBoard(position, StoneColor.Black); } //reflect the number of placed stones to listeners StonesPlaced = _gameController.Info.NumberOfHandicapStones; //add the board to game Controller.GameTree.AddToEnd(positions.ToArray(), new Position[0], gameBoard, new GroupState(groupState, Controller.Ruleset.RulesetInfo)); GoToPhase(Modes.LiveGame.Phases.GamePhaseType.Main); } else { // Wait for the rest. Controller.OnDebuggingMessage("KGS fixed handicap: Not enough stones! Will wake up later..."); } }