You're reading the documentation for a development version. For the latest released version, please have a look at master.
queens_reasoner.utils
Functions
|
Create and configure a logger with a standard format. |
|
Print a formatted Queens puzzle solution to the terminal. |
|
Format an integer value with optional terminal coloring. |
Module Contents
- queens_reasoner.utils.create_logger(name)[source]
Create and configure a logger with a standard format.
- Parameters:
name (str) – Logger name, typically in
"package::module"format.- Returns:
Configured logger instance.
- Return type:
logging.Logger
- queens_reasoner.utils.print_queens_solution(mat, mask)[source]
Print a formatted Queens puzzle solution to the terminal.
The board layout is displayed as a colored NumPy array where queen positions are highlighted using terminal color formatting.
Internally, queen cells are represented as negative values to allow conditional coloring during NumPy array formatting.
- Parameters:
mat (np.ndarray) – Sparse matrix of the puzzle layout. Each entry contains the integer color ID of a cell.
mask (np.ndarray) – Dense matrix indicating queen placements.
1is a queen,0is a non-queen,-1is unknown.
- Returns:
None
- Return type:
None
- queens_reasoner.utils.mark_ndarray(x, marker='*', anti_marker='x')[source]
Format an integer value with optional terminal coloring.
Negative values are highlighted using designated markers. Positive values are printed normally.
- Parameters:
x (int) – Integer value to format.
marker (str) – Character used as the queen marker.
anti_marker (str) – Character used as the non-queen marker.
- Returns:
Formatted string.
- Return type:
str
Example
>>> mark_ndarray(-3) '3*' >>> mark_ndarray(5) '5x' >>> mark_ndarray(10007) ' '