import math
import matplotlib.pyplot as plt
def plotDartBoard(values, n):
fig = plt.figure(figsize = (12, 12))
ax = fig.add_subplot(111,
xlim = (-1.05, 1.05),
ylim = (-1.05, 1.05))
#Remove axes and ticks.
for side in ['bottom', 'left', 'top', 'right']:
ax.spines[side].set_visible(False)
ax.set_xticks([])
ax.set_yticks([])
#Circles.
db_border = plt.Circle((0,0), 0.98, color = "#595959")
db = plt.Circle((0,0), 0.97, color = "#EEEEEE")
ax.add_patch(db_border)
ax.add_patch(db)
#Sectors
for i in (list(range(0, 19)) + [-1]):
#Lines.
a = math.radians(18*i+9)
xa = 0.975*math.cos(a)
ya = 0.975*math.sin(a)
plt.plot((0, xa),
(0, ya),
c = "#595959",
lw = 3)
#Points.
b = math.radians(18*i)
xb = 1.03*math.cos(b)
yb = 1.03*math.sin(b)
plt.annotate(values[i],
(xb, yb),
c = "k",
fontsize = 18,
ha = "center",
va = "center")
#EVs
ev = 0.25 * values[i-1] + 0.5 * values[i]+ 0.25 * values[i+1]
xc = 0.75*math.cos(b)
yc = 0.75*math.sin(b)
plt.annotate(ev,
(xc, yc),
c = "#22A844",
fontsize = 18,
ha = "center",
va = "center")
fig.savefig("2023.01.27 Express" + str(n) + ".png")
original = [11, 14, 9, 12, 5,
20, 1, 18, 4, 13,
6, 10, 15, 2, 17,
3, 19, 7, 16, 8]
plotDartBoard(original, 1)
optimized = [15, 5, 17, 3, 19,
1, 20, 2, 18, 4,
16, 6, 14, 8, 12,
10, 11, 9, 13, 7]
optimized = [6, 16, 4, 18, 2,
20, 1, 19, 3, 17,
5, 15, 7, 13, 9,
11, 10, 12, 8, 14]
plotDartBoard(optimized, 2)