-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotting.py
48 lines (40 loc) · 1.05 KB
/
plotting.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
from maptools import *
def plotTerritories( borders, terr ):
x = [t.x for t in terr]
y = [t.y for t in terr]
names = [t.name for t in terr]
plt.scatter(x,y)
for t in terr:
c = 'gray'
style = 'square'
if t.terrain == "coastal":
style = 'round'
elif t.terrain == "sea":
c = 'blue'
style = 'round'
plt.annotate( t.name, (t.x, t.y),
horizontalalignment='center', verticalalignment='center',
bbox=dict(facecolor=c, boxstyle=style))
print(names)
def plotBorders( borders, terr ):
for A,B in borders:
c = 'black'
if borders[A,B].type == 'fleets':
c = 'blue'
elif borders[A,B].type == 'armies':
c = 'brown'
Ax = getTerritory(terr, A).x
Ay = getTerritory(terr, A).y
Bx = getTerritory(terr, B).x
By = getTerritory(terr, B).y
plt.plot([Ax, Bx], [Ay, By], color=c)
def plotUnits( borders, u ):
print(u)
def plotMap( borders, terr, units ):
plotTerritories( borders, terr )
plotBorders( borders, terr )
plotUnits( borders, units )
plt.show()