Temple of The Roguelike Forums

Development => Programming => Topic started by: Trowel on November 17, 2013, 10:54:51 PM

Title: Physics of Magic
Post by: Trowel on November 17, 2013, 10:54:51 PM
Well it's been a while since I posted here (real life got in the way) but I've got some free time on my hands now and wanted to put it towards making a roguelike with a difference.

I've always been interested in 'pseudo-physics', as a kid I would draw up a bunch of physics theories for everything from time travel to the creation of an entire universe.. Though being terrible at maths it was of course all made up. But of course what makes sense in real life, doesn't necessarily limit what can make sense in a video game ...

And that got me thinking about magic. What if I created a roguelike world where magic logically existed and had it's own set of coherent properties that actually were actually based on 'magic physics'.. Eg: Rather than a magic missile firing in a straight line because I pressed a key, how about the missile being composed of a structure of magic particles which can be affected by the environment as much as the caster.

So what about having a particle that represented 'thrust', which is bound to a particle which produces a huge amount of 'energy' when it 'decays', thus in simple terms, creating a magic missile. But what if each of these particles had 'spin' and could destabilise each-other under certain conditions by 'spinning themselves apart', that is another logical way the spell energy could be created. And it could have interesting effects if for example we have an 'interdimensional particle' which spins in harmony with time and space. Imagine if that particle was ripped apart, it could create a tear in time, giving us a logical reason for a portal to appear, or teleport etc.

It probably all sounds crazy and I'm not explaining it well at all (don't write posts when your tired), but I'm thinking of turning this all into a game. I just wondered if anybody had any thoughts for where else I could go with this sort of theme, my current thinking is to integrate it with the plot so at least all of this 'complexity' has a purpose and becomes a part of the game rather than an unnecessary chore.

Perhaps I'll come refine the idea when I'm feeling more awake, until then feel free to laugh at my craziness and imagine my torment trying to implement quantum physics into a roguelike..  :'(
Title: Re: Physics of Magic
Post by: Gr3yling on November 17, 2013, 11:42:18 PM
I just want to say that I think this is a great idea.  It sounds like it has potential.
Title: Re: Physics of Magic
Post by: Quendus on November 18, 2013, 05:40:16 AM
I toyed with an idea a bit like this a while back - there were particles of magic flying around the map, and you could draw symbols on the map to influence how they behaved. Instead of standing in place and casting a spell, you would move around drawing symbols that made the particles do something that accomplished your goals. The particles could change between different energy states and magic types (standard four elements plus a few other things).

I never put gameplay into this toy system because there was a big problem with it - accomplishing anything in the system meant a lot of walking around doing things that had no immediate effect, during which time any opponent would be either at your throat or miles away from the target tile. An AI opponent working in the same system would be a total pushover, and an opponent who could interfere with your work would make it impossible to get anything done. It probably would have been more suited to a puzzle game.

There's definitely potential in this kind of idea though - I'd like to see what your version looks like (and if it's more suited to a tactics game).
Title: Re: Physics of Magic
Post by: Samildanach on November 18, 2013, 12:39:00 PM
I like the idea, though I'm not sure how it would be implemented. I'm definitely keen to see anything that comes of this.
Title: Re: Physics of Magic
Post by: Xecutor on November 18, 2013, 02:50:54 PM
Thinking about it theoretically is surely fun. But putting all this together in a consistent way is hard job.
And once you will have more or less consistent system, another problem will appear. Balance.
'User made magic' systems tent to be really hard to balance.

I will surely like to see a complete game of this kind someday :)
Title: Re: Physics of Magic
Post by: Vanguard on November 18, 2013, 04:42:42 PM
Thinking about it theoretically is surely fun. But putting all this together in a consistent way is hard job.
And once you will have more or less consistent system, another problem will appear. Balance.
'User made magic' systems tent to be really hard to balance.

What's even more difficult is making them mechanically compelling.  But on the other hand, it's really easy to thematically justify any mechanics you come up with.  That's why it's better to start with a good set of rules and grow a setting around them than the other way around.
Title: Re: Physics of Magic
Post by: Trowel on November 22, 2013, 06:00:23 AM
Thanks for the responses guys and sorry I'm so late in replying to this! I've been really busy working on a Drupal project that is just eating up my free time. As soon as I get that project out of the way I'll try to get a demo up, just something to toy around with ;)

