performance: built in LogicBricks versus Python

I want to built a complex AI into my game, so I will have lot of triggers and sensors to be validated during runtime.

IMHO one main aspect of putting all into python is the source transparency, since I see all triggers, sensors actuators etc. in one source, or at least spread on several files, while logic bricks must be searched and found individually within the scenes and materials.

What is the performance difference between the built in logic bricks and logic bricks written in python ? I guess the blender logic bricks will be interpreted somehow in the game engine; external python sources will be interpreted as well. So which one is faster ? In which language will the internal logic bricks be translated to (or interpreted with) ?

Thanks in advance.

I’ve no idea, somtimes python scripts slow down the game, and sometimes it’s the logic bricks. I tried to test this by cretaing a mini game in Python, and afther that completely rebuild in logic bricks only. Afther that I should be able to see what’s faster and afther that combine them to optimise the minigame. But lag in python blender knowledge and sparetime I stopped developing that. :-?

I guess, somebody got knowledge of and access to the sources of the logic bricks … The logic brick interpreter itself is written in a language.
So, what language is it ?

Thanks in advance !

Logic bricks are written in C/C++ and are far from being “interpreted”. Their data structures are accessed by game engine and engine itself executes needed functions - logic bricks are generally faster than Python scripts.
But if there are to many logic bricks with complicated interconnections, it’s better to replace them by Python script - this replacement can have better performance.

General rule: If there is simple logic which can be easily implemented by logic bricks - use logic bricks. If not - use Python script.

Logicbricks should be faster. The more python scripts you have constantly running, the slower your game should go. I don’t have much experience with python, but that’s what i’d think…


Basically what they said. If you’re logic is complex, python should be faster, simple logic is faster with a few bricks. It doesn’t make a huge difference though. The most important thing is that your solution fits the task. Ai is best suited to python, as the logic with bricks gets really messy and hard to work with.

By the way, python runs fastest if you combine as much as possible into one script instead of using many.

Sounds what I was planning to do in my Python minigame. I was thinking to create 2 or 4 big scripts and run the total game with these 4 python scripts. But it wasn’t that easy as I thought it was. Anyways it would be an another usefull minigame running with 4 big python scripts to show what else the engine can do. Also intresting for real coders fans. :smiley:

So, where do I find the latest version of the Python API for blender 2.34 with the complete list of functions ? Could someone please post the link !?

And is there a tutorial about some API functions available ?

Thanks in advance !

If you want to get started with python, download ‘Byte of Python’ from this link: There you’ll find that free python book to get started learning how python works and how it’s build. :smiley: