In [12]:
import numpy as np
In [13]:
inf = open('testworlds/world01.csv')
In [14]:
data = np.array([list(map(float, s.strip().split(','))) for s in inf.readlines()])
originalmap = data.copy() #make a copy so we can revert to the original map later
In [15]:
originalmap
Out[15]:
In [16]:
data
Out[16]:
In [33]:
# print out the map
def printmap(data):
print("-"*data.shape[1]*3)
for row in range(0, data.shape[0]):
line_str = ""
for col in range(0, data.shape[1]):
if data[row,col] == 0:
line_str += " "
if data[row,col] == 1:
line_str += " o "
if data[row,col] == 2:
line_str += " * "
if data[row,col] == 3:
line_str += " X "
if data[row,col] == 4:
line_str += " . "
if data[row,col] == 5:
line_str += " S "
print(line_str)
print("-"*data.shape[1]*3)
In [34]:
printmap(data)
In [ ]: