-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
114 lines (84 loc) · 3.73 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
<html>
<head>
<title>Generals Bot Runner</title>
<link rel="stylesheet" href="app/vendor/bootstrap-4.0.0-alpha.6-dist/css/bootstrap.min.css"/>
<style>
.neutral{ background-color: #ccc;}
.red{ background-color: red !important;}
.green{ background-color: green !important;}
.blue{ background-color: blue !important;}
.teal{ background-color: teal !important;}
.purple{ background-color: purple !important;}
.mountain{ background: #bbbbbb url('app/images/mountain.png') center center !important;}
.city{ background-image: url('app/images/city.png') !important; background-position: center center !important;}
.city.neutral { background-color: #777777 !important; }
.general{ background-image: url('app/images/general.png') !important; background-position: center center !important;}
</style>
</head>
<body>
<div class="container mt-4" >
<h1>Generals Bot Runner</h1>
<div class="row">
<div class="col-9 col-sm-9" style="background: #efefef">
<full-map></full-map>
</div>
<div class="col-3 col-sm-3">
<bot-game-cards></bot-game-cards>
</div>
</div>
</div>
<script>
// Make node modules happy in browser
window.module={
exports:{}
}
</script>
<!-- Components -->
<script type="riot/tag" src="app/components/full-map.tag.html"></script>
<script type="riot/tag" src="app/components/bot-game-card.tag.html"></script>
<script type="riot/tag" src="app/components/bot-game-cards.tag.html"></script>
<script src="app/vendor/riotcompiler.min.js"></script>
<!-- Models -->
<script src="app/models/generals_game.js"></script>
<!-- Bots -->
<script>
sim = {
bots:[]
}
sim.RegisterBot = function(bot){
this.bots.push(new bot())
}
</script>
<script src="bots/MyBot v1/bot.js"></script>
<script>sim.RegisterBot(module.exports)</script>
<script src="bots/RandomBot v1/bot.js"></script>
<script>sim.RegisterBot(module.exports)</script>
<!-- <script src="bots/EdgeBot v1/bot.js"></script> -->
<!-- <script>sim.RegisterBot(module.exports)</script> -->
<!-- <script src="bots/PullBot v1/bot.js"></script> -->
<!-- <script>sim.RegisterBot(module.exports)</script> -->
<script>
function GameUI(){
riot.observable(this)
return this
}
gameUI = new GameUI()
var game = new GeneralsGame()
gameUI.map = game.generateMap(20, 25, sim.bots.length)
riot.mount('full-map', {gameUI: gameUI})
riot.mount('bot-game-cards', {bots: sim.bots})
gameUI.trigger("update")
var interval = setInterval(function(){
moves = []
for(var i = 0; i < sim.bots.length; i++){
moves[i] = sim.bots[i].doStep(gameUI.map, i)
}
game.doStep(gameUI.map, moves)
gameUI.trigger("update")
if(gameUI.map.step == 2000 || gameUI.map.activePlayerCount == 1){
clearInterval(interval)
}
}, 500)
</script>
</body>
</html>