Jump to content

Phaser Update Speed


Zef
 Share

Recommended Posts

Hi there,

 

I am currently using phaser for a simulation of life evolving a neural network inside little creatures. This relies on generation after generation of these creatures being evolved with a genetic algorithm. I am currently relying on the arcade physics system to handle collisions and overlaps etc, and the little creatures survive by eating food, and hunting each other. Or at least that is what they should learn to do.

 

Currently each round last 45 seconds, this in itself isn't a problem, but I have been trying to find a way to step the Phaser engine at the fastest speed possible so that I can complete a number of simulations in the shortest possible time. It can take 1000s of generations before the creatures evolve to show intelligent behaviour. 

 

I am struggling to achieve this at present. I have tried using game.enableStep() and then in the update function calling game.step() more than once but this doesn't appear to work. Does anyone know how I can do this?

 

Thanks for you help.

 

ps. I have made a little site showcasing the neural network http://jozefmaxted.co.uk/neural/index.html I plan to add more examples and will put the code up on Github soon. Its the sort of thing that will be really handy for creating AI for games.

Link to comment
Share on other sites

I'm sure there will be a way to do it. If I am correct requestAniimationFrame will cap at 60fps, but I presume that is just calling the phaser update function. All I need is some way of calling update more than once each time. Thanks for your help ;p

Link to comment
Share on other sites

I'd say what you need to do is to separate your logic from the rendering loop altogether. Do your calculations on a short (or even 0) length timeout so they can run as fast as you need, and then have the Phaser update loop just render the results each time it's called. You should not be trying to call Phaser's update routine any faster than the browser can render it, as that becomes highly wasteful and will severely reduce performance.

Link to comment
Share on other sites

For what it's worth, you can still use things such as Rectangle.intersects and the heavier, less performant Sprite.overlap to do overlap detection as often as your simulation loop occurs. There probably is a way to hook into the physics system directly and run it within your simulation loop however I think this question is best left to someone with more intimate knowledge of how this is wired into the framework.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...