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
Toggle between fast mode vs. visualisation mode in Love.
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: Toggle between fast mode vs. visualisation mode in Love.
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:
Which is completely untested.
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Toggle between fast mode vs. visualisation mode in Love.
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.DaedalusYoung wrote:set the value of dt back to something like 0.016 or even 1.
Also, watch out with the vsync thing: if it is initially disabled, it will be activated at the wrong time.
Help us help you: attach a .love.
Re: Toggle between fast mode vs. visualisation mode in Love.
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
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
Who is online
Users browsing this forum: No registered users and 0 guests