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 / Loading 26 Letter TXT Files Works on HTML5 But Fails On Android?

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 3rd Jan 2018 09:33
Hi,

We are working on a new word spelling educational game.
We have 26 letter TXT files in alphabetical order.
When the game is first run we load all 26 TXT files into a 2-D array: global Dictionary as string[26, 50000]
It works 100% on HTML5 platform, but freezes on Android platform?
Game locks up with music playing on Android?

Anyone know how to fix the above issue on Android platform?
The dictionary is about 5MB in total.

Here is the dictionary load function:


Any help would be greatly appreciated, thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 3rd Jan 2018 09:39
Does it not ever complete? Android takes a lot longer to read files compared to computer as it's max sync rate is 60 meaning it can only do 60 loops per second.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 3rd Jan 2018 09:53
Hi,

Loading letter "A" takes over 1 minute on a fast Android smartphone, and there are still 25 other letter files...

Load TXT files into an array is not going to work on Android.
What other options do I have?

Let me know, thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 3rd Jan 2018 10:01
Hi,

Would pasting each TXT file into a new AGC file work?
I've attached a one of the TXT files.
Let me know thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 3rd Jan 2018 10:10
When you say it hangs playing the music or is it genuinely hanging when reading in the letter files.

Maybe perhaps use the CreateMemblockfromFile(), this maybe a little faster.

Ill have a think and come back to you later tonight

JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 3rd Jan 2018 11:37
Hi,

I put the 26 dictionary TXT files into separate AGC files.
It's still not working though?

For example I have something like this:


But when I try to print each array string I get nothing on the screen?
Am I doing something obviously wrong?
Thanks!
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
puzzler2018
User Banned
Posted: 3rd Jan 2018 17:46
this works for me

puzzler2018
User Banned
Posted: 3rd Jan 2018 18:54
This will work on Android and quiet reasonable i think


JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 3rd Jan 2018 19:21
Thanks puzzler2018,

I got it all working now, but will revisit it before official Beta1 release to optimize.
Thanks again for your help with this project...
JeZxLee
16BitSoft
Video Game Design Studio
http://www.16BitSoft.com
Open-Source AppGameKit Project!
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 4th Jan 2018 03:41 Edited at: 4th Jan 2018 04:01
one style tip would be compute the filenames rather than hard coding them.

so this,


Becomes this,




I suspect the loading is slow due to how spooling strings generally works, which tends to be byte by byte. Terrible for big files. Moreover string comparisons within the loop can be detrimental also.

One simple idea would be store the number of lines at the head of the document. Then you can use a FOR/NEXT block to grab the lines, without polling the device for the size all the file and no 'end' tokens.

ie.

LinesInFile = val(ReadLine(readFile) ) -1
for Index=0 To LinesInFile
Dictionary[letter, index]= ReadLine(readFile)
next


example file

50000
AAAAAAAA
ABBA
ABBADABBA
etc etc



That still a lot of string / disc thrashing though..

probably best to load the file into a memblock using CreateMemblockFromFile


Rather than store the dictionary as 'text' files, i'd be more include to pre-process the file so that I can do searches directly on the memblock memory and not have to load it as strings at all, which introduces a lot of memory thrashing..

one idea would be to run through the files, for each file compute a table that is a life of byte offsets without the data block, so using the the header you can index the offset to the string you want. Storing a simple hash with the offset might be handy too, which will avoid doing string comparisons . The header could saving separately or attached to the text data, the latter is more messing around, but should be faster to load (slightly).








PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code

Login to post a reply

Server time is: 2024-04-20 02:58:19
Your offset time is: 2024-04-20 02:58:19