-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
182 lines (177 loc) · 10 KB
/
index.html
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html lang="en">
<head>
<title>Twilight Imperium 4 Systems Dealer | TI4</title>
<script type="module">
import * as ti4 from './__target__/_ti4_planet_selection.js';
window.ti4 = ti4;
</script>
<link rel="stylesheet" href="ti4.css" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1,minimum-scale=1">
<meta name="title" content="Twilight Imperium 4 Systems Dealer">
<meta name="description"
content="The Twilight Imperium 4 Systems Dealer allocates system tiles with balanced resource and influence for Twilight Imperium 4.">
</head>
<body>
<h1>Twilight Imperium 4 Systems Dealer</h1>
<h2>The tool</h2>
<div id="greet">
Select either base game or Prophecy of Kings (pok)
<p>Select the number of players.</p>
<p>Default creates decks balanced in resource, influence, wormholes, blanks and anomalies. In default style,
the number of red and blue backed systems in each deck will not be the same as the original rules.</p>
<p>Original creates decks balanced in resource, influence and wormholes, but tries to use the original rules
as much as possible for red systems. This means that a player might have lots of blanks or anomalies,
rather than a mix of both.</p>
<p>Warp is only valid for 5 player games, it creates a set of tiles suitable for use in a warp zone 5 player
game.</p>
<p>Large is only used for 6 player games in Prophecy of Kings where a 4 ring galaxy is used</p>
<p>Finally select how many legendary planets you want to include (0, 1 or 2)</p>
</div>
<table><tr><td>Game Version</td>
<td><select id='version' onchange="if (document.getElementById('version').value == 'base') {
document.getElementById('player7').disabled=true;
document.getElementById('player8').disabled=true;
document.getElementById('leg0').disabled=false;
document.getElementById('leg1').disabled=true;
document.getElementById('leg2').disabled=true;
} else {
document.getElementById('player7').disabled=false;
document.getElementById('player8').disabled=false;
document.getElementById('leg0').disabled=false;
document.getElementById('leg1').disabled=false;
document.getElementById('leg2').disabled=false;
}
document.getElementById('number_players').value='3';
document.getElementById('style').value='default';
document.getElementById('legendary').value='0';
">
<option>base</option>
<option>pok</option>
</select></td></tr>
<tr><td>Number of Players</td>
<td><select id='number_players' onchange="if (document.getElementById('version').value == 'base') {
document.getElementById('large').disabled=true;
document.getElementById('alternate').disabled=true;
document.getElementById('leg0').disabled=false;
document.getElementById('leg1').disabled=true;
document.getElementById('leg2').disabled=true;
document.getElementById('legendary').value='0';
if (document.getElementById('number_players').value == '5') {
document.getElementById('hyperlane').disabled=false;
} else {
document.getElementById('hyperlane').disabled=true;
if (document.getElementById('style').value=='hyperlane' ) {
document.getElementById('style').value='default';
}
}
} else {
document.getElementById('leg0').disabled=false;
document.getElementById('leg1').disabled=false;
document.getElementById('leg2').disabled=false;
if (document.getElementById('number_players').value == '3') {
document.getElementById('hyperlane').disabled=true
document.getElementById('alternate').disabled=true
document.getElementById('large').disabled=true
document.getElementById('style').value='default';
} else if (document.getElementById('number_players').value == '4') {
document.getElementById('hyperlane').disabled=true
document.getElementById('alternate').disabled=true
document.getElementById('large').disabled=true
document.getElementById('style').value='default';
} else if (document.getElementById('number_players').value == '5') {
document.getElementById('hyperlane').disabled=false
document.getElementById('alternate').disabled=true
document.getElementById('large').disabled=true
document.getElementById('style').value='default';
} else if (document.getElementById('number_players').value == '6') {
document.getElementById('hyperlane').disabled=true
document.getElementById('alternate').disabled=true
document.getElementById('large').disabled=false
document.getElementById('style').value='default';
} else if (document.getElementById('number_players').value == '7') {
document.getElementById('hyperlane').disabled=true
document.getElementById('alternate').disabled=false
document.getElementById('large').disabled=true
document.getElementById('style').value='default';
} else if (document.getElementById('number_players').value == '8') {
document.getElementById('hyperlane').disabled=true
document.getElementById('alternate').disabled=false
document.getElementById('large').disabled=true
document.getElementById('style').value='default';
}
}">
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option id='player7' disabled=true>7</option>
<option id='player8' disabled=true>8</option>
</select></td></tr>
<tr><td>Game Style</td>
<td><select id='style' onchange = "if (document.getElementById('style').value == 'large') {
document.getElementById('leg0').disabled=true;
document.getElementById('leg1').disabled=true;
document.getElementById('leg2').disabled=false;
document.getElementById('legendary').value = '2';
} else if (document.getElementById('version').value == 'pok') {
document.getElementById('leg0').disabled=false;
document.getElementById('leg1').disabled=false;
document.getElementById('leg2').disabled=false;
}">
<option>default</option>
<option>original</option>
<option id='large' disabled>large</option>
<option id='hyperlane' disabled>hyperlane</option>
<option id='alternate' disabled>alternate</option>
</select></td></tr>
<tr><td>Number of Legendary Planets</td>
<td><select id='legendary'>
<option id='leg0'>0</option>
<option id='leg1' disabled>1</option>
<option id='leg2' disabled>2</option>
</select></td></tr>
</table>
<div>
<button onclick="document.getElementById('output').innerHTML = ti4.ti4_planet_selection(
document.getElementById('number_players').value,
document.getElementById('version').value,
document.getElementById('style').value,
document.getElementById('legendary').value);">
Create the balanced decks
</button>
</div>
<div id="output"></div>
<h2>Explanation</h2>
<p>This page allocates system tiles with balanced resource and influence for Twilight Imperium 4. Each run
generates
a new set of decks, randomised within the constraints.</p>
<p>It will allocate wormholes, anomalies and blank tiles using a simple heuristic to mean that each player has a
similar total number of non-planet tiles, and each player has at most one wormhole.</p>
<p>The available resource and influence is balanced across all players, and a simple recursive backtracking
alogrithm used to pick a randomised set of tiles that balances resource and influence between players.
Technology, planet traits, and number of planets are not balanced.</p>
<p>Tile descriptions, and the heuristics to allocate non-planet tiles are factored out to ease upgrades when TI4
expansions are released.</p>
<p><img src="ti4.jpg" width="768" height="256" alt="TI4 board image from wikipedia" /></p>
<h2>Background</h2>
<p>The base rules of both Twilight Imperium 3 and 4 involve building a deck of tiles to use for the game and
then randomly allocating them to players. The group we normally play with found, over time, that this often
resulted in very unbalanced games. In Twilight Imperium 3 we found that balancing resources between each deck of
tiles was sufficient to balance the game. But with the increased importance of influence in Twilight Imperium 4,
we found that balancing both resource and influence helped to create a balanced game.</p>
<p>There is already an excellent universe builder available online for players who would prefer to skip the
universe building stage of the game. Our group enjoys building a universe; hence this script. Running the script
provides a list of systems to allocate to each player. What we normally do is build these decks, then randomly
allocate each deck out to a player.</p>
<p>In order to not have too many constraints, we do not balance technology traits, planet traits, or the number
of planets. Since these are primarily used to score secret objectives, and TI4 now involves a deck building
component to secret objectives, we are comfortable with that limitation.</p>
<h2>Source code</h2>
<p>The source is available at <a
href="http://github.com/daveah/ti4_planet_selection">http://github.com/daveah/ti4_planet_selection</a>
</p>
</body>
</html>