-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.py
30 lines (26 loc) · 1.21 KB
/
display.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# display.py - A simple way to trace the intermediate steps of algorithms.
# AIFCA Python3 code Version 0.9.5 Documentation at http://aipython.org
# Download the zip file and read aipython.pdf for documentation
# Artificial Intelligence: Foundations of Computational Agents http://artint.info
# Copyright David L Poole and Alan K Mackworth 2017-2023.
# This work is licensed under a Creative Commons
# Attribution-NonCommercial-ShareAlike 4.0 International License.
# See: http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en
class Displayable(object):
"""Class that uses 'display'.
The amount of detail is controlled by max_display_level
"""
max_display_level = 1 # can be overridden in subclasses
def display(self,level,*args,**nargs):
"""print the arguments if level is less than or equal to the
current max_display_level.
level is an integer.
the other arguments are whatever arguments print can take.
"""
if level <= self.max_display_level:
print(*args, **nargs) ##if error you are using Python2 not Python3
def visualize(func):
"""A decorator for algorithms that do interactive visualization.
Ignored here.
"""
return func