-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathants.html
58 lines (40 loc) · 1.55 KB
/
ants.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
<!DOCTYPE html>
<head>
<title>Ants</title>
<script type="module" src="./uielements.html.js"></script>
<link rel="stylesheet" href="./uielements.css" />
</head>
<body>
<script type="module">
import * as UI from './uielements.js'
import elements from './antsElements.js'
// ====== The views2mv code as-is ======
import Animator from 'https://code.agentscript.org/src/Animator.js'
import TwoDraw from 'https://code.agentscript.org/src/TwoDraw.js'
import Model from 'https://code.agentscript.org/models/AntsModel.js'
import TwoDrawOptions from 'https://code.agentscript.org/views2mv/antsOptions.js'
const model = new Model()
model.setup()
const view = new TwoDraw(model, TwoDrawOptions("modelDiv", model, 8))
const anim = new Animator(
() => {
model.step()
view.draw()
},
500, // how many steps
30 // at fps steps/second
)
// ====== Additional code for uielements usage ======
anim.stop() // let uielements start/stop animator
anim.setSteps(-1) // in case you want to run forever
await UI.setAppState(model, view, anim) // connect model to uielements
// UI.createElements() // create elements from persistent storage
UI.createElements(elements, true) // create elements from file
</script>
<!-- <div>
<div id="modelDiv"></div>
<div id="plotDiv"></div>
</div> -->
<div id="modelDiv"></div>
</body>
</html>