コード例 #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
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
        public GameTree addContinuation(Move move)
        {
            GameTree newTree = new GameTree(move.execute(pos), this);

            continuations.Add(new Variation(move, newTree));
            return(newTree);
        }
コード例 #4
0
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
 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
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
        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
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
 public GameTree(Position position, GameTree parent, List <Variation> continuations)
 {
     this.pos           = position;
     this.parent        = parent;
     this.continuations = continuations;
 }
コード例 #13
0
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
 public GameTree(Position position, GameTree parent)
 {
     this.pos    = position;
     this.parent = parent;
 }
コード例 #14
0
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
 public GameTree(Position position)
 {
     this.pos    = position;
     this.parent = null;
 }
コード例 #15
0
ファイル: GameTree.cs プロジェクト: Zchpoor/Blobfish
 public GameTree()
 {
     this.pos    = Game.startingPosition;
     this.parent = null;
 }