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.

AppGameKit Classic Chat / Sync and Swap is slowing me down

Author
Message
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 15th Jul 2017 08:48
I've built a function in Tier 1 that solves Sokoban puzzles. It does seem to work, but it's quite slow. The puzzle on the Wikipedia page describing Sokoban takes about four seconds on my computer. I've trimmed it a bit, I will trim it further so it gets faster, but because it is a bit slow I thought I should present some type of loading thingy to show that it's actually doing something and haven't hanged.

But when I do that, it gets really slow. I realize that Tier 1 has no threading, but what can I do to make it faster? What I do now is in my loop for the BFS-algorithm is to do a print of the current solution and then call Render and then Swap. And it gets really slow. I tried to disable the sync rate, and it stil gets about twice as slow as without Render and Swap. Is there anything else I can do?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Jul 2017 09:09
At 60 FPS you are obviously refreshing the screen 60 times a second.
You could keep your own timer and update maybe 4 times a second. Each loop you check whether 0.25 seconds have passed, and only update when it has. Most cycles will not update the screen. That would be just 1/15 of the updates.

Why are you using Render and Swap? Can you use the simpler Sync()?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 15th Jul 2017 09:39
Since Sync does a bunch of stuff behind the scenes, I decided to experiment with calling Render and Swap etc manually to see if I could increase the speed.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 21st Jul 2017 21:57
As you're solving function is in T1, I don't know how you are able to process a sync loop of any type while your function is working, unless your function is written to "do a bit of solve" then sync.

Just syncing the screen in itself isn't going to slow you down any. You would at least have to break down your solver like this:

--> solve()
-->UpdateDisplay()
-->Sync()

where solve() only performs some part at a time of the solution and feeds the updateDIsplay() function with it's progress.
Fluorescent
FPSC Reloaded TGC Backer
18
Years of Service
User Offline
Joined: 1st Aug 2005
Location: Stockholm, Sweden
Posted: 22nd Jul 2017 07:43
Since the solver works on two loops, one for a queue in the breadth-first-search algorithm and one for moving the player. I can in each iteration of these loops call Sync or Render or whatever really.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Jul 2017 15:02
OK, so why not operate a counter to only sync / progress update every n iterations? May only need to update once every 100 or 1000 loops

Login to post a reply

Server time is: 2024-04-20 08:20:29
Your offset time is: 2024-04-20 08:20:29