user2989977
user2989977

Reputation: 45

How to make my game not lag in netlogo

im creating a a model of the classic arcade game dig dug in netlogo. So I tried o create a level and have monsters moving 3 steps forward and 3 steps back constantly in their areas but when i try to play the game lags and becomes very slow. please help

to stalk
ask monsters
[
  fd 1 wait .1 
fd 1 wait .5
fd 1 wait .5
bk 1 wait .5
bk 1 wait .5
bk 1 wait .5
 ]

 end

i tried putting this code as a forever button but then the game becomes slow. how do i set the monsters to pace around constantly while the hero moves around in the game?

(plz review dig-dug if your not sure what it is]

Upvotes: 2

Views: 276

Answers (1)

StephenGuerin
StephenGuerin

Reputation: 871

The lag is coming from the use of wait.

You should regulate the speed of your monsters by using mod with ticks or by having a 'speed' variable. Here's example code for the first approach:

; move monsters every 10th tick
to move-monsters
  if ticks mod 10 = 0 [ask monsters [fd 1]]
end

Upvotes: 2

Related Questions