• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
vazix

Estimating a physics engine's performance

3 posts in this topic

Hello,

I have visited gamedev forums a while ago with different epic game ideas and concepts. With my current understanding of programming I realize how complex can even a simple card game get with different interactions between players, cards and so on...

Since I am a physics student and a fan of 2D Worms games, I tried my luck at creating a physics engine prototype, with which I would hopefully make everything (besides characters,weapons...) out of tiny particles, thus destructible and uniform.

My current working demo using javascript and canvas.

If I risk of having some simulation bugs and weird particle behaviours, I could get almost 10 000 particles to be simulated at 30 fps. By fiddling with the speed of simulation and other variables I was able to achieve some sort of soft bodies that would break appart if they hit the ground with a too great speed.

 

The biggest obstacle to my goal is uncompressable fluids and solid objects. For example: if a solid box hits the ground, I would want it to stop almost instantly. My way of doing the simulation is to calculate only the interactions between nearby particles (usually one to six) per one interation. If my box is 100px tall and I want it to stop moving in 5 frames, I would have to do at least 20 iterations per frame to have it (the top part) compleatly stopped if the gaps between the particles is one pixel.

This rought benchmark demo tells me that only 5 000 000 simple calculation cycles can be executed by javascript per one frame, which is a lot less than I would need to simulate 2048*1024 particles (my goal for something like full HD playing world) with the previously mentioned fast responses. My reasons to have everything made out of particles are more game-play specific, but I am also keen on finding out if its at all possible.

 

I am looking into OpenCl to ("port") create my physics engine in. I am starting to get familliar with the kernels and all that good stuff, but before moving on I would like to know if there is a good way to estimate a worst case scnario performance of my game engine. Is it possible to determine if my engine would be possible with just a base knowledge of how many calculations I will need to carry out? Do I need to create a full physics engine prototype just to know where the unexpected bottlenecks appear?

 

I can give more details on how my engine works (its all in the webpage's source, as unique and precious as I think it is at the moment) and why I think it can be very easily parallelised, but my question is dragging already.

P.S.   I would gladly discuss the physics of my engine (or the engine of my physics) more in depth, not sure where to do so.

1

Share this post


Link to post
Share on other sites

but before moving on I would like to know if there is a good way to estimate a worst case scnario performance of my game engine. Is it possible to determine if my engine would be possible with just a base knowledge of how many calculations I will need to carry out? Do I need to create a full physics engine prototype just to know where the unexpected bottlenecks appear?


Not really, outside of extreme cases. Obviously you want to make an attempt at figuring out the computational complexity of your algorithms ("big O" notation stuff) and rethink any parts that are worse than polynomial time for the number of particles/shapes you're dealing with.

Aside from that, the only realistic thing to do is throw a stress test at your implementation: toss 3x to 10x as many objects as you expect it to handle and see how well it handles the load, then optimize and refactor and redesign until you get it handling that number of objects reasonably well without spikes.

Remember that for games, worst-case performance is more important than average-case most of the time. Having 60 FPS that drops to 1 FPS every 200 frames is much, much worse than just running at a steady 30 FPS.
0

Share this post


Link to post
Share on other sites

Is it feasible to create a physics engine that always performs near the worst case scenario?

In my code I divide the whole physics world into a grid and in each cell there can be only one particle (because of hte forces) and the particle has relative coordinates to the cell. Then to calculate the forces with nearby particles I just itterate over the nearby cells, first checking if they are filled. This approach sounded quite neat for me, because the coordinate system is related to array indexes and it is obvious which particles are close. Now in a worst case scenario almost every particle will have about 6 particles nearby, so almost every nearby cell will be filled.

 

In other words: is it beneficial to avoid unecessary calculations when there are a few particles if I am aiming to make the least calculations in the worst case scenario?

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0