Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Random String Generator Data Format

This topic is 5486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a game project that I probably won''t start for a long time, but as an initial step I wanted to make a random string generator that gets the data it needs from files. For example, I''d have one bit of data that says "take the first word from this list, add this string, and take the other word from some other list", and to go with that I''d have two other bits of data with the two lists of words. Also, there is recursion in that the words that are randomly chosen could also be randomly generated from other lists. I already made a simple text parsing system which worked but was very messy, unflexible, and there was no way to add the extra functionality I wanted (such as probabilities, quick avoidance of generating two of the same strings, etc). So, my first question is, is there anything thats already available that does this? If not, I was going to give it another go. I''m not having trouble with the algorithms for generating the strings, its mostly the storing of the data. It looks like XML is the best bet, since I don''t know when I''ll start the main project, and in the worst case it should be relatively easy to convert the XML data to some other format if I need to. I already know of some parsing libraries, but I was wondering if this was the best way to go, or is there was some other easy way to do it, such as something similar to ini files (which I was trying to use in my first attempt)?

Share this post

Link to post
Share on other sites
I would have thought storing the data was the easy part, actually. Your algorithms determine the way you want to store it in memory, and the way you store it in memory hints at the best way to store it on disk. Perhaps you're saying it's complicated because some data is essentially meta-data that says to look elsewhere, yeah?

I can't think of anything that does this sort of thing already, but XML is an excellent choice for the storage as you can add extra attributes (such as probabilities) without breaking the parsing at all. TinyXML (see my signature) is a great library for parsing XML if you're not concerned about the more pedantic details of XML standards compliance, and I believe this is true in your case.

You might also look into natural language processing, as they have rules for decomposing a sentence from the component words. In essence this is simply the reverse of what you are doing, and many of the same ideas will apply. For example, a Backus-Naur parser might work well. eg.

<sentence> ::= <subject> <verb> <object>
<subject> ::= <name> | <pronoun>
<verb> ::= "likes" | "eats" | "hates"
<object> ::= "cake" | "carrots" | "peas"
<name> ::= "John" | "Mary"
<pronoun> ::= "he" | "she" | "someone"

That grammar describes 45 different sentences, for example. It wouldn't be too hard to encode the above in XML.

<rule name='sentence'>
<option> [subject] [verb] [object] </option>
<rule name='subject'>
<option> [name] </option>
<option> [pronoun] </option>
<rule name='verb'>

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

[edited by - Kylotan on July 9, 2003 11:04:04 AM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!