getNumberOfQueensOnBoard() public method

public getNumberOfQueensOnBoard ( ) : int
return int
コード例 #1
0
ファイル: NQueensGoalTest.cs プロジェクト: claudiu04/AIMA.Net
        public bool isGoalState(Object state)
        {
            NQueensBoard board = (NQueensBoard)state;

            return(board.getNumberOfQueensOnBoard() == board.getSize() &&
                   board.getNumberOfAttackingPairs() == 0);
        }
コード例 #2
0
            public HashSet <Action> actions(Object state)
            {
                NQueensBoard board = (NQueensBoard)state;

                HashSet <Action> actions = new LinkedHashSet <Action>();

                int numQueens = board.getNumberOfQueensOnBoard();
                int boardSize = board.getSize();

                for (int i = 0; i < boardSize; i++)
                {
                    XYLocation newLocation = new XYLocation(numQueens, i);
                    if (!(board.isSquareUnderAttack(newLocation)))
                    {
                        actions.Add(new QueenAction(QueenAction.PLACE_QUEEN,
                                                    newLocation));
                    }
                }

                return(actions);
            }