Results 1 to 6 of 6

Thread: Random-Depth Tree Creator/Editor

  1. #1

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,646

    Random-Depth Tree Creator/Editor

    Edit (2024-04-18@2216ish)

    I made a mistake. I've been running the Tree Creator over and over and it is *not* doing what I want. Essentially any Root Branch could branch differently from any other root branch but within any given branch all branches were the same.

    In other words:

    "You come to a Crossroad."

    Now no matter what you do you have the same number of choices to get to an outcome.

    If you go left you get three choices. If you turn back you get three choices. If you go right you get three choices. You get the point.

    That's because I was generating the Random Number *outside* the loop.

    Now I've moved it inside the loop so if you turn back that might be the final outcome. But if you turn right you might get four choices. If you turn left you might get two choices. If you go straight ahead you might get five choices.

    I haven't uploaded it yet - the attached upload still contains the problem. I need to play with it some more.

    Also, the whole Create Method in cNode is hack programming. I have no idea what I'm doing really. I just keep changing pluses to minuses and trying different things. As long as it exits without Stack Overflow I know I'm on the right track. Again, this is a one-time tool so it doesn't need to be perfect. It just has to give me a result I like eventually and it's doing that now.

    I'll make another edit to this post with the updated source code after I play with it some more.

    Made a few other small tweaks such as getting rid of the leading "000" in the textbox because that's the Mother of all Branches and isn't necessary.

    Also too, the stuff I posted does work. There's nothing actually wrong with it except not being as random as I wanted.

    ============================

    Original upload: Tree.zip

    ============================

    This is a Tool I built to create random events in a game I'm writing.

    The idea is to create a Tree having Random-Depth Branches.

    Each Branch can branch off into different directions so that when an Event happens it can go multiple ways.

    The "real" way to do this is to probably just create branches as you need them but I wanted something to kind of push me along.

    Hopefully what I end up with content-wise isn't too contrived just to force-fill the Nodes.

    It's a one-and-done kind of tool. Once the Tree is created that's it for that game. You never use it again.

    Unless you want to create multiple databases or put multiple tables in the same database and each time you run the Tree Creator you have it fill a different table. You'll have to change the Table Name in the code every time you do this.

    --------------

    Edit: You could pretty easily add another textbox to the Tree Creator and have it create an empty copy of the Table with whatever name you enter into the textbox and then have the Tree fill that new table. I should have done that and probably will.

    --------------

    That would allow you to use the same game engine (you gotta write that) but have multiple versions of it: Steampunk, Cyberpunk, Post-Apocalypse, etc.

    This applet is very bare-bones. It is fully functional though.

    I added in the quality-of-life stuff I know I'll want. I'll probably make some tweaks to it here and there as I'm using it more extensively and find things I'd like to work better or easier or more efficiently or whatever.

    But really it's just to get me the content for my game without spending any more time than necessary making the tools to make the game.

    If you download the attached file then be sure to check out the Tree Editor *BEFORE* you create any Trees.

    Every time you create a New Tree it wipes out the existing Tree. All of it.

    So the first thing to do is fire it up, go to the Tree Editor, go to the "Branch to Node" Combobox and scroll down a few entries.

    There are Nine entries filled in this so you can see how it works.

    Also too, if there's an entry missing in the middle of a branch it will tell you. In fact, it will tell you ALL missing nodes.

    But if you see something like:

    "You walk into the forest."
    "You see a bear."
    "[Content is Missing]"
    "YOU DIED!"

    Then there's a missing bit that needs to be fixed.

    Anyway, this is doing everything I need it to do (I think) and it doesn't choke.

    I will caution you against putting in huge numbers for the Tree Creator.

    I put in 999 for Starting Seed and 99 for Target Depth. Hours later it was in the 300's. That was when it was only writing to a text file. I hadn't done the db bit yet. That's on a Threadripper 3960x with very fast NVMe drives.

    Because it's Random, you might end up with the largest tree possible for the numbers input or something very small.

    For example, if you enter 50 for Starting Seed, that doesn't mean it won't roll a one and give you one branch with two nodes.

    So you might have to do it a few times to get something you like which is exactly what I wanted.

    I just roll until I get about the right balance between number of Branches and total number of Nodes.

    I was looking for Nodes in the 3K to 5K range. Starting Seed of 75 with a Target Depth of 6 got me what I wanted after a couple rolls.

    ===============

    About the game and why I'm doing it this way. And before I go there, this IS NOT the game. This is to create content for the game in case that wasn't clear.

    This game isn't a "story". It picks Events at random and the player responds to them.

    So one event might have the player in her office and the next Event might be the player in a dungeon with no coherant path from office to dungeon.

    That's not driven by the Tree though. If you were to use this to build a game you could easily set it up so it doesn't pick events at random and events have to follow each other in a logical way.

    I'm just having fun.

    Lastly, I have "Tech Savvy" and "Booksmarts" that seem to be pretty much the same thing. I want six stats so before I go creating a bunch of content I need to think about that some more and figure out a stat that would be better to replace one of the two.
    Last edited by cafeenman; Apr 18th, 2024 at 09:32 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,570

    Re: Random-Depth Tree Creator/Editor

    Ahhh....Nice writeup... but.... you forgot something.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,646

    Re: Random-Depth Tree Creator/Editor

    It's at the top of the post where it's nearly impossible to see. You're looking for the source code?

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,570

    Re: Random-Depth Tree Creator/Editor

    Ah, yeah... missed that... carry on...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,646

    Re: Random-Depth Tree Creator/Editor

    I don't like how that works. In fact, sometimes I put the zip in the middle of the post just so it stands out more. When it's at the top it's really easy to miss.

    In other words, not your fault.

  6. #6

    Thread Starter
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,646

    Re: Random-Depth Tree Creator/Editor

    My "plan" for Points is to be able to put in whole numbers that are taken as-is. E.g. if Points = 1 then you get that many points in that Attribute. But if the number is fractional then it's a percentage of that Attribute. Thus +0.20 would be a 20% boost to whatever. Or -0.20 would debuff that stat 20%.

    Also, I'm realizing I'm gonna need a He/She/It system so that it responds properly to the gender of the person or if it's not a person - animals and objects are "its".

    Otherwise I'm going to have to jump through all kinds of hoops to word things so they don't sound weird and they'll probably sound weird anyway.

    I think I might have bit off too big of a chunk with this project. We'll see....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width