Skip to content

Instantly share code, notes, and snippets.

@phenomist
Created June 9, 2017 22:12
Show Gist options
  • Save phenomist/c955720ff5be361434d091f06b6b5790 to your computer and use it in GitHub Desktop.
Save phenomist/c955720ff5be361434d091f06b6b5790 to your computer and use it in GitHub Desktop.
Python script to plot color-coded buildings in the game Castle Age
from PIL import Image
f = open("buildinglist.csv")
colordict = {"Castle":(255,0,0),
"Gold Mine":(255,255,0),
"Iron Mine":(192,192,192),
"Sawmill":(128,64,0),
"Quarry":(64,64,64),
"Forge":(255,0,255),
"Market-Place":(0,255,0),
"Storehouse":(0,0,255),
"Farm":(0,255,255),
"Town Hall":(255,255,255)}
camap = []
for x in range(501):
camap.append([(0,0,0)]*501)
for e in f.read().split("\n"):
z = e.split(",")
if len(z)>5:
if z[4] == " no relatio":
z[4] = z[5]
camap[250-int(z[2])][250+int(z[1])]=colordict[z[4]]
res = []
for e in camap:
res += e
i = Image.new("RGB", (501,501))
i.putdata(res)
i.save("ca_bldgmap.png", "PNG")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment