agentscript
Version:
AgentScript Model in Model/View architecture
41 lines (33 loc) • 937 B
HTML
<html>
<head>
<title>Pheromone2</title>
</head>
<body>
<div id="modelDiv"></div>
<script type="module">
import { util, TwoDraw, ColorMap, Animator } from './agentscript.js'
import Model from './PheromoneModel.js'
const colorMap = ColorMap.gradientColorMap(
8, ['black', 'purple', 'yellow']
)
const model = new Model() // no arge => use default world options
model.setup()
const view = new TwoDraw(model, {
div: 'modelDiv',
patchSize: 20,
drawOptions: {
turtlesSize: 2,
patchesColor: (p) => colorMap.scaleColor(p.pheromone, 0, 100)
}
})
const anim = new Animator(
() => {
model.step()
view.draw()
},
500, // run 500 steps
30 // 30 fps
)
</script>
</body>
</html>