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 / Code line limit?

Author
Message
Velector
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 2nd Feb 2013 14:12
Hello all, I am wondering if AppGameKit has a limit on the size of source code files, as I am making a word game with a very large word list (39,416 words). I am using Tier 1 and I did some forum searching. I came across this thread: http://forum.thegamecreators.com/?m=forum_view&t=196495&b=41 My programming skills aren't the best, so I went with multiple arrays rather than one large array. I'm still unsure as to what a binary tree is, so I have not attempted that. Reading the file at startup took far too long.

I grabbed a word list from sil.org and wrote a tool in C# to parse the word list, limiting it to 7 letter words and splitting it into arrays. Each letter has its own array of 2 characters, 3 characters and so forth, maxing out at 7 characters.

Example:

word_2_a$[]
word_3_a$[]
...
word_7_z$[]

I tested the output file with just the letter A, and it happily compiled in both 1076 and 108b6. I pasted the rest of the list in, and originally had the list as a single large file (39,600 lines), called dictionary.agc and initialised the arrays before populating with my word list. After a certain amount of time compiling, the compiler crashed with the error,

Compiling: main.agc
Process terminated with status -1073741571 (1 minutes, 55 seconds)

(The above error is from 1076, I think 108b6 was the same.)

I figured the list was too long, so I split it up into separate code files, from A to Z (dictionary_a.agc, dictionary_b.agc...), compiling after each code file's inclusion. It compiles with no problems to R. When I got to S, It crashed out with the same error. I split S up into two code files (2000 lines each) and the first one compiled, but the second didn't.

I thought maybe there was an error in the second S list, so I deleted it and went ahead with T. Crashed out, same error. So I am wondering if there is source code size limit in AGK. The error does not come up anywhere on the forums, so I figured I would ask here.

I have attached the output of my tool for anyone who wants to try it. There are two files - one is the raw word output, and the other is a rough Tier 1 file. The Tier 1 array declarations are at the bottom of the file. I usually move them to the top, and encase the entire list into a function, "InitDictionary()"

Thanks in advance.

Attachments

Login to view attachments
TrezSoft
AGK Tool Maker
11
Years of Service
User Offline
Joined: 8th Nov 2012
Location: UK
Posted: 2nd Feb 2013 19:59
I Have no idea of the code line limit but would it not be a better solution to store the word text files in a CSV format and then parse them into the word array ? Its a lot less code and easier to manage.
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 2nd Feb 2013 23:22
There are lots of techniques to do this more efficiently, but a lot depends on what you want to do. Is it a dictionary, a word game, etc?

At the very simplest (assuming it does not have numbers as legal) you can make 26 arrays and miss the first letter off each word. That we if you have 1000 words starting with A you save 1000 bytes.

Another common technique is to tokenise common letter groups. For example, ING is very common. Let's assume you code values 0..25 as A..Z, then you could give ING value 26, saving two bytes for each occurrence.

There's a useful list of letter distribution here:
http://oxforddictionaries.com/words/what-is-the-frequency-of-the-letters-of-the-alphabet-in-english
and a list of common digraphs and trigraphs here:
http://kf7ekb.com/morse-code-cw/learning/digraphs-trigraphs-and-common-letters-and-words/

A binary tree would be very inefficient with a sorted word list. For searches a binary chop is the best technique, and very fast.

For very high compression rates, Huffman coding will massively reduce the data size:
http://en.wikipedia.org/wiki/Huffman_coding

Almost all of these techniques meaning building the database outside your program and then loading it. Playing with these algorithms is very interesting, I think.

I use "hashing" a lot where a linear search would be potentially too slow. This relies upon having plenty of disk storage, a fixed record size, and the ability to seek in a binary file.

For your problem I would suggest using simply 2-3-4 letter group substitution and 26 arrays with the outcome. Even if you started with ASCII "A" (character 65) that would leave you with 165 remaining codes for common letter groups such as "OUGH"

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Feb 2013 17:20
As for the title of this thread "code line limit?", as far as I know there isn't a limit. None has been stated anyway.

The error message message you see is one that has popped up periodically. It may be related to the number of string arrays/variables used. Strangely, it is often cured by putting a do-nothing non-comment line at just the right place (something like print("")). The trick is finding the correct place.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 3rd Feb 2013 18:11
I have only ever found this error happens when you attempt to access data from an array that is out of bounds in 1076. Your array looks more like lots of variables from the code you posted above.

word_2_a$[]
word_3_a$[]

You would be better storing the words in one array I would imagine.

word$[1]
word$[2]

If you need extra data tagged in with the word you can add more fields to the array.

word$[1,3]

This would give you 4 fields to contain any data you wish, albeit only string data. Obviously you can easily convert string to integer if you need to easily enough. So you could use word$[1,0] as the word, [1,1] as a description, etc.

Or you could use types and use.

type word
word
description
use
end type

dim word[10000] as word

Then you use word[1].word etc to access the data. Of course this may be teaching you to suck eggs, but I have no idea how advanced your coding is

As for it taking a long time to load, it sounds as if you have a lot of words and you will have to suffer a hit on load time if you wish to load them all. However, it may be taking longer than it should, dependant on how you are doing it, and what sort of game you are coding.

Velector
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 5th Feb 2013 16:22
Hi all, thanks for the responses. I apologise for taking so long to get back to you.

TrezSoft: I will try a CSV file in a few days and report back. I'm ashamed to admit that CSV did not even cross my mind. Occam's razor and all.

JimHawkins: This is a word game, yes. The general idea is, the user picks a bunch of letters from letters on the screen and makes as many words as possible. Each letter gets destroyed upon use. Think, Bejeweled, but with letters. Letters will constantly fall from the top, which is why I am going with a full sized dictionary. Thank you for your suggestions. I will be looking into those after I try the CSV method.

Ancient Lady: I did a search when I first got the error, and ran into one of your posts saying to do the same thing. That was the reason I split the dictionary arrays into multiple source files. It is a weird bug.

DVader: Thank you for the suggestion. To answer your question, I've been programming as a hobby for about 13 years, nothing large scale. The largest piece of software I've done was a small business management suite which handled inventory, customer cash and credit transactions, and the accounting - in C# with an SQL Server 2008 database. It is mostly string and data manipulation.

For this kind of dictionary, I would normally use a List<> type but I don't have that kind of flexibility in Tier 1. I'd use C++ but my skills are limited to an introductory course I took alongside with Java, so BASIC is the way to go for this until I learn the inner workings of AppGameKit a little more.

Again, thank you all for the suggestions, I'll be trying everything I can and reporting back.
Velector
11
Years of Service
User Offline
Joined: 8th Jan 2013
Location:
Posted: 12th Feb 2013 20:53
Hi all,

I have tried the CSV method, using the same variable names as before, and the entire file loads in less than 2 seconds. I tested with a few letters with a little over a thousand entries, and the seek times were more than satisfactory for a simple word game. I will go with this for now, and keep your other suggestions in mind if I feel I need a performance boost.

Thank you all again.

Login to post a reply

Server time is: 2024-05-07 18:48:02
Your offset time is: 2024-05-07 18:48:02