I toyed with an idea a bit like this a while back - there were particles of magic flying around the map, and you could draw symbols on the map to influence how they behaved. Instead of standing in place and casting a spell, you would move around drawing symbols that made the particles do something that accomplished your goals. The particles could change between different energy states and magic types (standard four elements plus a few other things).

That sounds pretty fun actually. My thinking was rather more boring I'm afraid. I was thinking of creating some kind of 'visual magic editor' which you could unlock in the game and that would allow you to combine various components into spells. I haven't really figured out the exact implementation yet though, I might extend it into being a central game-play mechanic if I can think of a way for that to be possible. Currently though I'm just thinking of having spells that can be influenced by symbols or by the environment etc. So you might fire a spell only for it to pass over some hidden symbol and explode into several different missiles killing several monsters in the area but injuring yourself as well.

Thinking about it theoretically is surely fun. But putting all this together in a consistent way is hard job.
And once you will have more or less consistent system, another problem will appear. Balance.
'User made magic' systems tent to be really hard to balance.

Really good point here actually, balance will probably be the most difficult thing to implement. Creating your own spells could be fun but how would you stop someone from creating a 'super spell' which they could just recreate each time. One idea I had is that the more powerful spells might have an element of 'corruption' to them, meaning they could lower your accuracy each time they're used.

Or how about spells that degrade over time. Who says magic stored in a wand or staff can't decompose? Think of it a bit like lighting a ten year old firework, sure it could make a pretty display but there will be a bigger chance that it will miss-fire. Perhaps this could be a way to add a strategy element to spell selection? (though it could just get annoying, like another form of food clock).

Thinking about it theoretically is surely fun. But putting all this together in a consistent way is hard job.
And once you will have more or less consistent system, another problem will appear. Balance.
'User made magic' systems tent to be really hard to balance.

What's even more difficult is making them mechanically compelling.  But on the other hand, it's really easy to thematically justify any mechanics you come up with.  That's why it's better to start with a good set of rules and grow a setting around them than the other way around.

Another good point actually, how can you make a system that is both compelling and yet simple enough to operate with just a few keybindings? I think to a certain degree some clever on screen 'visual effects' can add excitement to an otherwise straightforward system. One thing I like the idea of that I haven't seen implemented is chain reactions. I like the idea that a spell can bounce off a wall, taking a chunk out of it and take out several monsters before exploding in the middle of the dungeon.

As has been pointed out already in this thread though, it's all ok to sit here and type up all these 'great' ideas but there is probably a good reason why they haven't been implemented yet and it's not because people haven't thought of them already :)
Title: Re: Physics of Magic
Post by: Vanguard on November 22, 2013, 09:49:06 AM
One thing I like the idea of that I haven't seen implemented is chain reactions. I like the idea that a spell can bounce off a wall, taking a chunk out of it and take out several monsters before exploding in the middle of the dungeon.

Spelunky is really good at this.  It's full of simple objects that interact with each other to produce complex effects.  Like, you might throw a rock at a monster, accidentally set off an arrow trap, and watch as the arrow strikes a box of explosives that detonates and kills the damsel you were trying to rescue.
Title: Re: Physics of Magic
Post by: akeley on November 23, 2013, 10:20:34 AM
Like, you might throw a rock at a monster, accidentally set off an arrow trap, and watch as the arrow strikes a box of explosives that detonates and kills the damsel you were trying to rescue.

