Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var gi = new GameInfo();
            var g = new Game(gi);
            g.SetupMove(1, 3, Content.Black);
            g.SetupMove(1, 4, Content.Black);
            g.SetupMove(2, 2, Content.Black);
            g.SetupMove(2, 5, Content.Black);
            g.SetupMove(3, 3, Content.Black);
            g.SetupMove(3, 1, Content.Black);
            g.SetupMove(4, 1, Content.Black);
            g.SetupMove(5, 2, Content.Black);

            g.SetupMove(2, 3, Content.White);
            g.SetupMove(2, 4, Content.White);
            g.SetupMove(3, 2, Content.White);
            g.SetupMove(3, 4, Content.White);
            g.SetupMove(3, 5, Content.White);
            g.SetupMove(4, 2, Content.White);
            g.SetupMove(4, 4, Content.White);
            g.SetupMove(5, 3, Content.White);

            Console.WriteLine("{0}", g.Board);
            var result = g.MakeMove(4, 3);
            Console.WriteLine("{0}", result.Board);
        }
Exemplo n.º 2
0
 private static void CreateGameTree(SGFGameTree root, Game p)
 {
     if (p.GameInfo != null)
     {
         foreach (var m in root.Sequence.GetRootProperties())
         {
             if (PropertyHandlers.ContainsKey(m.Name))
                 PropertyHandlers[m.Name](p, m);
             if (!PropertiesToExclude.Contains(m.Name))
                 p.sgfProperties.Add(m);
         }
         p.InitializeFromGameInfo();
     }
     foreach (var m in root.Sequence.GetProperties())
     {
         if (PropertyHandlers.ContainsKey(m.Name))
             p = PropertyHandlers[m.Name](p, m);
         if (!PropertiesToExclude.Contains(m.Name))
             p.sgfProperties.Add(m);
     }
     foreach (var r in root.GameTrees)
     {
         CreateGameTree(r, p);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Makes a 'pass' move and returns a new Game object representing the state after 
 /// the move. The color of the move is determined by the Turn property.
 /// </summary>
 /// <returns>A game object representing the state of the game after the move.</returns>
 public Game Pass()
 {
     var g = new Game(this);
     moves.Add(Game.PassMove, g);
     return g;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Makes a move and returns a new Game object representing the state after the
 /// move. The move is carried out whether it is legal or illegal (for example,
 /// an overwrite move). The color of the move is determined by the Turn property.
 /// If the move was illegal (suicide, violating super-ko, or an overwrite), the
 /// method sets the legal parameter to false, otherwise it is set to true.
 /// </summary>
 /// <param name="x">The X coordinate of the move.</param>
 /// <param name="y">The Y coordinate of the move.</param>
 /// <param name="legal">Set to true if the move was legal, false otherwise.</param>
 /// <returns>A game object representing the state of the game after the move.</returns>
 public Game MakeMove(int x, int y, out bool legal)
 {
     var g = new Game(this);
     legal = g.InternalMakeMove(x, y);
     moves.Add(new Point(x, y), g);
     return g;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructs a Game object from an existing Game object. This constructor is used when making
 /// game moves.
 /// </summary>
 /// <param name="fromGame">The Game object before the move.</param>
 protected Game(Game fromGame)
 {
     Board = new Board(fromGame.Board);
     Turn = fromGame.Turn.Opposite();
     captures[Content.White] = fromGame.captures[Content.White];
     captures[Content.Black] = fromGame.captures[Content.Black];
     foreach (var p in fromGame.superKoSet) superKoSet.Add(p);
     Root = fromGame.Root;
 }
Exemplo n.º 6
0
 public void SerializeToSGFTest1()
 {
     GameInfo gi = new GameInfo();
     gi.BoardSizeX = gi.BoardSizeY = 9;
     gi.FreePlacedHandicap = false;
     gi.Handicap = 3;
     gi.Komi = 7.5;
     gi.StartingPlayer = Content.White;
     Game target = new Game(gi);
     target.SetupMove(5, 5, Content.Black);
     target.SetupMove(6, 5, Content.Black);
     target.SetupMove(8, 5, Content.White);
     target.MakeMove(5, 7).MakeMove(6, 7);
     target.MakeMove(5, 8);
     string expected = @"(;AB[cc][gg][gc][ff][gf]AW[if]HA[3]PL[W]KM[7.50]SZ[9](;W[fh];B[gh])(;W[fi]))";
     string actual;
     actual = target.SerializeToSGF(null);
     Assert.AreEqual(expected, actual);
 }