Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Open ended question: can AGK handle background processes?

Author
Message
JohnAD
5
Years of Service
User Offline
Joined: 8th Dec 2018
Location:
Posted: 8th Dec 2018 05:02
I've written a board game app called Kalah (a Mancala game); its currently up on Google Play. The current version was written in Python with the Kivy framework. It...works... but is problematic. Specifically, the negamax AI algorithm I wrote for it can take up to 8 seconds to run in the harder modes. The end-users experiences this as a "game lockup" while it is thinking.

So, my general question is this: can AppGameKit launch processes into the background and asynchronously continue while the process finishes? Essentially, I'd want the game to launch the decision-making algorithm into the background. And then the game continues running, probably showing a "please wait...I'm thinking" animation while waiting for the process to finish.

I'm happy to rewrite the algorithm into C++ or the AppGameKit language. But before I start, I'm asking if this is even possible.

Thanks in advance for any help or feedback!

John
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 9th Dec 2018 06:25
So, AppGameKit does not directly support threading or asynchronous processing.

Using tier 2 you could probably run a logic / calculation process asynchronously as long as it was not interacting with anything that agk (not thread safe) was managing.

alternatively for tier 1, yes you can launch a separate process that can run alongside your main process but it is truly separate, they won't directly share memory or runtime states. You would need to get them communicating with each other, either by networking or possibly mutex/shared memory though I think that would need a plugin and may not be doable on all platforms.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 9th Dec 2018 06:45
I remember seeing something where they used a shader to do their calculations in the GPU
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 9th Dec 2018 09:42
Remove any loops from the thinking process and let the game sync while the AI is thinking but make sure it doesn't let the game progress until the thinking is completed.
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 10th Dec 2018 12:44
Only good way to handle this is as Ortu says, spawn a new process that does the calculation and communicate with it.
You can do this with the RunApp command, though it's only available on desktop: https://www.appgamekit.com/documentation/Reference/Core/RunApp.htm
DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 14th Dec 2018 23:01
Would be nice to have even basic asynchronous processing. Even the abilirybto have a sprite continue to play for asset loading type spinners would be good.
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)

Login to post a reply

Server time is: 2024-04-25 04:51:29
Your offset time is: 2024-04-25 04:51:29