/// <summary> /// Fills the map of shadow items based on the state of markups. /// </summary> /// <param name="boardSize">Size of game board.</param> /// <param name="kind">Kind of sequence markup. (Letter, Number)</param> /// <returns>Map of shadow items.</returns> public string[,] FillSequenceShadowMap(GameBoardSize boardSize, SequenceMarkupKind kind) { string shadow; string[,] shadows = new string[boardSize.Width, boardSize.Height]; if (kind == SequenceMarkupKind.Letter) { shadow = GetSmallestUnusedLetter().ToString(); } else { shadow = GetSmallestUnusedNumber().ToString(); } for (int x = 0; x < boardSize.Width; x++) { for (int y = 0; y < boardSize.Height; y++) { shadows[x, y] = shadow; } } foreach (var label in GetMarkups <Label>()) { shadows[label.Position.X, label.Position.Y] = "r"; } return(shadows); }
public void FillBoardStateOfRoot(GameBoardSize boardSize, IRuleset ruleset) { if (Parent != null) { throw new InvalidOperationException("Only call this on a root."); } FillBoardStateInternal(new GameBoard(boardSize), new GroupState(ruleset.RulesetInfo), ruleset); }
/// <summary> /// Creates a game tree with a given ruleset /// </summary> public GameTree(IRuleset ruleset, GameBoardSize boardSize) { Ruleset = ruleset; BoardSize = boardSize; GameTreeRoot = new GameTreeNode(); GameTreeRoot.BoardState = new GameBoard(boardSize); GameTreeRoot.GroupState = new GroupState(ruleset.RulesetInfo); LastNode = GameTreeRoot; }
public GameInfo(PlayerInfo whitePlayerInfo, PlayerInfo blackPlayerInfo, GameBoardSize boardSize, RulesetType rulesetType, int numberOfHandicapStones, HandicapPlacementType handicapPlacementType, float komi, CountingType countingType) { White = whitePlayerInfo; Black = blackPlayerInfo; BoardSize = boardSize; RulesetType = rulesetType; NumberOfHandicapStones = numberOfHandicapStones; HandicapPlacementType = handicapPlacementType; Komi = komi; CountingType = countingType; }
/// <summary> /// Creates a game tree with a given ruleset and root /// </summary> /// <param name="ruleset">Ruleset</param> /// <param name="boardSize">Board size</param> /// <param name="gameTreeRoot">Root</param> public GameTree(IRuleset ruleset, GameBoardSize boardSize, GameTreeNode gameTreeRoot) { Ruleset = ruleset; BoardSize = boardSize; GameTreeRoot = gameTreeRoot; var lastNode = gameTreeRoot; while (lastNode.NextNode != null) { lastNode = lastNode.NextNode; } LastNode = lastNode; }
internal SgfPoint ToSgfPoint(GameBoardSize size) => new SgfPoint(X, size.Height - Y - 1);
/// <summary> /// Converts SGF point to Position /// </summary> /// <param name="sgfPoint">SGF point</param> /// <param name="size">Game board size is used for reversing Y coordinates.</param> /// <returns>Position</returns> internal static Position FromSgfPoint(SgfPoint sgfPoint, GameBoardSize size) => new Position(sgfPoint.Column, size.Height - sgfPoint.Row - 1);
/// <summary> /// Fills the map of shadow items based on the state of markups. /// </summary> /// <param name="boardSize">Size of game board.</param> /// <param name="kind">Kind of simple markup. (Circle, Cross, Square, Triangle)</param> /// <returns>Map of shadow items.</returns> public char[,] FillSimpleShadowMap(GameBoardSize boardSize, SimpleMarkupKind kind) { char[,] shadows = new char[boardSize.Width, boardSize.Height]; switch (kind) { case SimpleMarkupKind.Circle: { for (int x = 0; x < boardSize.Width; x++) { for (int y = 0; y < boardSize.Height; y++) { shadows[x, y] = 'c'; } } foreach (var circle in GetMarkups <Circle>()) { shadows[circle.Position.X, circle.Position.Y] = 'r'; } } return(shadows); case SimpleMarkupKind.Cross: { for (int x = 0; x < boardSize.Width; x++) { for (int y = 0; y < boardSize.Height; y++) { shadows[x, y] = 'x'; } } foreach (var cross in GetMarkups <Cross>()) { shadows[cross.Position.X, cross.Position.Y] = 'r'; } } return(shadows); case SimpleMarkupKind.Square: { for (int x = 0; x < boardSize.Width; x++) { for (int y = 0; y < boardSize.Height; y++) { shadows[x, y] = 's'; } } foreach (var square in GetMarkups <Square>()) { shadows[square.Position.X, square.Position.Y] = 'r'; } } return(shadows); case SimpleMarkupKind.Triangle: { for (int x = 0; x < boardSize.Width; x++) { for (int y = 0; y < boardSize.Height; y++) { shadows[x, y] = 't'; } } foreach (var triangle in GetMarkups <Triangle>()) { shadows[triangle.Position.X, triangle.Position.Y] = 'r'; } } return(shadows); } return(shadows); }
/// <summary> /// Initializes a new <see cref="GameBoard"/> with the specified dimensions. /// </summary> /// <param name="boardSize">Size of the board.</param> public GameBoard(GameBoardSize boardSize) { _board = new StoneColor[boardSize.Width, boardSize.Height]; this.Size = boardSize; }