public void goBack() { if (gameTree.parent != null) { gameTree = gameTree.parent; } }
public void mainContinuation() { if (gameTree.continuations.Count > 0) { gameTree = gameTree.continuations[0].Item2; } }
public GameTree addContinuation(Move move) { GameTree newTree = new GameTree(move.execute(pos), this); continuations.Add(new Variation(move, newTree)); return(newTree); }
public void removeContinuation(GameTree continuation) { for (int i = 0; i < continuations.Count; i++) { if (continuations[i].Item2 == continuation) { continuations.RemoveAt(i); } } }
public void addMove(Move move) { GameTree gt = gameTree.continuation(move); if (gt != null) { gameTree = gt; } else { gameTree = gameTree.addContinuation(move); } }
public void takeback(int numberOfMoves) { if (gameTree.parent == null || numberOfMoves <= 0) { return; } else { gameTree.parent.removeContinuation(gameTree); gameTree = gameTree.parent; takeback(numberOfMoves - 1); } }
public Game(Position customStartingPosition, string[] players) { gameTree = new GameTree(customStartingPosition); firstGameTreeNode = gameTree; this.players = players; }
public Game(Position customStartingPosition) { gameTree = new GameTree(customStartingPosition); firstGameTreeNode = gameTree; players = new string[] { "Human player", "Blobfish 11" }; }
public Game() { gameTree = new GameTree(); firstGameTreeNode = gameTree; players = new string[] { "Human player", "Blobfish 11" }; }
public void goToFirstPosition() { gameTree = firstGameTreeNode; }
public string toString(GameTree nodeToBeBald) { string ret = ""; if (continuations.Count > 0) { if (continuation(0) == nodeToBeBald) { ret += @"\b "; } if (pos.whiteToMove) { ret += pos.moveCounter + "."; } ret += getMove(0).toString(pos) + " "; if (continuation(0) == nodeToBeBald) { ret += @"\b0 "; } if (continuations.Count > 1) { for (int i = 1; i < continuations.Count; i++) { ret += "("; if (continuation(i) == nodeToBeBald) { ret += @"\b "; } ret += pos.moveCounter; if (pos.whiteToMove) { ret += "."; } else { ret += "..."; } ret += getMove(i).toString(pos); if (continuation(i) == nodeToBeBald) { ret += @"\b0 "; } string cont = continuation(i).toString(nodeToBeBald); if (cont != "") { ret += " " + cont; } ret += ") "; } string mainLine = continuation(0).toString(nodeToBeBald); if (mainLine != "") { if (pos.whiteToMove) { ret += pos.moveCounter; ret += "..."; } ret += mainLine; } } else { ret += continuation(0).toString(nodeToBeBald); } } return(ret); }
public GameTree(Position position, GameTree parent, List <Variation> continuations) { this.pos = position; this.parent = parent; this.continuations = continuations; }
public GameTree(Position position, GameTree parent) { this.pos = position; this.parent = parent; }
public GameTree(Position position) { this.pos = position; this.parent = null; }
public GameTree() { this.pos = Game.startingPosition; this.parent = null; }