Occurs after the Play button has been clicked on the VisualBots control or the Play method has been executed.
Private Sub object_OnSimBegin(ByVal World As World, ByVal Bots As Bots,ByVal Cells As Cells)
object A reference to a World control object sited on a Worksheet.
World Required. Returns a reference to the World object.
Bots Required. Returns a reference to the Bots object.
Cells Required. Returns a reference to the Cells object.
Use the OnSimStep event to handle object interaction and movement for a simulation.
The following example is a simulation to visually mimic the appearance of randomly moving worms. 100 Bot objects are created and corresponding properties modified when the OnSimBegin event is triggered at the beginning of the simulation. Then for each time step, the OnSimStep event is triggered, which randomly moves the Bot objects.
Private Sub World1_OnSimBegin(ByVal World As World, ByVal Worms As Bots, ByVal Cells As Cells)
World.Screen.Resize 350, 350
World.Screen.BackColor = vbBlack
World.Screen.FadeRate = 0.04
Worms.Create 100
Worms.Shape = vbtPoint
Worms.Color = vbBlue
Worms.Size = 3
Worms.Pen.ColorRand
Worms.Pen.Width = 2
Worms.Pen.Down
End Sub
Private Sub World1_OnSimStep(ByVal World As World, ByVal Worms As Bots, ByVal Cells As Cells)
Worms.TurnRand -30, 30
Worms.Step 1
End Sub