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); }
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(); }
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); }
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); }
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); }
public KnightMoveStrategy(Board board) { _board = board; }
public void test_invalid_position_throws_exception() { Board b = new Board(); b.GetKey(new BoardPosition() { X = -5, Y = 1000 }); }
public void test_get_key() { Board b = new Board(); Key k = b.GetKey(new BoardPosition() { X = 0, Y = 0 }); Assert.AreEqual(k, Key.A); }
public SequenceGenerator(Board board, IMoveStrategy moveStrategy, int pathSize) { _board = board; _moveStrategy = moveStrategy; _pathSize = pathSize; }