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 / How to implement large word list for word game

Author
Message
chrisnob
12
Years of Service
User Offline
Joined: 3rd May 2012
Location: Leeds - UK
Posted: 3rd May 2012 11:00
Hi All,

Recently purchased AppGameKit to create a word game. Love AppGameKit but I do not seem to be able to create a word list to check the players words against during game play.

I have tried reading from a file but it takes too long. I have also tried using arrays but the size of them is quite large so compile times are also very large.

Does anyone have any ideas?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd May 2012 17:00
Using an array is the best way. I would read the list in from a file at the start and save the words in a simple array.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd May 2012 17:06
As far as game play goes, you should suck up the compile time so that the player gets the game started sooner.

But the size of your word list may slow down the load time either way. It takes time to load a big executable, or it takes time to read the file.

Depending on your target platform, you may want to be conscious of how big the executable (and data) will get.

In Tier2, in theory, you could do things like file indexing to do relatively quick checks of segments of the file. Sort the word file alphabetically and create an index file showing where each letter begins.

In Tier1, you don't have that option. There are no random access file functions.

Games aimed at mobile devices need to be a smaller footprint.

If you are aiming your game for the Windows market, you aren't quite so constrained.

Cheers,
Ancient Lady
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd May 2012 17:24
Quote: "In Tier1, you don't have that option. There are no random access file functions."

You could store where each letter starts as a variable and then jump to that part of your array to start the search. If you reach the next letter index you know the word doesn't exist.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 3rd May 2012 17:30
How big is the file? My current project Obliterator stands a fairly massive 110MB at the min in total, which seems quite big for a phone app. I have plenty to trim out before release though. The compile time on it is quite long now, but is to be expected. However, if I run the actual app, rather than compile in AppGameKit, it isn't really all that slow to load, even on my android. Of course that is mainly graphical and sound data, rather than a huge array.
Do you mean the compile time, or the in game time it takes to load your data?

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd May 2012 18:31
Baxslash is right about making the search in the game faster using an index array.

My point was in accessing a file directly, instead of loading it all up at the start.

So, chrisnob, are you working in Tier1 or Tier2? That makes a difference as to the options you have.

Cheers,
Ancient Lady
chrisnob
12
Years of Service
User Offline
Joined: 3rd May 2012
Location: Leeds - UK
Posted: 3rd May 2012 18:41
Thank you for all the ideas.

I am currently working in Tier 1. I did consider jumping to Tier 2 but I really enjoy working in Tier 1.

I have solved my issue with a little bit of compromise. My original word list was 120,000 words but I've switched to around 12,000 words.

I've sorted all the words by letter count and now I have a single file with the 3 letter words on single line, followed by the 4 letter words, up to 7 letters. I read each line of the file and use the Mid command to chop up out the words storing the words in an array. I also have the index for the firs letter boundaries in the array so hopefully I can check words pretty quick.

The final word file is 117KB and takes a couple of seconds to load on Windows. I haven't tested on a mobile device yet.


Thanks once again for all the help.
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 5th May 2012 11:44
You could get blisteringly fast searches by using a binary tree. Each node need contain only Left, Right - integers and char (next letter in word). Assuming that char is actually 4 bytes, that's twelve bytes per node. Given that words contain a high degree of repetition, storing that info as whole words consumes a lot of unnecessary memory.

I've just downloaded a very big English (or maybe America!) word list, and I'll do some tests

-- Jim
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th May 2012 17:13
A binary search sounds like a great way to go.

And I can so envisage a 'Word Map Builder' program that would parse the original text file and build a good binary tree and then create a binary file to be read into the actual game.

My only problem is trying to figure out how to implement a binary tree in Tier1. Easy-peasy in Tier2.

Cheers,
Ancient Lady
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 5th May 2012 19:07
I've started making a constructor program in Delphi EX2 that will do most of this offline. I would carry on, but the Cup Final kicks off in 5 minutes!

-- Jim

Login to post a reply

Server time is: 2024-11-23 10:34:36
Your offset time is: 2024-11-23 10:34:36