示例#1
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public void goBack()
 {
     if (gameTree.parent != null)
     {
         gameTree = gameTree.parent;
     }
 }
示例#2
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public void mainContinuation()
 {
     if (gameTree.continuations.Count > 0)
     {
         gameTree = gameTree.continuations[0].Item2;
     }
 }
示例#3
0
        public GameTree addContinuation(Move move)
        {
            GameTree newTree = new GameTree(move.execute(pos), this);

            continuations.Add(new Variation(move, newTree));
            return(newTree);
        }
示例#4
0
 public void removeContinuation(GameTree continuation)
 {
     for (int i = 0; i < continuations.Count; i++)
     {
         if (continuations[i].Item2 == continuation)
         {
             continuations.RemoveAt(i);
         }
     }
 }
示例#5
0
文件: Game.cs 项目: Zchpoor/Blobfish
        public void addMove(Move move)
        {
            GameTree gt = gameTree.continuation(move);

            if (gt != null)
            {
                gameTree = gt;
            }
            else
            {
                gameTree = gameTree.addContinuation(move);
            }
        }
示例#6
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public void takeback(int numberOfMoves)
 {
     if (gameTree.parent == null || numberOfMoves <= 0)
     {
         return;
     }
     else
     {
         gameTree.parent.removeContinuation(gameTree);
         gameTree = gameTree.parent;
         takeback(numberOfMoves - 1);
     }
 }
示例#7
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public Game(Position customStartingPosition, string[] players)
 {
     gameTree          = new GameTree(customStartingPosition);
     firstGameTreeNode = gameTree;
     this.players      = players;
 }
示例#8
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public Game(Position customStartingPosition)
 {
     gameTree          = new GameTree(customStartingPosition);
     firstGameTreeNode = gameTree;
     players           = new string[] { "Human player", "Blobfish 11" };
 }
示例#9
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public Game()
 {
     gameTree          = new GameTree();
     firstGameTreeNode = gameTree;
     players           = new string[] { "Human player", "Blobfish 11" };
 }
示例#10
0
文件: Game.cs 项目: Zchpoor/Blobfish
 public void goToFirstPosition()
 {
     gameTree = firstGameTreeNode;
 }
示例#11
0
        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);
        }
示例#12
0
 public GameTree(Position position, GameTree parent, List <Variation> continuations)
 {
     this.pos           = position;
     this.parent        = parent;
     this.continuations = continuations;
 }
示例#13
0
 public GameTree(Position position, GameTree parent)
 {
     this.pos    = position;
     this.parent = parent;
 }
示例#14
0
 public GameTree(Position position)
 {
     this.pos    = position;
     this.parent = null;
 }
示例#15
0
 public GameTree()
 {
     this.pos    = Game.startingPosition;
     this.parent = null;
 }