NaNoGenMo / 2018

National Novel Generation Month, 2018 edition.
https://nanogenmo.github.io/
112 stars 6 forks source link

Dungeon Crawl #13

Open shakna-israel opened 5 years ago

shakna-israel commented 5 years ago

Entry Repository.

I've been kicking an idea around for a while, though I've not yet tried to implement it.

Procedurally generate a MUD-style world, and then send a series of adventurers through it, and log their progress.

Not very exciting, though perhaps vergining on readable which is sort of my goal.

There's the issue whereby adventurers may die, before we get the length of novel we want, because I rely so heavily on randomness for this sort of thing. Hence the series of adventurers.

Not sure if I want to keep trying until I get one of the right length, or send in new adventurers, and have the dead haunt whatever room they died in.

Tweaking how the NPCs, who write our story for us, behave would probably take the most amount of time.

kleer001 commented 5 years ago

Ha, nice! I too am aiming for readability. I'll certainly be keeping an eye on your progress :)

shakna-israel commented 5 years ago

Mmm. Your idea seems the closest one can get to readable without fullblown Natural Language Processing the entire work.

I'm a bit lazy for that, so I'll be relying less on a corpus, but more trying my hand at sentence construction. Hopefully with enough conditionals the reader won't be able to tell they're just reading the same thing repeatedly.

LuRsT commented 5 years ago

I had a very similar idea, but simpler where I'd send adventurers down a single corridor fighting monsters, eventually dying and then another one would venture down. I might still do that, hopefully not too similar to yours :smile:

shakna-israel commented 5 years ago

@LuRsT It'll be different. Even if we had the exact same idea, programming is fairly creative, and even the RNG we use would be able to bring fair differences.

If it's any help, I'm probably going to see how much I can get away with just by using a shell script. It has basically all the things I want, whilst being fairly fast to write.

shakna-israel commented 5 years ago

4 days til I can start. Might looking forward to this. Entry repository.

cantino commented 5 years ago

Great idea! I'm thinking along similar lines.

You could run the simulation many times and then score the results based on some concept of a dramatic arc, selecting one that meets your search criteria.

shakna-israel commented 5 years ago

I've started, I'll get around to uploading it eventually, but my local clock being futz'd because of the EU changes has kinda screwed with git's datetime stamps. Looking into fixing that now things are settling down.

But, here's an early sample, from an incomplete input:

Dungeon Crawl


Prologue


Grief has stricken the land. Horror sweeps over the night. Our princess has been stolen, and with her, her protection. No more magic to save us from the ghosts beyond the Demonwall. She was taken, by a great evil, and hidden away in a labyrinth beneath the ground. It was X'wa the Warrior who delved below, to save our hope.

X'wa the Warrior Fantastic Hope


A small stream runs down one wall of the cave.

Undaunted, the Warrior heads deeper.

X'wa the Warrior finds a Fantastic Hope


X'wa turns their gaze to the next narrow opening, that joins this cave, to the next.

Obviously, the low level fights, and the environment descriptors are the most pressing at the moment.

I'm being fairly linear - the hero/ine (going for a genderless hero, let the reader supply their own connection to the protagonist) will always reach the end of the story, but I've got about four states lined up for that, which each can take different descriptors... Me, being me means that only one of those four outcomes is actually 'happy'. Whoops.

Title descriptors for the chapters are craaaaaaaaaaaaaaaap, unfortunately. I'll need to rethink it. (I need something other than numbers, because of the way pandoc is generating chapter headings).

PDF output is the prettiest, as expected, but I'll upload a sample pdf, epub and html page when I get this thing closer to a finished state. It requires a lot of creative writing on my part, because of how I've structured things.

Each chapter is made of a series of descriptors, and chance encounters.

Building a full-sized novel (with incomplete descriptors) only takes about 15mins on my terrible (Celeron) laptop, which is surprisingly good.

Another quick sample:

A small stone catches the eye of Elptibud. It's a diamond. Knocked loose from some larger arrangement. The princess came this way.

Elptibud turns their gaze to the next narrow opening, that joins this cave, to the next.

shakna-israel commented 5 years ago

Basic story structure:

Then once enough words have been generated, we move into the climactic moment:

Then we send that final output off to pandoc, for our final formats (PDF, ePub, HTML).

It may be overly simple, but it's getting close to being something actually readable for three or four chapters. Of about 30-60 that get generated.

shakna-israel commented 5 years ago

Ignoring the missing fight scene, and awful title, this is pretty good:

Kcohav the Warrior's Joyous Encounter


Some crystalline structures can be seen lining the walls.

Something growls in the dark.

Echoing, from some distance, a voice speaks: 'Kcohav, did you know? That you were doomed even before you began?'

Kcohav turns their gaze to the next narrow opening, that joins this cave, to the next.

Kcohav lay on the ground, coughing as they drowned in the blood pouring from their shattered frame. It was over. The battle was lost. The princess was gone. Evil would inherit the surface... What evil? Humanity would be expunged... Which meant there was no evil, not anymore. Just the rightful owner taking back what was already theirs. Humanity was the evil. Kcohav closed their eyes, for the last time.

