Exemple #1
0
        public void Solve(IPlotter plotter)
        {
            // Given a magnitude N
            // Place N queens in a NxN chess board
            // in such a way that no queens attack each other

            const int size  = 8;
            var       board = _strategy.Solve(size);

            plotter.Plot(" ");
            for (var file = 1; file <= board.Size; file++)
            {
                plotter.Plot(" ");
                plotter.Plot(file.ToString());
            }
            plotter.PlotLine("");
            for (var rank = 1; rank <= board.Size; rank++)
            {
                plotter.Plot(rank.ToString());
                for (var file = 1; file <= board.Size; file++)
                {
                    plotter.Plot(" ");
                    plotter.Plot(board[rank, file].HasQueen ? "Q" : "-");
                }
                plotter.PlotLine("");
            }
        }