@@ -78,7 +78,7 @@ def reset_pathfinding(self):
78
78
for dot in self .dots .values ():
79
79
dot .neighbors_obsolete = True
80
80
81
- def text_to_dots (self , text , ignore_terrain = "" ):
81
+ def text_to_dots (self , text , ignore_terrain = "" , convert_to_int = False ):
82
82
"""
83
83
Converts a text to a set of dots
84
84
@@ -94,14 +94,18 @@ def text_to_dots(self, text, ignore_terrain=""):
94
94
for line in text .splitlines ():
95
95
for x in range (len (line )):
96
96
if line [x ] not in ignore_terrain :
97
+ if convert_to_int :
98
+ value = int (line [x ])
99
+ else :
100
+ value = line [x ]
97
101
if self .is_isotropic :
98
- self .dots [x - y * 1j ] = Dot (self , x - y * 1j , line [ x ] )
102
+ self .dots [x - y * 1j ] = Dot (self , x - y * 1j , value )
99
103
else :
100
104
for dir in self .possible_source_directions .get (
101
- line [ x ] , self .direction_default
105
+ value , self .direction_default
102
106
):
103
107
self .dots [(x - y * 1j , dir )] = Dot (
104
- self , x - y * 1j , line [ x ] , dir
108
+ self , x - y * 1j , value , dir
105
109
)
106
110
y += 1
107
111
@@ -150,7 +154,7 @@ def dots_to_text(self, mark_coords={}, void=" "):
150
154
for y in range (max_y , min_y - 1 , - 1 ):
151
155
for x in range (min_x , max_x + 1 ):
152
156
try :
153
- text += mark_coords [x + y * 1j ]
157
+ text += str ( mark_coords [x + y * 1j ])
154
158
except (KeyError , TypeError ):
155
159
if x + y * 1j in mark_coords :
156
160
text += "X"
0 commit comments