|
Sudoku Showcase
|
Represents the atomic unit of a Sudoku puzzle: a single Field. More...
Public Member Functions | |
| def | __init__ (self, int x, int y, int value=0, bool fixed=False, set|None notes=None) |
| str | __str__ (self) |
| The represent when using str(Fieldobj) Recommended usage on console. More... | |
| int|list|None | __repr__ (self) |
| The represent when not using str(Fieldobj) More... | |
| None | printDict (self) |
| Prints all attributs of Field on cli. More... | |
| None | inspect (self) |
| Prints the public attributes of Field on cli. More... | |
| "Field" | clone (cls, "Field" other) |
| (classmethod) Returns a flat copy of a Field (call-by-value) Usage: newField = Field.clone(oldField) More... | |
| int | x (self) |
| Properties. More... | |
| int | row (self) |
| (readonly property) The row where the Field is located in the puzzle. More... | |
| int | y (self) |
| (readonly property) The y-coordinate of a Field. More... | |
| int | col (self) |
| (readonly property) The column where the Field is located in the puzzle. More... | |
| tuple[int, int] | position (self) |
| (readonly property) Position as a tuple of ints. More... | |
| tuple[int, int] | pos (self) |
| (readonly property) abbreviation for property position NOTE: The values are set on initialization. More... | |
| int|None | value (self) |
| (property) The value the Field contains NOTE: Default is None More... | |
| None | value (self, int x) |
| Set a valid value to value-property of a non-fixed Field NOTE: to clear a value,. More... | |
| bool | fixed (self) |
| (property) Wether a Field is editable or not. More... | |
| None | fixed (self, bool value) |
| Sets the property fixed to True, in other words: Locks the Field NOTE: There is no way to unlock a Field NOTE: Has to be Not-Empty to do so. More... | |
| bool | isEmpty (self) |
| (readonly property) Wether a Field has a value or not (value is None) More... | |
| set[int] | notes (self) |
| (readonly property) Returns a set of notes for the Field. More... | |
| bool | addNote (self, int x) |
| Functions. More... | |
| bool | removeNote (self, int x) |
| Removes a note from the set, if in the list. More... | |
| None | clearNotes (self) |
| Deletes the current set of notes. More... | |
| bool | clear (self) |
| The only way to set a non-fixed Field to empty (value is None). More... | |
| int | getRandomValue (cls) |
| (classmethod) Returns random valid value More... | |
Static Public Attributes | |
| NULL = None | |
| string | DEFAULT_AS_STRING = " " |
Represents the atomic unit of a Sudoku puzzle: a single Field.
A Field stores its position, value, fixed state, and possible candidate notes. It is designed with defensive programming principles and behaves as a near-immutable data object when used correctly through its public API.
The class enforces strict validation for all modifications and ensures that Sudoku constraints are respected at the field level. Direct manipulation of internal state is intentionally restricted.
A Field can:
Field provides utility functions for cloning, inspection, and random value generation (used primarily during puzzle creation).
The value setter automatically clears notes when a value is assigned, ensuring consistency between solved state and candidate state.
| def field.Field.__init__ | ( | self, | |
| int | x, | ||
| int | y, | ||
| int | value = 0, |
||
| bool | fixed = False, |
||
| set | None | notes = None |
||
| ) |
| int | list | None field.Field.__repr__ | ( | self | ) |
The represent when not using str(Fieldobj)
| str field.Field.__str__ | ( | self | ) |
The represent when using str(Fieldobj) Recommended usage on console.
| bool field.Field.addNote | ( | self, | |
| int | x | ||
| ) |
Functions.
Adds a note, if field is empty and value is allowed
| x | int - the value of the note |
| bool field.Field.clear | ( | self | ) |
The only way to set a non-fixed Field to empty (value is None).
| None field.Field.clearNotes | ( | self | ) |
Deletes the current set of notes.
| "Field" field.Field.clone | ( | cls, | |
| "Field" | other | ||
| ) |
| int field.Field.col | ( | self | ) |
(readonly property) The column where the Field is located in the puzzle.
Also known as y. NOTE: The value is set on initialization.
| bool field.Field.fixed | ( | self | ) |
(property) Wether a Field is editable or not.
| None field.Field.fixed | ( | self, | |
| bool | value | ||
| ) |
| int field.Field.getRandomValue | ( | cls | ) |
(classmethod) Returns random valid value
| None field.Field.inspect | ( | self | ) |
Prints the public attributes of Field on cli.
| bool field.Field.isEmpty | ( | self | ) |
(readonly property) Wether a Field has a value or not (value is None)
| set[int] field.Field.notes | ( | self | ) |
(readonly property) Returns a set of notes for the Field.
To change the current set of notes:
| tuple[int, int] field.Field.pos | ( | self | ) |
(readonly property) abbreviation for property position NOTE: The values are set on initialization.
| tuple[int,int] field.Field.position | ( | self | ) |
(readonly property) Position as a tuple of ints.
NOTE: The values are set on initialization.
| None field.Field.printDict | ( | self | ) |
Prints all attributs of Field on cli.
| bool field.Field.removeNote | ( | self, | |
| int | x | ||
| ) |
Removes a note from the set, if in the list.
| x | int - - the value of the note to be removed from set |
| int field.Field.row | ( | self | ) |
(readonly property) The row where the Field is located in the puzzle.
Also known as x. NOTE: The value is set on initialization.
| int | None field.Field.value | ( | self | ) |
(property) The value the Field contains NOTE: Default is None
| None field.Field.value | ( | self, | |
| int | x | ||
| ) |
| int field.Field.x | ( | self | ) |
Properties.
(readonly property) The x-coordinate of a Field. Also known as row. NOTE: The value is set on initialization.
| int field.Field.y | ( | self | ) |
|
static |
|
static |