The Daily Click ::. Forums ::. Klik Coding Help ::. Efficiency in Spring Appending in MMF
 

Post Reply  Post Oekaki 
 

Posted By Message

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
30th August, 2008 at 13:31:28 -

So heres my problem. I'm working on my text based game, but I've run into a wall in that the game runs down to 25 FPS on my system; I need to append string characters every frame in the form of a 60x26 grid; 1560 total '"X" + "X"' actions, in my fast loops. However, simply doing this character by character with normal string objects, or text blitter, will eat up the system because string appending seems to be inefficient in MMF. And because I need the columns to be split up vertically instead of horizontally, but taking chunks out of a larger string that goes horizontally, it makes it devilishly hard to parse.

Is there some extension that can take entire vertical slices out of a string array, or some way I can directly convert this array into text instead of having to read one element at a time and append it? IE its a 60x26 array of characters in the form of a string, and I need to slice off 60 different columns, only reading X number of characters from the top, not necessarily all of them, and paste that into a DIFFERENT string object.

Programming a way to do it was easy, finding a more efficient way is not...

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
30th August, 2008 at 13:51:08 -

I've got a good way to put it.

Imagine I wanted to make a scrabble-like game. I have the entire board saved as an array or a string or whatever, I can do either way, and I want to extract the vertical words, traveling from top down. As far as I know, all the conventional methods and extensions only parse horizontally, left to right. I want to take a substring slice out of it, and export that to another string.

I can do this by doing one character at a time, but thats so inefficient it drops the games FPS by half.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st August, 2008 at 13:21:09 -

really anyone got an idea?

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
31st August, 2008 at 13:59:44 -

no idea sorry

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st August, 2008 at 14:17:32 -



 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st August, 2008 at 14:23:25 -

I wonder if theres some workaround, like an extension that can convert letters into numbers, which I could then stack doing simple "A + B * 100 + C * 10000" and converting back into letters, since I know that direct math takes essentially no system time in MMF. Like an "A = 01, B = 02, C = 03, Z = 26" kind of thing.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st August, 2008 at 15:06:56 -

nope that won't work either.

http://www.yoda.arachsys.com/csharp/stringbuilder.html
If you read that, it explains why string appending is extremely inefficient; the system needs to allocate the memory of the entire string each time, instead of just adding the letter to the end. However, we don't HAVE a "stringbuilder" object, so im at a loss how to work around it.

Image Edited by the Author.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
31st August, 2008 at 21:53:24 -


Originally Posted by Pixelthief
I wonder if theres some workaround, like an extension that can convert letters into numbers, which I could then stack doing simple "A + B * 100 + C * 10000" and converting back into letters, since I know that direct math takes essentially no system time in MMF. Like an "A = 01, B = 02, C = 03, Z = 26" kind of thing.



Though I don't understand the problem you're facing (the first post), this problem does have a solution. Since you can convert letters to ascii values with string parser 2. Unless I misunderstood this post too

 
This space is for rent

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
31st August, 2008 at 22:29:09 -

tried that, but as the string parser only does 1 character at a time, I'd need to append them again. And the text blitter has a built in append function thats *slightly* more efficient, but didn't work. However, the guys on the clickteam forum pointed out that I can use the Binary object to convert the string into bytes, append the bytes, and convert back, which is working like a charm. So solved the problem.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Stevie Ray



Registered
  27/01/2021 19:46:53
Points
  1
27th January, 2021 at 27/01/2021 20:03:20 -


Originally Posted by Pixelthief
I've got a good way to put it.

Imagine I wanted to make a scrabble-like game. I have the entire board saved as an array or a string or whatever, I can do either way, and I want to extract the vertical words, traveling from top down. As far as I know, all the conventional methods and extensions only parse horizontally, left to right. I want to take a substring slice out of it, and export that to another string.

I can do this by doing one character at a time, but thats so inefficient it drops the games FPS by half.



Did you get this figured out? Need the source code? There are a couple places that publish this and provide good info for creating Scrabble games/solvers:
https://www.crosswordsolver.com/scrabble-word-finder
http://www.gtoal.com/wordgames/crosswords.html

 
Stevie Ray

Knockturnal

Nothing to see here turn back

Registered
  11/04/2008
Points
  354

VIP Member
26th March, 2021 at 26/03/2021 00:42:55 -

Well, I'd wager 13 years was enough time for them to figure out arrays

 
Professional vaporware developer

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
13th May, 2021 at 13/05/2021 20:03:47 -

lol; 13 years for an answer? Seems about right for DK.

Fastloops aren't a great option if they account for a bulk of your events. All fastloops run before a graphical update, which means the more fastloops you have going in a single frame, the lower your FPS.

Accessing any kind of external file source or importing data from elsewhere inside of a fastloop will make it run like complete mud. If you need to import data, do that at the start of frame, outside of a fastloop. Load the data into control objects you can work with directly.

It'd be a little less direct, but you could probably simplify this a bit by having a single list object with one horizontal line from your array on each line in the list. Append changes to the list object using Mid$. Once all changes are made, read the array and display it.

If you need to change a bunch of values every frame, tackle as much of that change in as few fastloops as possible. In the past, I've created interpreters that operate off of a list object and tokenized values built around an X|Y|Z pattern where X is the horizontal position of the character, Y is the vertical row that needs editing, and Z is the new string or value to be updated. A single fastloop can then be run an amount of times equal to the number of entries in the list object, which would force all changes to occur in a single display frame; probably without much noticeable lag.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?
   

Post Reply



 



Advertisement

Worth A Click