Help me decide about gameplay...

Also, @Mobious, about “Cython which compiles Python code into C”, how to do it?

People have come up with all kinds of crazy compilers that translate between languages. Unity 3D has a system that takes scripts written in C#, compiles them to C++, then compiles that into Javascript (actually ASM.JS which is strict sub-set of Javascript).

You cannot translate arbitrary Python code into C, but if you use a special subset of Python and provide some clues, it is possible to do.

Well, you can technically do this, because CPython is C. All these compilers tend to do is remove the dynamic typing whenever possible, amongst other things :wink:

You could have, in my opinion, a long wait with a loading animation. While you play a level opening animation (big gate lock mechanism, some device that needs to be stored in the inventory but analysed first, collecting a long rope into a backpack, etc), you could squeeze your heavy calculation in via a thread, since the player will be waiting for that animation to end. And you can give some basic movement to the player so he doesn’t think the game froze.
I’d advice against going back and restructure your game logic, since you already invested so much…

Wherever possible, assets should be loaded before they’re noticeable (but relevant) like animations. Game logic that depends upon an animation finishing on a specific time should instead be driven by the animation.

There are going to be various kinds of tilesets. Some will be indoors and can be mostly tiles as you say, but others will be outside and have more natural features like rivers and trees. Each tile will join at the edges with other tiles. Some areas will be pretty empty and have low density mesh structure, others (near doors for example) will have higher density. The graph is stored as a dictionary and the entries are python objects.

I’ll post a demo later…
Heres an old video;

The idea here was to use the -let’s say intricate lock mechanism- as a disguise of a loading screen. It can be an elevator or a train or something else. That is a way to have a loading routine without completely stopping the game.

the start of game can take 4 second without problems (1 or 4 not make much difference)

the lag during the game is MUCH more hurting .
i know perfectly civilization(IV) , yes with large map (after press space) the ai turn can take really minutes .
but it is too much, for that i played ever with little map , the LAG of AI was 1/2 seconds.

a time acceptable for that kind of game .(totally strategic)
also make a new action(right) for the player can take minutes, so 2 seconds of wait was not a problem.

Here’s a working example for using multiprocessing in the BGE. Note that it’s for Windows only.

This sounds like something you should only be doing only once when the level mesh initially loads. You should read all the vertices and then save any necessary information in a list (or possibly an array as that may be faster/more memory efficient if you have a lot of nodes). This will save you from having to go through the slow process of fetching vertices from the mesh every time you need to calculate something.

Again, this sounds like it should only happen once when the level initially loads. If the graph changes as the game progresses, you should be able to make small updates very quickly as the changes happen instead of waiting until the start of the AI’s turn to update the entire graph at once.

I’m curious as to how many nodes you have in your graph. For how long it takes to calculate, it sounds to me like you have too many. You may want to look into reducing the number of nodes, or, if that’s not feasible, go with SolarLune’s suggestion of grouping nodes together to create a much smaller graph that you can then use to reduce the number of nodes you need to search through.

Also, improving your algorithm and its implementation can really boost performance. In my case, I wrote a C++ PriorityQueue class that halved the considerable time spent using heappush and heappop


Thank you but again, that doesn’t work for me. I’m confident that it could be made to work given some time and some help, but there’s already a lot of hassle when distributing games to make sure they can run on different computers with different operating systems and different hardware. I want to find a way that is simple and ideally fool proof.

Yes, that’s what I do. It really doesn’t take a very long time, but during that initial second or so of starting the level there’s going to be a lot going on. Saved game data being loaded from file, dungeon generating algorithm running, tileset sections being placed, player and enemies being set up and placed, loot, traps and other things being generated and placed…

The game can lock up for at least half a second and seem like it has crashed, there’s the “not responding” tag on the program. Using threading, or by stacking the tasks in a queue and dealing with them one by one, I can stop the game from locking up, but it means waiting longer.

During gameplay, the AI calculations I want to make are also not that devastating, but they can cause a bit of a slow down. framerates are going to drop, and in slow computers it might even freeze momentarily. Wouldn’t it be better to keep the framerate up at maximum but have a short delay at the beginning of the AI turn?

As a side issue, is an array the best way to save level data?
I used to use arrays, but I noticed that while an array represents every square in a given level size (20x20 = 400) tiles, a dictionary only has to represent tiles which are actually used. In a sparse environment (a dungeon, island, cave system etc…) this might be less than 50% of the actual tiles by area.

That’s exactly what I had in mind. Like the old Resident Evil games which played an animation of the door opening when you move to a different room.

I’ve even got an animationlined up for it. :stuck_out_tongue:

I do partially agree with you on this, but this isn’t only a game I’m making, it’s a learning experience. This particular project is one which I don’t really mind if I finish or not. It’s gone through so many iterations over the months and years I’ve been working on it… I guess it would be nice to pin it down and finally finish it, but then I’d have to start another project along the same lines. When I started this project 3-4 years ago I didn’t have the skills needed to finish it. Still, the scope of this project is probably beyond my ability to complete, but each time I start work on it again it seems little more possible to achieve a victory.

As a side issue, is an array the best way to save level data?
I used to use arrays, but I noticed that while an array represents every square in a given level size (20x20 = 400) tiles, a dictionary only has to represent tiles which are actually used. In a sparse environment (a dungeon, island, cave system etc…) this might be less than 50% of the actual tiles by area.

When using numpy / python arrays, raw C data types can be used underneath. This means you save a lot of memory, and have quicker lookup times.

