Пример #1
0
            public ISet <IAction> Actions(object state)
            {
                NQueensBoard board = (NQueensBoard)state;

                ISet <IAction> actions = new HashedSet <IAction>();

                var numQueens = board.GetNumberOfQueensOnBoard();
                var boardSize = board.Size;

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

                return(actions);
            }