import { ControlVariable, Runtime, RuntimeConstructor } from 'agentscape/runtime' import { CellGrid, AgentSet } from 'agentscape/structures' import { Angle } from 'agentscape/numbers' import Agent from './Agent' import Cell from './Cell' export default class {{className}} extends Runtime < Cell, Agent > { @ControlVariable() gridSize: number @ControlVariable() agentCount: number @ControlVariable() randomSeed: number constructor(opts: RuntimeConstructor) { super(opts) this.setRandomSeed(this.randomSeed) } initAgents() { const _default = AgentSet.fromFactory( this.agentCount, (_, randomSeed) => new Agent({ initialPosition: [ Math.floor(this.gridSize / 2), Math.floor(this.gridSize / 2), ], rotation: Angle.random(this.rng), randomSeed, }), { randomSeed: this.randomSeed } ) return { _default } } initGrid() { return CellGrid.default(this.gridSize, { boundaryCondition: 'periodic', }) } }