When the game lags, what does it cut back?

My concern is BGE wants to be real-time, meaning it will lag or even crash if there’s too much physics or algorithm to run.

So - When BGE lags, what does it cut back on? Does BGE cut out pieces of your algorithm or physics or graphics to try and keep real-time? And does it avoid cutting out pieces of code because that would be too disastrous?

And if it avoids cutting out code and will run through it no matter how long it takes, and is no longer real-time, will it crash if it gets too slow? And why not just run through slower? Why crash? I wanttt to wait. I’m simulating a brain.

First thing to go is rendering. It will (by default) perform up to five logic and physics steps per rendered frame. You can configure this in the world panel.
You can seperate how many physics steps and how many logic steps to accept per rendered frame. After those limits are hit, everything slows down.

It should not crash. It will not cut out code.

Interesting. Now when you say it will cut back logic steps, isn’t that code it’s cutting out? Or does it keep python but cut out bricks you mean?

Within the BGE there is a “Game Loop” which normally looks like:


logic -> physics -> render

And repeats continuously at 60FPS. When the game is running slow, it can do this:


logic -> physics -> logic -> physics -> render

It can do that “logic -> physics” up to 5 times (as defined in the “max physics steps” and “max logic steps” in the world panel).

If you have a higher physics than logic substeps, then I suppose you can get:


logic -> physics -> physics -> logic -> physics -> physics -> render

Generally the goal is to keep it at 60FPS, and if that’s not happening, then you need to optimize. In many cases (eg AI simulations) the render isn’t the thing causing the slowdown, so the default behaviour of cutting out the render step doesn’t really help anything except make it look laggier than it is. In these cases, try splitting your logic over more frames.

My human brain AI algorithm must complete code fast and cannot spread over frames ex. recognizes a house cat after gets to the bus stop lol. So, if I don’t spread it out or optimize, are you saying it will cut out my code? Any code cut out will fail the whole algorithm. Would this happen?

Optimize. The human brain has an “algorithm” that is sequential plus parallel and utilizes parallelism bigtime ex. recognize some cat by searching through a million image memories. Electrical sequential CPUs are actually faster than neurons’s slow traveling chemo-electrical signals and fire frequency (note each can fire on own time - so 200 fires per sec for fastest neurons doesn’t mean 200 ticks per sec), but your lacking parallelism, unless your tasks are sequential. Then you’d win-out! Therefore any of my sequential AI is actually faster than human brain and should be very very real-time budget. Then, I must optimize any parallel tasks, ex. make them non-parallel ex. instead of searching image memories, searches single bit memories. Hey it’s a compromise. Or, optimize. Throws away information though!

Another tip - it doesn’t matter much how fast signals travel, rather, their fire frequency matters. Imagine a billion fires traveling at electrical speed. Imagine a million fires traveling at lightspeed. There’s a moment difference to us, but after the wait is over, those billion signals one-after-another enter into a ex. block and each computes fast. Imagine recording a billion images per second. No matter if travel slow. There is a back-to-back line-up coming for a billion images from 1 second.

Hm maybe you can make BGE render ex. make empty frames with extra code needing computing. That’s spreading out. Can you freeze physics? Interestingly, only in simulated universes, you can, after 1 milisecond, have computed unlimited amounts, then turn back on physics and output answers. In reality, lightspeed is the limit, and parallism makes all the signals have to sorta get back to eachother maybe.

Are you using any other software to make this human brain ai algorithm other than python and the bge?I am interested in ai too.I make chatbots.I make them on the botlibre websight.

I’m going to use Blender Cycles mode, and if it can’t work, BGE / UPBGE / Armory. Alternatively I can use Unity, UE4, Euphoria, V-REP, or OpenAI Gym / Roboschool / Parallel Game Engine.

V-REP, if I’m correct, waits for your code to execute like Cycles, and unlike Cycles it has full code functionality (Cycles may though idk yet). Looks really high tech too. UE4 is pretty good, and one guy said it will wait to complete your code, but idk for sure.

would it be ai that someone can interact with?Because if you use
cycles you wont be able to do that.

I can interact with it by setting things up beforehand, and by watching it in viewport without waiting for rendering movies. But interaction is necessary.

what are you trying to accomplish with this?

My life goal is to advance technology. I’m going to either show it to professors, or create human intelligence right in my own computer if no professor will ever care to help me.

Have you been doing any research into ai.Because they have making things that could help you.Physics.org has been posting articles on stuff like that.

Yes I’ve been researching all of the AI field for almost 3 years, and researching everything for over 3 years. Physics.org is just about physics…there’s nothing I need there…

There are two websights with that name.Put it in the search like this.
physics.org nanotechnology and chemistry
it has more than physics on it.
look at the techxplore websight under topics=computer science

I found it.

So back to my last reply with questions (post #5), does anyone have any answers?

You could have the ai algorithm done all in python or another programming language.Then send the information to it from the game engine.Then send information from the ai algorithm to the game engine.That is the just of it.

Because all code is self-contained to run inside a single “frame” - and has to finish inside that time, code is never “cut out.” The effect of slow code is to make the game visually run slower.
But it will never go “let’s skip this logic brick” or “let’s skip this line of code” because doing so would, as you expect, be an utter disaster.

And yes, AI is typically spread over time. Very very few AI algorithms outside of gaming run in any sort of semblance of timelyness.
And think about it, how many times when walking down the street do you suddenly come to a realization about something your saw 3, 10, 30 minutes ago. (or is that just me?).

Also, look into GPU’s. A GTX 1080 has over 2500 cores running in parallel at 1.6Ghz. That’s a HUGE amount of processing power. Hence why companies researching computer vision and neural networks like GPUs… Have a look into CUDA (nvidia) or OpenCL (amd)

I will warn you. AI research is fantastic stuff, but also requires a deep understanding of a wide range of sciences and the tools you are working with. I would advise you to make a simple game in BGE first (to learn how to use the tool). This will teach you how BGE handles lag better than I could explain it here.

Oh thank god yes yes that is good. Great to hear.

When it cuts back on the physics and graphics though, is there a point at which it won’t cut back any more and just run slower? Or can it really get to a point where it has 1 graphic frame every 7 hours and 3 physics calculation frames every 7 hours?

“You could have the ai algorithm done all in python or another programming language.Then send the information to it from the game engine.Then send information from the ai algorithm to the game engine.That is the just of it.”

Wha?..

Are you saying to make python call out of the Blender software to a ex. C++ compiler software to tell it to run C++, then also talk to the Game Engine when in the Cycles mode, then switch to the Game Engine and talk to the Cycles mode? I don’t think you can do any of that without major hacking lol.

Yes, you can get to the one-frame-per-7-hours stage. But if you’re that slow, something must be going really wrong (or really right).

I don’t think you can do any of that without major hacking lol.

Python is amazing. You can do this sort of thing! Or via networks, which is much easier in my opinion…