Author Topic: Conway's Spikes  (Read 5716 times)

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Conway's Spikes
« on: March 26, 2016, 07:40:16 PM »
So I'd like to have a type of large room that is filled with spikes, either retracted or extended.  The spikes extend and retract every x turns, according to a pattern that the player can figure out.

I was thinking of using Conway's Game of Life, but it seems like the grid eventually becomes very stable.  It could be quite a large number of turns before the player finds the spike room, so I don't want it to be a largely static situation when the player arrives.  I also don't want funky-looking patterns, like a bunch of glider guns.  Finally, I don't want to just trigger a bunch of spikes to shake things up, because the that's not a challenge that a sufficiently skilled player can overcome (ie., it's unfair).

I know ADOM uses CA for an herb level or something; any thoughts from the community?

Skullcoder

  • Newcomer
  • Posts: 23
  • Karma: +0/-0
    • View Profile
    • Skullcode
    • Email
Re: Conway's Spikes
« Reply #1 on: March 27, 2016, 04:25:25 AM »
If you know anything about Perlin Noise, or Simplex noise, I'd suggest application of something like that.

You could have a selection of noise generators, which are functions that return values between 0 and 1 for a given x,y, and t (time) input.  Pseudo randomly select N noise generators.  Pseudo randomly generate the parameters for them.  Average the result and apply a high-pass filter (say, values greater than 0.75 == has spikes).   A modulo time domain will create the period of a noise pattern's repetition, and the seeds for generation of its parameters (t can be turns, of course).

Modulating with a Voronoi filter or other such filter before the isSpike() calculation can add interesting patterns.  Biasing the result with simple patterns such linear or circular progressive waves towards the exit [ (distance_from_exit * t) MOD period], etc. can add directionality to the movement of the spikes and help prevent impossible spike rooms.

If you are dead set on using Conway's Automata you can simply select N cells pseudo randomly and XOR these same cells every N turns (no need to randomly select a different location each XOR).  This is like re-seeding the automata sim with a known pattern every N turns and will prevent permanent stability perhaps at the cost of the odd long running emergent pattern (as it will be interrupted via the periodic reintroduction of chaos).  You could experiment to discover a good starting "seed" which produces a nice amount of activity, use that seed as a constant for the spike floor, and then only slightly modify it via aforementioned periodic pseudo random XOR so as to have some control over what to expect without absolute pre-determination.  While this may run counter to your stated desire not to simply trigger some traps to mix things up, it is offset by the initial introduction of a known behavior which meets the requirement of being in a somewhat known state.

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: Conway's Spikes
« Reply #2 on: March 27, 2016, 08:28:59 PM »
In playtesting, it doesn't work real well. I just looks entirely random. So instead, I think I'm going to try out a vornoi map with each zone on a timer (different timers for different zones) and see how that works out.

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: Conway's Spikes
« Reply #3 on: March 28, 2016, 04:13:01 PM »
Update:  It works really well.  I had to play with the timers a bit (20 normal turns turned out to be about right), and I have the floor change color a few turns before the spikes pop as a warning to the player.  While I had initially given them all different reset timers lengths, I eventually found it was better just to give them all the same reset but start out at different increments (ie., each zone changes state every 20 turns, but is generated at countdown step random(1, 20)).  Then I just have to make sure that the only enemies generated in that area are appropriate (flying, don't leave a corpse because corpses obscure underlying terrain).

Skullcoder

  • Newcomer
  • Posts: 23
  • Karma: +0/-0
    • View Profile
    • Skullcode
    • Email
Re: Conway's Spikes
« Reply #4 on: April 01, 2016, 03:30:04 PM »
[...] I have the floor change color a few turns before the spikes pop as a warning to the player.

That's a nifty feature.  Do the enemies know about the spike pattern, or are they alerted the same way the player is, or perhaps there's only flying foes on the floor?  I suppose, if especially devious, the spikes are the only foe required for that floor.

Do link us to any publicly displayable progress when possible.  I'm interested to see how it works out.

wire_hall_medic

  • Rogueliker
  • ***
  • Posts: 160
  • Karma: +0/-0
    • View Profile
Re: Conway's Spikes
« Reply #5 on: April 12, 2016, 03:50:42 PM »
Do link us to any publicly displayable progress when possible.

Sure, here you go: https://www.dropbox.com/s/28anug60aaenrt3/Spike%20Demo.jar?dl=0.
The spikes have a reset of 12 - 16 standard turns, and stay extended for half their reset time.  Stepping on an extend spike, or having a spike pop while you're standing on it deals damage.  You do not take damage for continuing to stand on a spike that is already extended.  There are some safe areas, marked by being a different color.  Only flying enemies who don't leave corpses are generated (and they can't pass through the gateways into the central area).  You need to flip switches in each area to access the next one, ultimately unlocking the stairs in the center of the central room.  This is a mod of the actual game (granted a mod that removes rather than adds), rather than strictly being a demo.