Newest Posts by me on: 3/29/2014
http://www.purebasic.fr/english/viewtop ... 60#p441540
-------------------------------
Small Intro:
As some of you may know by now I'm slowly in the process of building a Single Player Text RPG.
I intend for this threads to be a general repository for discussions relating to my development process and my progresss itself. I would like to ask a lot of questions, many of them probably n00bish or just me needing reassurance, but also may start some general discussions as well..
Instead of littering the forum with multiple posts, I want to try and keep it all in one thread.. Hopefully people won't forget its multiple topics inside when they see new posts
The two primary goals I have are:
A)Deep, Rich Story Telling (As a proficient writer I have this more than covered. I have previous years worth of source material already written)
B)Creating a very unique, immersive atmosphere with lots of interaction. I want to try and obtain the level of interaction you would typically find in most MUDs (Multi User Dungeon). Those who have played MUDs before know that they can be extremely addictive and interactive with the right combination of staff and a good player base.
However, I have never worked on a MUD before, let alone a Text Game (or any game).. So I have to approach everything from scratch.
My Text Coloring & Font parsing code is almost done, which means soon I will be able to start developing other systems. While one of my goals as a developer is to obtain speed and efficiency (Text worlds like this can take large amounts of CPU and RAM), I am also willing to sacrifice a little, to allow for an easier time coding, and producing more easily maintained code that I can actually read (although I do comment heavily).
So here are some of my thoughts on how I'd like to approach some of the stuff I'll have to do. I'm interested in feedback mostly on what is/isn't a good idea.. Optimized code examples are welcome if you have an alternate idea for one of mine, but keep in mind I may not use it if I deem it too tough to read/remember how it works. It's not unappreciated, just might not be for me.. If you want to say "Well this is a better way to do it", that is your right.. but unless it is orders of magnitude faster than my version, I may be hard to convince.. A lot of my ideas are firmly committed to my mind, but I am always willing to listen to others, and perhaps incorporate some changes where it makes sense for me.
-----------------------------
Asset Management:
In this case I decided a long time ago that I will be using a database to store a lot of my stuff. This covers a lot of things from basic Rooms in the game, to items, monsters, quests & all the associated properties that might go with them. I will most likely use SQLite as I have experience with using it from when I prototyped this idea in Python.. I'm sure Purebasic usage will present some differences but I'm firmly committed to SQLite at this point. It's small, portable (embedded in App) and fast. Perfect for what I need to use it for.
In-Memory management of stuff on the other hand (it has to go somewhere after you load it!).. I am considering using a combination of Maps and Linked Lists where appropriate in each individual case. I have my own addressing system that I want to use for my rooms.. It looks like a Hex number, but it really isn't used "as Hex". I also intend to use Structures, to manage different pieces of data for individual elements..
My only concern is that in all the examples of Lists/Map I've seen in help.. Either I don't understand them completely, or they possibly can't be used in the way I want? I want to make sure...
For Rooms in particular, I need to access any given room by its element name (instead of iterating the entire Map looking for a property matching a search term)..
Code: Select all
Structure Room_Struct
ID.s ("1x1A" allowed as an ID under this type?)
Title.s
Description.s
Contents.s (what's in the room? Static objects that can be interacted with)
Contents2.s (dynamic stuff, dropped treasure or other items, monsters, NPC's etc)
Exits.s
EndStructure
NewMap WorldMap.Room_Struct()
; So lets populate the map
; Do I absolutely NEED to do it like the example?
WorldMap("1x1A")\ID = "1x1A" <--- (I want this to be two separate lines/commands)
WorldMap()\Title = "Some Title"
WorldMap()\Description = "A long boring Room Description"
WorldMap()\Contents = "If anything, populate this"
WorldMap()\Contents2 = "Same as Contents"
WorldMap()\Exits = "Insert concatenated string variable listing all Exits in a nice format"
Do I need to implicitly use the AddMapElement keyword when populating a map? Or can I just set it up to build on the fly like above, changing the relevent Key name as it populates? This is the impression I have, so I just wanted to be sure.. Although I don't like having to append the assigning of the first structure variable onto the creation of the map Key..
Idea! :I don't mind building a function that first creates empty elements for all rooms in the game, and then goes back and populates them, however.. Actually it might be a good idea and would save memory because I could institute a "Bubble Loader" around the Player and only load Rooms / generate dynamic content within a certain radius of say... 50, 75, 100 rooms or so ? I think this will ultimately depend on resource testing I do when I get the engines skeleton (room navigation and basic command parsing) up and running. I could do something insane like generate 10,000 rooms of gibberish just to look at the memory footprint.. Although I am sure someone here might have a formula or something for multiplying average room size [bytes] by number of rooms, as well..
-----------------
Command Parser
This one... really troubles me to no end. I do not understand parsers, despite hours of research and reading. I honestly don't. I have read about topics such as BNF, heard about terms like top-down, bottom-up, recursive descent parsers, etc... Programs like "Lex" scare me.. I honestly just don't have the skillset or capacity to learn about proper parsers and how to build one.
In Python, I used an IF / ENDIF tree and Regular Expression matching.. To some marginal success (I have issues with the order words appeared in the match-list, etc).. For a handful of commands I think IF/ENDIF works fine and such.. But I don't know what the long-term complication woulds be if I my command set grew to something large, like 100+ commands??
I would like to be able to tokenize and parse complex phrases such as "put my sword in my green pack", or "polish the mirror with the rag".. especially in combat, stuff like "attack third orc" (out of a group of orcs).. I know a lot of it is about tokenizing and then tossing irrelevant words out.. ([put] my [sword] (in) my [green pack], etc).. But the whole concept of implementing a parser, a REAL parser that is good, is lightyears beyond me... A really complex phrase example which would be neat to handle, might be something like this... "put my sword in the green sheath that is on the stool, on the red table"... lol? (probably two or three ways to interpret that)
I know parsers have gone through a lot of evolution, especially among the big name Interactive Fiction companies of the past (Infocom, etc).. I think I read somewhere one idea for a parser was to assign keywords numerical values and somehow when tokenized and parsed out they would add up to the proper value to trigger the correct command.. That idea intrigues me, but I wouldn't know where to start with THAT, either...
I was wondering about using a LinkedList in the process somehow...or should I just stick with an IF / ENDIF or perhaps CASE / SELECT ??
Well those are my main thoughts / questions for now.. Hope it wasn't too boring.