Page 1 of 1
Toggle between fast mode vs. visualisation mode in Love.
Posted: Thu Aug 28, 2014 9:55 pm
by ctf20
Dear All,
I am using Lua Love to visualise a game. I am evolving agents to play the game, and since this is a long process where speed of simulation is essential for most of the time I want love.update to run without the overhead of visualisation. I want this to run very fast for 1000s of games but only when I press a button do I want the visualisation to start so I can check how well evolution is progressing.
How can I toggle between 'fast mode' and slow visualisation mode using a key press in Love? How can visualisation be switched off for 'fast mode'?
Thanks in Advance,
Chrisantha
Re: Toggle between fast mode vs. visualisation mode in Love.
Posted: Thu Aug 28, 2014 10:50 pm
by DaedalusYoung
Turn off vsync using
love.window.setMode and then set the value of
dt back to something like 0.016 or even 1. And disable the
love.draw function while in fast-forward mode.
So for example, something like this:
Code: Select all
local fastforward = false
function love.update(dt)
if fastforward then
dt = 1
end
-- do calculations here * dt
end
function love.draw()
if not fastforward then
-- draw your stuff here
end
end
function love.keypressed(key, repeat)
if key == "f" then
local w, h, flag = love.window.getMode()
flag.vsync = not flag.vsync
fastforward = not fastforward
love.window.setMode(w, h, flag)
end
end
Which is completely untested.
Re: Toggle between fast mode vs. visualisation mode in Love.
Posted: Fri Aug 29, 2014 9:20 am
by Robin
DaedalusYoung wrote:set the value of dt back to something like 0.016 or even 1.
That may or may not be a good idea, depending on what you want to do in love.update: some simulations lose accuracy when given too large a time-step.
Also, watch out with the vsync thing: if it is initially disabled, it will be activated at the wrong time.
Re: Toggle between fast mode vs. visualisation mode in Love.
Posted: Thu Jun 28, 2018 9:23 am
by lorinc
Hello,
I'm having a related question.
I write a game where you build entities whose behavior is based on simple neural networks. Think of a handful of neurons per bot, not much more. The neurons behave like agents, and the controlled bots as well.
I'd like to show the player the living network, that is, the charge of each neurons at any moment, and also the firings.
My question is - what love2d mechanics do I use to draw the neurons?
- ParticleSystem: Is it even possible to do it with this?
- newArrayImage: Create sprites and display the state with those?
- Shaders: is it efficient to pass the unique parameters of each neuron to a shader?
- other idea?
Thanks,
Lorinc