コード例 #1
0
 public void test_generate_sequence_pathsize_1()
 {
     Board b = new Board();
     IMoveStrategy strategy = new KnightMoveStrategy(b);
     SequenceGenerator generator = new SequenceGenerator(b, strategy, 10);
     int count = generator.CountAllSequences();
     Assert.IsTrue(count > 0);
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: gartdan/KnightMoves
 static void Main(string[] args)
 {
     Board b = new Board();
     IMoveStrategy moveStrategy = new KnightMoveStrategy(b);
     SequenceGenerator generator = new SequenceGenerator(b, moveStrategy, 3);
     int numMoves = generator.CountAllSequences();
     Console.WriteLine(numMoves.ToString());
     //Console.ReadLine();
 }
コード例 #3
0
ファイル: BoardTest.cs プロジェクト: gartdan/KnightMoves
        public void test_get_possible_moves()
        {
            Board b = new Board();
            var strategy = new KnightMoveStrategy(b);
            var results = strategy.GetPossibleMoves(Key.H);
            Assert.AreEqual(6, results.Count);

            results = strategy.GetPossibleMoves(Key.A);
            Assert.AreEqual(2, results.Count);
        }
コード例 #4
0
        public void test_count_sequences_from_key()
        {
            Board b = new Board();
            IMoveStrategy strategy = new KnightMoveStrategy(b);
            SequenceGenerator generator = new SequenceGenerator(b, strategy, 2);
            int numMoves = generator.CountSequencesFromKey(Key.A, new KeypadSequence().Add(Key.A));

            Assert.AreEqual(2, numMoves);

            numMoves = generator.CountSequencesFromKey(Key.H, new KeypadSequence().Add(Key.H));
            Assert.AreEqual(6, numMoves);
        }
コード例 #5
0
ファイル: BoardTest.cs プロジェクト: gartdan/KnightMoves
        public void test_get_position()
        {
            Board b = new Board();
            BoardPosition position = b.GetPosition(Key.A);
            Assert.AreEqual(0, position.X);
            Assert.AreEqual(0, position.Y);

            position = b.GetPosition(Key.H);
            Assert.AreEqual(2, position.X);
            Assert.AreEqual(1, position.Y);

            position = b.GetPosition(Key.N1);

            Assert.AreEqual(1, position.X);
            Assert.AreEqual(3, position.Y);
        }
コード例 #6
0
 public KnightMoveStrategy(Board board)
 {
     _board = board;
 }
コード例 #7
0
ファイル: BoardTest.cs プロジェクト: gartdan/KnightMoves
 public void test_invalid_position_throws_exception()
 {
     Board b = new Board();
     b.GetKey(new BoardPosition() { X = -5, Y = 1000 });
 }
コード例 #8
0
ファイル: BoardTest.cs プロジェクト: gartdan/KnightMoves
 public void test_get_key()
 {
     Board b = new Board();
     Key k = b.GetKey(new BoardPosition() { X = 0, Y = 0 });
     Assert.AreEqual(k, Key.A);
 }
コード例 #9
0
 public SequenceGenerator(Board board, IMoveStrategy moveStrategy, int pathSize)
 {
     _board = board;
     _moveStrategy = moveStrategy;
     _pathSize = pathSize;
 }