shakna-israel commented 5 years ago

Still getting issues occasionally:

pandoc: Cannot decode byte '\xc3': Data.Text.Internal.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream

Something to do with the name generator, I think.

gen_name_diagram() {
  # Grab a random twochar selection from the dictionary, and lowercase it.
  val=$(cat /usr/share/dict/words | cut -c-2 | uniq | shuf -n1 | tr '[:upper:]' '[:lower:]')
  # If we got something nonenglish, retry.
  while [ "$val" = 'bq' ] || [ "$val" = 'bz' ] ||
  [ "$val" = 'cf' ] || [ "$val" = 'cj' ] || [ "$val" = 'cv' ] ||
  [ "$val" = 'cx' ] || [ "$val" = 'fq' ] || [ "$val" = 'fv' ] ||
  [ "$val" = 'fx' ] || [ "$val" = 'fz' ] || [ "$val" = 'gq' ] ||
  [ "$val" = 'gv' ] || [ "$val" = 'gx' ] || [ "$val" = 'hx' ] ||
  [ "$val" = 'hz' ] || [ "$val" = 'jb' ] || [ "$val" = 'jd' ] ||
  [ "$val" = 'jf' ] || [ "$val" = 'jg' ] || [ "$val" = 'jh' ] ||
  [ "$val" = 'jl' ] || [ "$val" = 'jm' ] || [ "$val" = 'jp' ] ||
  [ "$val" = 'jq' ] || [ "$val" = 'jr' ] || [ "$val" = 'js' ] ||
  [ "$val" = 'jt' ] || [ "$val" = 'jv' ] || [ "$val" = 'jw' ] ||
  [ "$val" = 'jx' ] || [ "$val" = 'jy' ] || [ "$val" = 'jz' ] ||
  [ "$val" = 'kq' ] || [ "$val" = 'kx' ] || [ "$val" = 'kz' ] ||
  [ "$val" = 'mx' ] || [ "$val" = 'mz' ] || [ "$val" = 'pq' ] ||
  [ "$val" = 'pv' ] || [ "$val" = 'px' ] || [ "$val" = 'qb' ] ||
  [ "$val" = 'qc' ] || [ "$val" = 'qd' ] || [ "$val" = 'qf' ] ||
  [ "$val" = 'qg' ] || [ "$val" = 'qh' ] || [ "$val" = 'qj' ] ||
  [ "$val" = 'qk' ] || [ "$val" = 'ql' ] || [ "$val" = 'qm' ] ||
  [ "$val" = 'qn' ] || [ "$val" = 'qp' ] || [ "$val" = 'qq' ] ||
  [ "$val" = 'qv' ] || [ "$val" = 'qw' ] || [ "$val" = 'qx' ] ||
  [ "$val" = 'qy' ] || [ "$val" = 'qz' ] || [ "$val" = 'sx' ] ||
  [ "$val" = 'tq' ] || [ "$val" = 'vb' ] || [ "$val" = 'vf' ] ||
  [ "$val" = 'vh' ] || [ "$val" = 'vj' ] || [ "$val" = 'vk' ] ||
  [ "$val" = 'vm' ] || [ "$val" = 'vp' ] || [ "$val" = 'vq' ] ||
  [ "$val" = 'vw' ] || [ "$val" = 'vx' ] || [ "$val" = 'wq' ] ||
  [ "$val" = 'wv' ] || [ "$val" = 'wx' ] || [ "$val" = 'xd' ] ||
  [ "$val" = 'xj' ] || [ "$val" = 'xk' ] || [ "$val" = 'xr' ] ||
  [ "$val" = 'xz' ] || [ "$val" = 'yq' ] || [ "$val" = 'yy' ] ||
  [ "$val" = 'zf' ] || [ "$val" = 'zr' ] || [ "$val" = zx ]
  do
    val=$(cat /usr/share/dict/words | cut -c-2 | tr '[[:alnum:]]' | uniq | shuf -n1 | tr '[:upper:]' '[:lower:]')
  done
  echo "$val"
}

gen_name() {
  # Fairly crappy name generator.
  name=''
  for i in $(seq 1 $(shuf -i 2-4 -n 1)); do
    name="$name$(gen_name_diagram)"
  done
  # Capitalise first letter
  name=$(echo "$name" | awk '{ for ( i=1; i <= NF; i++) { sub(".", substr(toupper($i),1,1) , $i) } print }')
  echo "$name"
}

I would have thought passing it through tr '[[:alnum:]]' would have killed any odd symbols, but who knows. Debugging something where everything is random is kinda difficult.

shakna-israel commented 5 years ago

I hate time.

Latest commit d2a4350 an hour from now

shakna-israel commented 5 years ago

Today's journal entry: Heat wave, and cluster headache... Yeah, not much is getting done today.

shakna-israel commented 5 years ago

Pre-release demo files are up: here.

They are incomplete, but show the basic structure and how it's coming along. I'm kinda impressed.

LuRsT commented 5 years ago

Wow, so much progress! Keep it up!