elBukkit / MagicPlugin

A Bukkit plugin for spells, wands and other magic
http://mine.elmakers.com
MIT License
233 stars 152 forks source link

Help understanding settings for automata #1347

Open Mineshaft87 opened 2 months ago

Mineshaft87 commented 2 months ago

Hi Nathan, Really enjoying automata now that they have been fixed. Many thanks for that! I was wondering if you could help me understand their unique settings so i can go about editing them and making my own, no one in the discord appears to know much about how to do so. I've tried finding their explanations on the reference manual and wiki's without much luck. The example spells on the elmakers sandbox site is super useful, i was wondering if you could do something similar for an automata spell like the Snake.

Mineshaft87 commented 2 months ago

Hi Nathan i understand this would be time consuming, is there an amount i can pay you for it? I'm really keen to utilise automata as a key part to my server Discord #mineshaft87

NathanWolf commented 2 months ago

Automata are.. weird :)

They are kind of a pet project of mine, but the first thing you should know about them is that they're not really totally controllable.

There are basically two facets to them:

  1. Some basic logic about how they target, what spells they cast, how fast they move, how big they can be, what materials they can be made out of, that sort of thing. I'm hoping these parts are all fairly clear when looking at the configs of an existing automata type (e.g. hunter.yml) but if you have specific questions about any of these pieces please ask.

  2. Then there's the simulation ...

Automata are based on Conway's Game of Life. If you weren't aware of this then it's good to know, you can read up on it here: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

The basic gist is that it is a "cellular automata simulation". This is a class of algorithms that work with a grid of cells, each cell follows some specific set of rules, generally based on what it sees in the cells around it.

Automata in Magic are a 3-D variant of the game of Life. So each automata runs a simulation every tick using the blocks around them as cells. Air blocks are "dead" and solid blocks are "alive" for the purposes of the simulation.

What this all comes down to is there are two sets of rules that each cell follows, every tick it will basically follow two paths:

  1. If a cell is alive, does it stay alive or does it die?
  2. If a cell is dead, will a new living cell be born in its place?

From these rules we get the different shapes of each automata. The shapes emerge from the rules, there is no real way to say "I'd like it to be more solid", strictly speaking.

So for instance, the Hunter uses the following rules:

        live_rules: 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
        birth_rules: 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26

This means that any living cell with 5 or more living cells around it, will continue to live. Any dead cell with 5 or more living cells around it, will become living. (Note that since neighbors are in a 3x3x3 grid, 26 is the total number of neighbors any cell can have)

The effect here for Hunter is basically that it will create a solid sphere. Things get a little more organic than just that, especially once you start destroying blocks (cells) when attacking it, but roughly it just keeps a spherical shape.

The Virus on the other hand has a more restrictive set of rules:

        birth_rules: 1,2,3
        diagonal_birth_rules: 0,1
        live_rules: 1,2,3
        diagonal_live_rules: 0,1

So here you can see that it avoids "crowding" by only surviving if there are a small number of neighbor cells. It also has separate rules for diagonal blocks (neighbors that are not directly NESW/Up/Down).

The result there is that it forms roughly straight lines with spaces in between.

The various specific of Automata are things I got just by experimenting with these rules and seeing what happens. There isn't really a guide nor any real rhyme or reason to it, honestly.

So what I would suggest to you if you want to make a new variant is to just experiment. Pick one that's closest to what you like. Maybe remove its spell list to start with to make it easier to test.

Then just play with the rules and see what happens. You may get something that dies off immediately, or you may get some cool new organic shape. It's kind of hard to say, honestly!

Let me know if I can help more, it is kind of a weird system, like I said a pet project so maybe a little hard to mess with, but hopefully it's a fun process :)