-
Notifications
You must be signed in to change notification settings - Fork 0
/
Life.html
131 lines (118 loc) · 4.59 KB
/
Life.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Life.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
padding-top: 40px; /* 60px to make the container go all the way to the bottom of the topbar */
overflow:hidden;
}
#controls{
position:absolute;
top:30%;
height:70%;
width:100%;
display:none;
background:white;
opacity:0.8;
}
#fitness{
position:relative;
width:100%;
height:60%;
}
#brain {
position:relative;
float:left;
height: 500px;
width: 500px;
margin: 0px;
padding: 0px;
background: #000;
}
.btn-group{
float:left;
}
</style>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="btn-group">
<button class="btn btn-primary" data-toggle="button" id="pause">Pause</button>
<button class="btn" data-toggle="button" id="showControls">Show Advanced Controls</button>
<button class="btn" data-toggle="button" id="enableLogging">Enable Logging</button>
</div>
<div class="btn-group">
<button class="btn btn-success" id="clone">Clone this agent</button>
<button class="btn btn-danger" id="kill">Kill this agent</button>
</div>
</div>
</div>
<div id="sim">
</div>
<div id="controls">
<ul class="nav nav-tabs" id="tabs">
<li class="active"><a href="#charts">Charts</a></li>
<li><a href="#agent">Selected Agent</a></li>
<li><a href="#simulation">Simulation Control</a></li>
<li><a href="#render">Render Settings</a></li>
<li><a href="#help">Help</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="charts">
<div id="fitness" class="maxHeight"></div>
</div>
<div class="tab-pane" id="agent">
<button class="btn" data-toggle="button" id="updateBrainGraph">Update Brain Graph (Slow)</button>
<canvas id="eyes" width="500px" height="500px"></canvas>
<div id="brain"></div>
</div>
<div class="tab-pane" id="simulation">...</div>
<div class="tab-pane" id="render">
<button class="btn btn-primary active" data-toggle="button" id="render_grass">Grass</button>
<div class="btn-group">
<button class="btn btn-primary" data-toggle="button" id="render_viewCones">View Cones</button>
<button class="btn btn-primary active" data-toggle="button" id="render_eyes">Eyes</button>
<button class="btn btn-primary active" data-toggle="button" id="render_indicators">Event Indicators</button>
<button class="btn btn-primary active" data-toggle="button" id="render_health">Health Bars</button>
<button class="btn btn-primary" data-toggle="button" id="render_stats">Stats</button>
</div>
</div>
<div class="tab-pane" id="help">...</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<script type="text/javascript" src="js/lib/life/jit.js"></script>
<script type="text/javascript" src="js/lib/life/Life.js"></script>
<script type="text/javascript" src="js/lib/life/LifeUI.js"></script>
<script type="text/javascript">
var simulation, view, ui;
$(document).ready(function(){
var height = document.getElementById("sim").height;
var width = document.getElementById("sim").width;
var parameters = {
height: height,
width:width,
maxAgents:70,
tickDuration:1,
agent: {babies: 1}
};
simulation = new Life.Simulation(parameters);
view = new Life.Renderer(simulation);
simulation.init();
view.init();
document.getElementById("sim").appendChild(view.canvas);
ui = new Life.UI(simulation);
});
</script>
</body>
</html>