コード例 #1
0
	public void setUp() {
		oneBoard = new NQueensBoard(1);
		eightBoard = new NQueensBoard(8);

		af = NQueensFunctionFactory.getIActionsFunction();
		rf = NQueensFunctionFactory.getResultFunction();
	}
コード例 #2
0
 public void testSingleSquareBoard()
 {
     board = new NQueensBoard(1);
     Assert.IsFalse(goalTest(board));
     board.addQueenAt(new XYLocation(0, 0));
     Assert.IsTrue(goalTest(board));
 }
コード例 #3
0
        public void testSimpleBoardSuccessorGenerator()
        {
            ICollection <QueenAction> actions = CollectionFactory.CreateQueue <QueenAction>(actionsFn.apply(oneBoard));

            Assert.AreEqual(1, actions.Size());
            NQueensBoard next = resultFn.apply(oneBoard, actions.Get(0));

            Assert.AreEqual(1, next.getNumberOfQueensOnBoard());
        }
コード例 #4
0
        public void testPrint()
        {
            NQueensBoard board2 = new NQueensBoard(2);

            board2.addQueenAt(new XYLocation(0, 0));
            string expected = " Q  - \n -  - \n";

            Assert.AreEqual(expected, board2.getBoardPic());
        }
コード例 #5
0
        public void setUp()
        {
            oneBoard   = new NQueensBoard(1);
            eightBoard = new NQueensBoard(8);
            board      = new NQueensBoard(8);

            actionsFn = NQueensFunctions.getIFActionsFunction();
            resultFn  = NQueensFunctions.getResultFunction();
            goalTest  = NQueensFunctions.testGoal;
        }
コード例 #6
0
        public void testEquality()
        {
            board.addQueenAt(new XYLocation(0, 0));
            NQueensBoard board2 = new NQueensBoard(8);

            board2.addQueenAt(new XYLocation(0, 0));
            Assert.AreEqual(board, board2);
            NQueensBoard board3 = new NQueensBoard(8);

            board3.addQueenAt(new XYLocation(0, 1));
            Assert.IsFalse(board.Equals(board3));
        }
コード例 #7
0
        public void test_getBoardForIndividual()
        {
            NQueensBoard board = NQueensGenAlgoUtil
                                 .getBoardForIndividual(new Individual <int>(CollectionFactory.CreateQueue <int>(new[] { 5, 6, 1, 3, 6, 4, 7, 7 })));

            Assert.AreEqual(" -  -  -  -  -  -  -  - \n"
                            + " -  -  Q  -  -  -  -  - \n" + " -  -  -  -  -  -  -  - \n"
                            + " -  -  -  Q  -  -  -  - \n" + " -  -  -  -  -  Q  -  - \n"
                            + " Q  -  -  -  -  -  -  - \n" + " -  Q  -  -  Q  -  -  - \n"
                            + " -  -  -  -  -  -  Q  Q \n", board.getBoardPic());

            Assert.AreEqual("--------\n" + "--Q-----\n" + "--------\n"
                            + "---Q----\n" + "-----Q--\n" + "Q-------\n" + "-Q--Q---\n"
                            + "------QQ\n", board.ToString());
        }
コード例 #8
0
	public void testSingleSquareBoard() {
		board = new NQueensBoard(1);
		Assert.assertFalse(goalTest.isGoalState(board));
		board.addQueenAt(new XYLocation(0, 0));
		Assert.assertTrue(goalTest.isGoalState(board));
	}
コード例 #9
0
	public void setUp() {
		goalTest = new NQueensGoalTest();
		board = new NQueensBoard(8);
	}
コード例 #10
0
 public void setUp()
 {
     board = new NQueensBoard(8);
 }
コード例 #11
0
	public void testPrint() {

		NQueensBoard board2 = new NQueensBoard(2);
		board2.addQueenAt(new XYLocation(0, 0));
		String expected = " Q  - \n -  - \n";
		Assert.assertEquals(expected, board2.getBoardPic());
	}
コード例 #12
0
	public void testEquality() {

		board.addQueenAt(new XYLocation(0, 0));
		NQueensBoard board2 = new NQueensBoard(8);
		board2.addQueenAt(new XYLocation(0, 0));
		Assert.assertEquals(board, board2);
		NQueensBoard board3 = new NQueensBoard(8);
		board3.addQueenAt(new XYLocation(0, 1));
		Assert.assertFalse(board.equals(board3));
	}
コード例 #13
0
	public void setUp() {

		board = new NQueensBoard(8);
	}