Let’s say you had < 255 tile types (likely), then you could create a 20*20 grid in 3200 bytes. Doing the same in pure-python would be much more (20 bytes or so more per element, depending on the platform), which is more like 11200 bytes.

If you wrote a special library, you could reduce the memory further. let’s say you have a maximum of 16 tiles, then you would need 1600 bytes (but slightly longer lookup times). You could reduce this even further by instead using a char array, (but now you pay search costs, though in C it’s not so bad) where the first bit of the next cell is a flag to say if the cell is populated. At this point you’d need to iterate over all the cell elements until such a point, which is slow for inner cells, and modifying the map would be a huge pain. Definitely not worth going this far in this direction at least.

My basic stance is that responsiveness > feedback time, the engine itself should avoid freezing over extending calculation time. Multiprocessing will rarely slow down the game (unless IO between processes is heavy), and will usually speed up logic calculation (as it is executed concurrently to other code) due to additional processor cores. So, your real choice ought to be with using threading or multiprocessing - no excuse to block the main game!

NB threaded / multiprocessing approaches will still block if you’re waiting on a mutex / lock from another thread. Hence, try and support asynchronous responses where possible.

I have similar difficulties with my own project. A simple example is generating planets on the fly, and the terrain. I use up a lot of memory, but in my case, I prepare the levels before they are visible. For instance, when a stellar system is generated , all data required for every planet visualization is calculated and saved. As the ship approaches a planet, the tiles making up the planet are quickly generated ( I save the vertices for the base mesh in a dict, then for every instance of the tile, I just need to add the values saved in the system). For the terrain, the same happens, I calculate all the data for the tile (objects, vegetation, altitude, etc) save them in a dict, and when the time comes to generate the terrain, i only have to worry about smaller things, like object placement and customization. Also,for the terrain’s heightmap, I use pre-made maps, I add or subtract a 1,2, or 3(mix) of them to get different results. that way I have simple addiction formulae. I get slow downs, but aren’t very noticeable, since the ship is moving in a very big space.
So making part of the calculation before hand can save some time. Saving data as bytes, can save you memory space.
Here’s my advice:
Simplify your algorithms, and assist them with pre-calculated data when possible. I think that modular procedural generation can work faster than mostly procedural generation!

In my experience, this is usually an issue with having different versions of Blender and Python, not necessarily the hardware and operating system. This means it’s actually easier to get working with the final exported executable since you know exactly what version the user will be running. What version of Blender did you try running it with? I was using 2.74 32-bit.

Here’s an updated link with a different Python library you can try if you still can’t get the other to work.

@@torakunsama
I have thought about pre-calculating the data and loading it from file. I’d like the game to be easily modded, either by myself or others, so I’d like to be able to just grab a tileset or new monster type from libload as long as its name is in a config file. In that case I could have a longer loading sequence the first time you start the game, load everything up that’s already loaded and then check if anything new has been added to the config file. If there’s something new I can process it and save it ready to be used again. It would still need threading or queuing though.

@@Mobious
Thanks,
I was using a RC of 2.75, 32 bit (although I have 64bit windows, I haven’t found much benefit to using 64bit blender…)

I want to know, from a gaming point of view, which is better, a 1 second wait with everything locked up so it seems as if the game might have crashed, or a 4 second wait with everything still running, but having an animation showing “calculating…” or whatever?

so making the sum …
animation require multiprocess that increase 4x the time original of loading, and the multiprocess itself maybe is not so simple to manage ?

but a black screen freezed seem a crash.

what about to a compromise , using a object text with “Loading …” in front to the camera? before to start the heavy processes
i guess still all “freezed” but at least the gamer is warned .
advantage: not require extraprocess, not extratime,not extra potential problem.
little disadvantage: is not cool as one animation

supposing that all is true, seem a excellent solution

Please consider this: though a loading animation might seem repetitive, the player won’t think that there’s something wrong with the game and it might crash (though he/she might think it’s slow). On the other hand, if it freezes up, the player might think the game is crashing.

yeah, basically I want to know the next ‘kink’ in the path, and face it , then start walking,

(so if you change paths, and the path is 180 degree behind player, he turns, THEN starts using the steering actuator, but I don’t think you have access to the path with the actuator right?)

That may be a nice feature - https://developer.blender.org/T45285

Steering.pathList = a list in order of the nodes remaining to reach target ?

You start with the list of nodes and work through them.

target = list[0]

target_vector = target - own.worldPosition.copy()

if target_vector.length &lt; 0.1:
         list.pop(0)
else:
         target_angle = (own.getAxisVect(y_axis)).to_2d().angle_signed(target_vector)
         if target_angle &lt; 0.5:
                 own.worldPosition += target_vector
         own.alignAxisToVect(target_vector,1,1.0)

Or something along those lines.

Can you send me a very basic version of the system? I need to get @pagio 's game up and running ASAP :smiley:

I will need to adapt it so the player and the enemies use the same system.

or you could help him integrate it and get the credit, (they already have so much art done)

I want to see the bge become a viable tool for indies.

Hmmm… that’s the problem I face. Navigation in an RPG isnt just an A star algorithm. You need to deal with obstructions so players and enemies don’t walk through each other. You need a system of priority for moving units to stop them walking over each other. You need some amount of ability to edit the graph to deal with locked doors. The final system is far from simple or basic.
That’s why I ended up designing my own system rather than using the built in nav mesh and why it takes time to set it up and why it’s not as fast as the built in version.

I’ll try to post a basic version of the pathfinding setup when I get home.