Errors and Utils
Any error explicitly raised by towers is defined here.
-
exception
towers.core.errors.
InvalidRod
(rod)[source]
-
__init__
(rod)[source]
Parameters: | rod (object) – The Rod which is invalid. |
-
exception
towers.core.errors.
InvalidRods
(rods)[source]
-
__init__
(rods)[source]
Parameters: | rods (object) – The Rods which are invalid |
-
exception
towers.core.errors.
InvalidRodHeight
(rod, max_height)[source]
-
__init__
(rod, max_height)[source]
Parameters: |
- rod (Rod) – The
Rod which has an invalid height.
- max_height (int) – The max allowed height of the
Rod .
|
-
exception
towers.core.errors.
DuplicateDisk
(rod, disk_width)[source]
A duplicate disk was found on a tower.
-
__init__
(rod, disk_width)[source]
Parameters: |
- rod (Rod) – The duplicate
Rod .
- disk_width (int) – The width of the
Disk .
|
-
exception
towers.core.errors.
CorruptRod
(rod, disk)[source]
A Rod
with an invalid stack of disks was found.
-
__init__
(rod, disk)[source]
Parameters: |
- rod (Rod) – The
Rod which is corrupt.
- disk (int) – A
Disk which sits directly atop a smaller Disk .
|
-
exception
towers.core.errors.
InvalidStartingConditions
(rods, moves)[source]
The Rods
for the towers are not in the correct starting state.
-
__init__
(rods, moves)[source]
Parameters: |
- rods (Rod) – The
Rod ‘s.
- moves (int) – Total number of moves already made (should be zero).
|
-
exception
towers.core.errors.
InvalidEndingConditions
(rods)[source]
The Rod
‘s for the towers are not in the correct ending state.
-
__init__
(rods)[source]
Parameters: | rods (Rod) – The Rod ‘s. |
-
exception
towers.core.errors.
InvalidTowerHeight
(height)[source]
The height of the Tower
is invalid.
-
__init__
(height)[source]
Parameters: | height (int) – The invalid height. |
-
exception
towers.core.errors.
InvalidDiskPosition
(position, height)[source]
The position of the Disk
is invalid.
-
__init__
(position, height)[source]
Parameters: |
- position (int) – The invalid position on the
Rod .
- height (int) – The height.
|
-
exception
towers.core.errors.
InvalidMoves
(moves)[source]
An invalid number of moves.
-
__init__
(moves)[source]
Parameters: | moves (int) – The invalid moves. |
Note
Main towers.core.utils.Serializable is used by all main classes: Towers, Rods, Rod, Disk
-
class
towers.core.utils.
Serializable
[source]
A mixin which shows that a class is serializable.
-
from_json
(d)[source]
Return a class instance from a json serializable representation.
Parameters: | d (str|dict) – The json or decoded-json from which to create a new instance from. |
-
to_json
()[source]
Return a json serializable representation of this instance.