Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Handling many random bits of text

A topic by Polyducks created Sep 03, 2019 Views: 176 Replies: 16
Viewing posts 1 to 5
Submitted (1 edit)

How do you handle multiple exclusive random outcomes? Here's how I've handled mine at the moment:

if ( chance(50) ){
    if ( chance(50) ){
        print "1"
    }else{
        print"2"
    }
}else{

    if ( chance(50) ){
        print "3"
    }else{
        print"4"
    }
}

If I could set an integer to a random number that might be easier to handle - but I can't figure that out.

Submitted

I guess I could have a subroutine to roll a random number 1-10 with a series of IF statements like the above and save that to an integer, but that feels too messy.

Host

I think this is what you are looking for ... 

This is currently undocumented, but not going anywhere.

   : execute_one_at_random {

      : print "one" ;
      : print "two" ;
      : print "three" ;
      : print "four" ;
   }

Submitted

I suppose you could put more actions into that list if you made each of them a subroutine, right?

Host

Right. Or if you made them an : if (true) {}

Don't use elses in this block at the top level though.

Submitted

Got it. It'd be useful if there was something like Chance(x) which returned a random number instead - i.e. Random(x).

Host

There is a random() function. Random returns a value between 0 - 99 (by default). Every time you call it, it will be a different random number.

Uses:

: set_integer var = "temp"  {( random() )}

Or

: if (random() < 50) {

   : do_something;

}

Submitted

:O!

I wish there were a big list of all these hidden features.

Host

I'm making a cookbook with them at the moment.

One of the goals of "classroon" was to conceal features that were not required to make the 3 "beginner level" Adventuron games:

  • "Escape from Dinosaur Island DX" 
  • "The Cave of Magic"
  • "Excalibur: Sword of Kings"

It seems that the jam is unleashing additional requirements and I require an "advanced user" guide. The cookbook will be just that. It's coming.

The more your document, the more you put off absolute beginners. Onboarding beginners needs is an undocumented goal of this jam. That's why it almost required two community boards. One for absolute beginners, and one for those with preconceptions about what functions they expect from the system.

Submitted (1 edit)

I don't think you need a cookbook - just a list, like in your HTML documentation, is fine. That's initially what I wanted to read, but it hadn't been posted at the time. I ended up doing the whole classroom lesson. I couldn't see the title of the chapters, so I had to do the whole class to unlock what they were.

Incidentally, there are a few typos through the classroom. I had them noted to forward to you, but I since had a restart and lost that notepad. Also, one of the comments in the copy-and-paste at the end of a section are incorrect. I think it's one of the headers surrounded in "#".

I thought the classroom was very thorough for absolute beginners.

I'm also approaching writing my game from the perspective of someone who is used to coding. Having a separate 'add', 'subtract' and 'increment' functions for elements instead of, for example, += is difficult to come to terms with. I may not be the target audience, and indeed what I'm doing with the engine is pushing it to its limits, so I appreciate you being so accomodating.

Host

Adventuron is not perfect for sure. It's taken more time that it should have to get 10% where I want it to be.

Submitted(+1)

Brilliant. I wanted to give my troll a bit more personality. I think I'll be able to do that now with the combination of chance(), random() and/or execute_one_at_random{}.

Regarding a reference manual, rather than beginner's tutorials, that gets my vote!

Regarding typos in the various doco, I've also noticed that, but there doesn't seem to be anywhere to report them. I'm happy to help out there.

Regarding the jam being for absolute beginners, I'm an absolute beginner when it comes to Adventuron, but I'm not an absolute beginner when it comes to programming and text adventures. I imagine that the bulk of itch.io users would be experienced artists and/or programmers, so you really have to expect them to have higher expectations than school children. Personally, I think Adventuron is far too complex for school children because of the convoluted syntax. Even I find it confusing.

Host

"Personally, I think Adventuron is far too complex for school children because of the convoluted syntax. Even I find it confusing."

Teachers are just getting started with Adventuron, but you may in the end be proved correct.

Submitted (2 edits)

I agree about the syntax. If this is an introduction to coding it might make sense to stick to something more c-like. It wouldn't be a huge leap to move closer to JSON.

That said, it's easier said than done, and what's in Adventuron right now is functionable. The explanation about the different meanings for :, = and ({}) helped me understand better, and could be really helpful to have near the start.

One of my other pet peeves was the different typings of strings i.e. boolean "0" or integer "5". true/false and 5 are more succinct and universal.

I like the challenge of coming up with new systems in such a foreign environment though.

Sometimes it's worth putting any dialogue on a loop (with maybe an odd randomly selected comment thrown in every so often) because the chances are, due to how randomness works, that the player won't see the full range of responses you've spent ages writing if it's just down to chance.

Submitted

Regarding random background responses, there are basically three approaches:

1. Purely random.

2. Cycle through them.

3. A combination of 1 & 2.

I like to use method 3. It works like this. You have a list of responses stored in something like a string array. You shuffle the indexes of the array then cycle through the shuffled responses. When you get to the end of the cycle, you shuffle the indexes again and repeat the process. This works really well. It guarantees that you get to see every response at least once before you start repeating them, but they appear to be random once you start repeating them. I'm not sure if you can do this sort of thing in Adventuron (and I certainly won't be doing it for the CaveJam), but I'm sure it's possible.

Submitted

Exclusive random! You could definitely do this in adventuron, but it'd be a massive bulk of code and a stack of booleans.