If this is a real example, I might give it another chance. I`ve a phobia of platformers and while I play them occasionally, they`re always on my gaming  backburner. But I`m a sucker for emergent gameplay so this sounds pretty cool.
Title: Re: Physics of Magic
Post by: Vanguard on November 23, 2013, 05:38:44 PM
That example is 100% real.  Spelunky is full of naturalistic Rube Goldberg devices.  The commercial version does them better, but the freeware Spelunky is still good at it.
Title: Re: Physics of Magic
Post by: Hulander on November 27, 2013, 07:39:37 PM
I think this is a really cool idea. Another game that made player created spells fun was Magicka, although that was more of a party game I still think it would be possible to modify the concept so it plays well in other types of game. For instance instead of having an infinite amount of spell power each spell type would be considered a resource. I think this would make the game a bit more interesting since the player would need to figure out the best spell to use at a given time instead of just casting the same spell over and over.

One way to avoid the super spell would be to add some kind of danger element to spells, like the more effects you add to a spell the more dangerous its for the player to use it. This would allow the player to create crazy spells but they would probably not survive after they used it.
Title: Re: Physics of Magic
Post by: Quendus on November 28, 2013, 04:33:12 AM
The podcast is a bit long, but there are some parallels between spell customisation and unit customisation in strategy games: http://flashofsteel.com/index.php/2012/07/23/three-moves-ahead-episode-178-unit-customization-and-game-design/
Title: Re: Physics of Magic
Post by: Krenium on December 02, 2013, 12:57:10 PM
I have put a lot of thought into this topic. I mean a lot. One thing I've always wanted to do is create a roguelike where you are tasked with researching magic. Everyone always goes on and on in their games about how wizards attend academies and study diligently. And I think to myself, wouldn't it be rewarding if the player actually had to research and discover magic for himself?

I've always wanted to tie linguistics into it. For instance, maybe the aspiring mage says the word "peh" out loud and he notices that the air around him seems a little warmer. He investigates further by saying "pehra" and the effect seems to be strengthened. He adds the word "rhi" in front which has proven to strengthen the effects of most magic in past experiments, and suddenly he has discovered a spell to keep himself warm on the most frigid of nights! Now he has learned a spell which he can call on time and time again. His learning wasn't constrained by some skill tree and his experience isn't denoted by XP; he learned the spell through experimentation and he is naturally more experienced as a result.

I eventually came to the conclusion that a convincing procedurally-generated system like this must be based upon a strongly axiomatic system. Thinking of it in terms of physics and particles could be a clever way to model this. This particle always travels against gravity. This particle has a half-life of 10 turns. That particle exerts a strong force on others around it. When this particle and this particle collide, it creates a new particle and releases energy. Simple rules often have profound influences and can be used to build unexpected things. The key is to let the player have access to this power, unhindered by cumbersome interfaces and overly-prescriptive rules and abilities.

Regarding the topic of spamming "super spells:" I agree this can diminish the fun and novelty of any game. I can't remember where I first came across the concept—I believe it may have been an anime?—but there was this universe where saying a word out loud caused a magical spell, but no one was physically able to speak that word ever again. It simply vanished from existence at that point. I found the concept to be utterly fascinating. However, this would negate the benefit of discovery, so perhaps a compromise could be made: each successive use of a spell diminishes its potency, so eventually you have to branch out to other things. But in the mean time, you can leverage your discovery.
Title: Re: Physics of Magic
Post by: Krenium on December 02, 2013, 01:12:33 PM
(Double-post; sorry!)
Title: Re: Physics of Magic
Post by: AgingMinotaur on December 02, 2013, 01:23:53 PM
I eventually came to the conclusion that a convincing procedurally-generated system like this must be based upon a strongly axiomatic system. [...] Simple rules often have profound influences and can be used to build unexpected things. The key is to let the player have access to this power, unhindered by cumbersome interfaces and overly-prescriptive rules and abilities.
Interesting. I remember the point'n'click adventure game Loom had a system where you learned to weave new spells, each spell consisting of a series of notes. There were even some puzzles where you reversed the effect of a spell by playing it backwards. Of course, this was all fixed content, and a system where some of the axioms are randomized for each playthrough could be quite cool, providing something akin to your typical identification subgame.

As always,
Minotauros
Title: Re: Physics of Magic
Post by: Xecutor on December 03, 2013, 03:59:44 AM
I can't remember where I first came across the concept—I believe it may have been an anime?—but there was this universe where saying a word out loud caused a magical spell, but no one was physically able to speak that word ever again. It simply vanished from existence at that point. I found the concept to be utterly fascinating. However, this would negate the benefit of discovery, so perhaps a compromise could be made: each successive use of a spell diminishes its potency, so eventually you have to branch out to other things. But in the mean time, you can leverage your discovery.
Several years ago I read a novel where magic had somewhat similar principle. Magician could turn almost any sentence into a spell.
But every time the some sentence was used as a spell, it was loosing strength a little. So, over time most common sentences weren't working at all anymore.
Magicians had to come up with weird and ornate sentences in order for their magic to work.

Too bad it is practically impossible to make a game based on this. Very powerful semantic analyzer is needed for this.
Title: Re: Physics of Magic
Post by: Trystan on December 03, 2013, 07:01:07 AM
I've seen something like this before.

I played an rpg long, long ago - back in the DOS era - where one of your party members could craft magic spells. There were ingredients and ruins that were chained together to determine the effect (fire, poison, ice, etc) and the shape (projectile, cloud, 8 adjacent tiles, etc) of the spell you are crafting. Hitting a creature or wall would begin the next chunk of the spell. So you could create a spell that would make a fire projectile that, when it hits something, creates clouds of poison in the adjacent tiles. That would require sulfur, a projectile ruin, frogs, a cloud ruin, and an adjacent tiles ruin. Or something like that.

I think my most used spells were a projectile that makes a healing cloud and another one that created a cloud that shot fireballs in 8 directions. It was glorious. I hope you come up with something.
Title: Re: Physics of Magic
Post by: Trowel on December 05, 2013, 05:45:44 PM
Thanks for all the interesting responses to this thread guys, I'm still working on another project which is eating most of my time but as soon as that is done with in a few days I'm going to try and write a simple experiment to test some concepts for this game idea. A sort of unofficial seven day roguelike and I'll post up the results here.

I really love the ideas here anyway and I have some more stuff to say, so I'll come back and reply to the discussion properly once I've got time a little later today (I'm on a super short break now).  ;)
Title: Re: Physics of Magic
Post by: Serefan on December 08, 2013, 11:22:34 PM
Definitely an interesting idea. I'm imagining a narrative-heavy game, in a world where magic spells have been in use for quite a while, but never fully understood. They were more viewed as a thing that has 'always been there', and should be used in conformity with the laws. Schools have long teached several magic spells, but these teachings never really evolved beyond basic fireball, ice cloud, heal wounds, etcetera. Until one guy suddenly discovered the true powers behind them in a very Newtonesque way. But because of the experimental nature of his ideas, they were dangerous, and therefore, feared and misunderstood. So he was mocked, shunned; he fled, and brooded... Biding his time.. He would show them... HE WOULD SHOW THEM ALL! MWHAHAHAHAH!

*cough* Sorry, got a bit carried away there.
Title: Re: Physics of Magic
Post by: Vanguard on December 09, 2013, 12:01:51 AM
I've said this before in another thread somewhere, but the absolute best way to get an interesting and believable magic system is to borrow from a real world culture's beliefs.
Title: Re: Physics of Magic
Post by: AgingMinotaur on December 09, 2013, 01:30:00 AM
Thales: sounds interesting. Is the player put in the shoes of the "mad scientist", or a disciple or some other character figuring out the details? Release early, release ofen :) (Also, a thousand actors per second doesn't really sound that bad to me; the real trouble starts when each of them are doing complex calculations, like heavy duty AI or area effects.)

As always (going off on a tangent),
Minotauros
Title: Re: Physics of Magic
Post by: Serefan on December 09, 2013, 01:53:26 AM
Thales: sounds interesting. Is the player put in the shoes of the "mad scientist", or a disciple or some other character figuring out the details? Release early, release ofen :) (Also, a thousand actors per second doesn't really sound that bad to me; the real trouble starts when each of them are doing complex calculations, like heavy duty AI or area effects.)

As always (going off on a tangent),
Minotauros

How did you... What the... My good sir, you seem to have tried to answer to two different threads in one post if I'm not mistaken. ;D

As for the brief story I jotted down here, anything goes really.
-> The scientist guy is the ultimate Big Bad of the game who himself is convinced he is working for the greater good
-> The guy could have gone undercover in a small farming village that hasn't heard of his deeds, helping out the villagers, posing as a humble skilled alchemist. The player then starts out being his apprentice (optional plot twist, the missions he sends you on is ultimately for some form of great evil)
-> The guy is very esteemed until the he reveals his ideas, gets stripped of all his influence and renown, and has to prove himself yet again (in this scenario the player is the scientist)
-> The guy wasn't really in control of what he was experimenting with, unleashed a great terror into the world, but since he's a good guy, he'll continue to hone his newfound skills to try and fix his error and save the world

You can go with it in so many directions. What's nice about this kind of 'logical magic' is that, narrative-wise, you can associate it with some goings-on in the real world, compare it to the controversy of certain scientific or religious happenings in the past or present.