summaryrefslogtreecommitdiff
path: root/tools/genmove.js
blob: a4ebae79f20ca8eb52a4913a6cc8d6cf1bc98885 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"use strict"

function array_insert(array, index, item) {
	for (let i = array.length; i > index; --i)
		array[i] = array[i - 1]
	array[index] = item
}

function set_add(set, item) {
	let a = 0
	let b = set.length - 1
	while (a <= b) {
		let m = (a + b) >> 1
		let x = set[m]
		if (item < x)
			b = m - 1
		else if (item > x)
			a = m + 1
		else
			return
	}
	array_insert(set, a, item)
}

const ITALIA = 0
const ASIA = 1
const GALLIA = 2
const MACEDONIA = 3
const PANNONIA = 4
const THRACIA = 5

const BRITANNIA = 6
const GALATIA = 7
const SYRIA = 8

const AEGYPTUS = 9
const AFRICA = 10
const HISPANIA = 11

const ALAMANNI_HOMELAND = 12
const FRANKS_HOMELAND = 13
const GOTHS_HOMELAND = 14
const SASSANIDS_HOMELAND = 15
const NOMADS_HOMELAND = 16

const MARE_OCCIDENTALE = 17
const MARE_ORIENTALE = 18
const OCEANUS_ATLANTICUS = 19
const PONTUS_EUXINUS = 20

const names = [
	"ITALIA",
	"ASIA",
	"GALLIA",
	"MACEDONIA",
	"PANNONIA",
	"THRACIA",
	"BRITANNIA",
	"GALATIA",
	"SYRIA",
	"AEGYPTUS",
	"AFRICA",
	"HISPANIA",
	"ALAMANNI_HOMELAND",
	"FRANKS_HOMELAND",
	"GOTHS_HOMELAND",
	"SASSANIDS_HOMELAND",
	"NOMADS_HOMELAND",
	"MARE_OCCIDENTALE",
	"MARE_ORIENTALE",
	"OCEANUS_ATLANTICUS",
	"PONTUS_EUXINUS",
]

const ADJACENT = [ [] ]

for (let a = 1; a <= 21; ++a)
	ADJACENT[a] = []

function adj(a, ...bs) {
	for (let b of bs) {
		set_add(ADJACENT[a], b)
		set_add(ADJACENT[b], a)
	}
}

adj(ITALIA, GALLIA, PANNONIA, MARE_OCCIDENTALE)
adj(AEGYPTUS, AFRICA, SYRIA, NOMADS_HOMELAND, MARE_ORIENTALE)
adj(AFRICA, HISPANIA, AEGYPTUS, NOMADS_HOMELAND, MARE_OCCIDENTALE, MARE_ORIENTALE, OCEANUS_ATLANTICUS)
adj(ASIA, THRACIA, GALATIA, PONTUS_EUXINUS, MARE_ORIENTALE)
adj(BRITANNIA, OCEANUS_ATLANTICUS)
adj(GALATIA, ASIA, SYRIA, SASSANIDS_HOMELAND, PONTUS_EUXINUS, MARE_ORIENTALE)
adj(GALLIA, HISPANIA, ITALIA, PANNONIA, FRANKS_HOMELAND, OCEANUS_ATLANTICUS, MARE_OCCIDENTALE)
adj(HISPANIA, AFRICA, GALLIA, OCEANUS_ATLANTICUS, MARE_OCCIDENTALE)
adj(MACEDONIA, PANNONIA, THRACIA, MARE_OCCIDENTALE, MARE_ORIENTALE)
adj(PANNONIA, ITALIA, GALLIA, THRACIA, MACEDONIA, FRANKS_HOMELAND, ALAMANNI_HOMELAND, MARE_OCCIDENTALE)
adj(SYRIA, AEGYPTUS, GALATIA, SASSANIDS_HOMELAND, MARE_ORIENTALE)
adj(THRACIA, PANNONIA, MACEDONIA, ASIA, GOTHS_HOMELAND, PONTUS_EUXINUS, MARE_ORIENTALE)

adj(ALAMANNI_HOMELAND, FRANKS_HOMELAND, PANNONIA, THRACIA, GOTHS_HOMELAND)
adj(FRANKS_HOMELAND, GALLIA, PANNONIA, ALAMANNI_HOMELAND, OCEANUS_ATLANTICUS)
adj(GOTHS_HOMELAND, ALAMANNI_HOMELAND, THRACIA, PONTUS_EUXINUS)
adj(NOMADS_HOMELAND, OCEANUS_ATLANTICUS, AFRICA, AEGYPTUS)
adj(SASSANIDS_HOMELAND, PONTUS_EUXINUS, GALATIA, SYRIA)

adj(MARE_OCCIDENTALE, OCEANUS_ATLANTICUS, MARE_ORIENTALE)

adj(ALAMANNI_HOMELAND)

console.log("const ADJACENT = [")
for (let i = 0; i < 21; ++i) {
	console.log("\t/*", names[i], "*/ [", ADJACENT[i].map(i => names[i]).join(", "), "],")
}
console.log("]")