new civilization positioning

mysterious space sector map

hello, Internet. I thought it might be interesting to explain how I solved a kind-of-weird problem in Mysterious Space, both to give you an inside look at how the game works, but also, hopefully, to show you at least one way that these kinds of problems can be solved.

first of all, the problem was this: sometimes, inhabited planets would be placed very close together:

bad, bad, civilizations

the reason had to do with how I’d been placing civilizations. my method was something like this:

  1. pick a random, empty system in the map, and “colonize” it
  2. until you have colonized six systems, pick a system you HAVE colonized, and colonize a random, adjacent system
  3. choose three of the colonized systems, at random, and uncolonize them

my thinking was that each civilizations would, “realistically”, tend to control adjacent systems, but I knew I’d want some spaces in between, so step 3 was added specifically to put some holes in a civilization.

besides the fact that step 3 won’t guarantee holes in a civ, it turns out that this “realistic” approach was bad for gameplay in a couple ways:

  1. since civilized systems are safe, having several in a row will let you skip a ton of systems. on the way TO the Mysterious Source, this means jumping up in difficulty level significantly (which maybe you want, but probably not), and on the way BACK, it often lets you skip most of the last systems, granting a cheap victory.
  2. with all the civilized systems clumped up, you don’t have many opportunities to shop. either you encounter a clump, and so get two shopping chances – once on the way in; once on the way out – or you don’t encounter one of these clumps at all, and never get to shop!

and though it was rare, sometimes multiple civs would clump together, compounding these problems!

agh!

I still liked the idea of having each civ in its own general area, but it was clear that my current method was not working.

so how to solve it?

there were a couple issues to solve, but I decided to start with spacing, since that was the problem that was most in-your-face.

I knew I didn’t want two civilized systems to be adjacent; I might even want them to be 2 or 3 systems apart… but I also wouldn’t want them to be TOO far apart, if possible…

it occurred to me that, since the system map itself is randomly generated, that even if I overlayed a repeating pattern of “place a civilized system HERE”, you would probably not be able to see that pattern…

what pattern could I use? I came up with this one:

civilization placement pattern

(you’ve probably noticed that the systems in Mysterious Space tend to fall on a grid. if not: well, they fall on a grid – now you know :P)

using this grid, you could imagine picking a random spot on it, drawing a box around that spot – say a 4×4 box – and colonizing all the planets within that box. that would ensure that the planets are near each other, but not TOO near.

but to do this, I’m going to need to a way to tell whether any arbitrary x/y position can be colonized. like say I position a civilization at (-11, 23), and want to check the squares around it… which ones can be colonized, and which can’t?

looking at the grid, I noticed that when y is 0 and x is 0, then the system can be colonized, and then when y is 5 and x is still 0, it can be colonized again: the pattern repeats every 5 rows (and every 5 columns). so if y divided by 5 has a remainder of 0 (or as mathsy people like to say, “y modulo 5 = 0”, or as programmers like to say, “x % 5 == 0”), AND x % 5 == 0, then the spot can be colonized. but when we look at a y of 1 (y % 5 == 1), it changes… and not in a way that’s immediately obvious. going from y = 0 to y = 4, we have:

  if y == 0, and x % 5 == 0, colonize
  if y == 1, and x % 5 == 3, colonize
  if y == 2, and x % 5 == 1, colonize
  if y == 3, and x % 5 == 4, colonize
  if y == 4, and x % 5 == 2, colonize

we could use that logic pretty much as-is, but surely there’s ONE line we can use to describe the entire grid. the question is how to map the y % 5 values (0, 1, 2, 3, 4, 5) to the x % 5 values (0, 3, 1, 4, 2), so that we can compare the two to each other. after playing with the numbers a little, I discovered the connection, and it’s what’s written on the left of the grid image above: x % 5 == (y * 3) % 5, or if you like: the remainder of x divided by 5 (0, 3, 1, 4, 2) equals the remainder of y times 3, divided by 5 (0 % 5 = 0, 3 % 5 = 3, 6 % 5 = 1, 9 % 5 = 4, 12 % 5 = 2).

OKAY.

fine, so now we have a grid. but how are we going to apply it to the system map, to colonize planets? I wanted to make sure each civilization had its own area of the map, where they wouldn’t overlap… how could I pick three starting places and be sure that they’re fairly-equally spaced?

making a grid by hand seemed pretty successful; why not pick the starting postiions by hand as well? 😛

civ starting areas

the diamond represents the general shape of Sector ZZ-Omega-9. (did you know it was a diamond shape?) the large “+” in the center is the x/y coordinate plane. (the Mysterious Source is always placed at (0, 0).) from there, I kind of drew boxes in such a way that I seemed to have given each box an equal share of the diamond, and then guesstimated at the coordinates of those boxes. for example, the left-most box touches the left edge of the diamond, and ends about 1/3 of the way from the center. each box seems to be 2/3 the “radius” of the diamond, and the left-most box is centered on the x-axis, so it must start at y = -1/3, and end at y = 1/3, and so on.

once I had decided on these general areas, the rest was fairly straight-forward: randomly assign a civ to each area; then for each area, find its center, and move outward, colonizing each system whose x and y coordinate falls on our grid – x % 5 == (y * 3) % 5 – until three systems are colonized.

ta-da!

the picture at the top of this post shows one sector generated using this method.

you might ask, though: “is this method perfect? is it even good enough? those rough guesses at civ areas were pretty rough – are you sure they’re equally sized? – and the areas that the civs take up are the same each time! that, together with the grid, makes it pretty easy for a player to know the positions of civilized systems!”

and those might be very fair points! I think, given the random arrangement of the systems themselves, that the final output is sufficiently random… but it is possible that, in the long run, this system will simply be too predictable.

there are a few ways I could increase the randomness, however:

  1. it would be trivial to “shift” our “you can colonize these spots” grid by a random amount by simply adding some random number to the x and/or y coordinates. for example, rather than x % 5 == (y * 3) % 5, we could use (x + RandomShiftValue) % 5 == (y * 3) % 5. just make sure to use the same RandomShiftValue over the course of the entire colonization process!
  2. it would also be trivial to slightly shift the start position from which we start placing each civ; rather than the dead-center of each area, a point slightly off-center by a random amount.
  3. realize that the “areas” we divided the diamond into are kind of silly; in the end, all we care about is a point from which to start placing a civ, and there are better, more-flexible ways to find three points evenly-spaced around a center point: trig! use the angles 0, 120, and 240, offset them all by the same, random amount, and then use cosine and sine to get x and y values.

and I will very likely do all three of these things! (to be honest, I hadn’t thought of them all until I sat down to write this article!)

I hope this has all been interesting to you, as a player of Mysterious Space, as a designer of your own games, or both!

thanks for reading!

so many ideas; so little time

a long time ago I promised to someday get eight-player local co-op implemented… that day has finally arrived! well, or that month, anyway >_> when I release 0.9.1 at the end of this month, we’ll absolutely have support for eight-player co-op. I already have it working, barring any bugs I haven’t discovered (though I don’t expect there to be many – it was a pretty straight-forward addition).

I’m also adding a new co-op option! in addition to being either a normal ship, or an orbital, you’ll now be able to play as the mothership (seen in the tutorial). the mothership gets its own share of the screen, as with normal split-screen co-op, but UNLIKE normal co-op, the mothership does not have a physical presence on the level – it doesn’t fly around the level blasting things and collecting fuel.

instead, the mothership has a new/unique mouse-driven UI which allows the player to help the other player(s) in various ways, for example by firing columns of death upon the planet, upgrading or repairing ship parts it’s holding on to, picking up and pinpointing outpost signals at the moment of entering a planet, changing the weather of the planet, etc.

I haven’t nailed down the exact mechanics for all of these effects (or even what the full list of effects might be), but several, at least, will be in the form of managing system power in order to build effects over time. here is a mockup which might give you a better idea of what I’m thinking:

mothership ui mockup

though the main interface is obviously different, the same mini-map and fuel progress that other players see will also be displayed to the mothership, as this will be used to target some effects, such as the firing of your death laser.

finally: is all of this interesting? will managing progress bars be fun? >_>

I do have some concerns about phrases like “managing progress bars”, but there’s really only one way to find out: build it, and try it! I’ll definitely be giving the mothership as many opportunities to interact with the other player(s) as possible, but if the everything mentioned above isn’t interesting enough on its own, I’ve thought of a few other ways we might be able to spice things up for the mothership player:

  • give the mothership a way to take emergency actions at some cost… for example, perhaps the death laser could be fired early, but at a cost of damaging other systems, or applying some debuff (blindness/sensor malfunction??)
  • give the mothership other threats which it must occasionally respond to, for example a meteor shower could make the mothership decide between reallocating resources to blast away the meteors, or allowing the meteors to fall to the planet, where they might strike the other player(s)

I’m really enjoying adding these completely-new/weird co-op modes to Mysterious Space; I hope you guys are enjoying playing them 🙂

I’ll definitely post again, when there’s more to show!

thanks for reading 🙂

what more can SHOOTING do?

I recently watched a couple videos, and read a couple articles, about the language of games… breaking things the player does down into verbs, the nouns those act on, and the results of those interactions.

in terms of Mysterious Space, you might for example say that the player can DROP things, such as a BATTERY, the result of which is the creation of a timebomb that destroys a ton of stuff on the screen when it blows. the player can also DROP… ANYTHING ELSE in order to create a crate containing that item, allowing some other play to pick up the item.

unlike some better games, however, Mysterious Space’s interactions often end after just one step. (the timebomb example is actually one of Mysterious Space’s exceptions, in that it can have some cascading effects, such as its EMP shots going on to disable a forcefield.) for the most part, you can SHOOT an ENEMY, causing it to die – end of story – or you can TRACTOR BEAM an OBELISK, and that takes you to a crazy sub-level, and that’s cool, but still: end of story.

compare to a Mario game where you can JUMP on a TURTLE, causing it to turn into a SHELL; you can then JUMP on a SHELL, causing it to go flying off, where it might kill some enemies, break some bricks, hit some “?” blocks (which in turn might do any number of things: release a power-up, a spring block, etc).

think about the kinds of things people can make with Mario Maker, and then think of what a Mysterious Space Maker would be, and what players could make with that… … yeah… Mysterious Space Maker would be pretty boring, really >_>

that pretty heavily suggests that Mysterious Space could benefit from an expansion of its verb/noun interactions.

for example: what if a button could trigger something other than a forcefield?

what else might it interact with? the fact that there’s no good answer to that question right now is part of why we have this problem!

so: what if we had objects that spawned enemies, but were tied to buttons, so if you put a crate on the button, it disabled the enemy-spawner?

or: you could have powerful vents controlled by buttons.

what other verbs do we have? shooting… tractor beams… okay: thinking back to Mario’s turtles becoming shells which can be carried, kicked, etc: what if killing certain enemies in Mysterious Space yielded debris, which fell to the ground, but could then be tractor-beamed around, for use elsewhere on the level? (perhaps the debris even occasionally fires off bullets, or lightning, or has some other effect.)

or what if there were other things in levels with their own tractor beams? enemies tractoring items that you must yank away, or structures that just constantly tractor beam things, to cause trouble (and perhaps these are tied to a button, or can be shot with EMP to temporarily disable).

colliding is another verb available to us. currently you can collide with buttons, pickups, and enemies, but there’s also areas-of-effect, like lava and vents, that you interact with by “colliding” with. (thinking about it, “colliding” might be one of Mysterious Space’s richer verbs.) could we have other areas of effect, like shield-regen-boosting, which are perhaps created by players, or enemies, or, again, effected by buttons, or tractor beams (a crate that emits a zone wherein things move FAST).

put some of these ideas together, and you start being able to create some interesting things: an enemy, which on death, creates a temporary zone of “things move fast in here”, which you could use to rocket yourself away from danger. or an inconveniently-placed zone of “can’t tractor beam here” which is created by an object which you can temporarily disable with an EMP shot, which you produce by dropping a battery, and there’s another object on the level which generates a battery for you to collect when its button changes from being unpressed to pressed, and rather than repeatedly press the button yourself, you place a crate on it, and above that crate, a block which periodically activates a tractor beam…

and that situation might be a bit contrived (… maybe!?), but if we had the verbs and nouns in place to support such a construction… what else might be possible to construct? what clever solutions might players devise to the problems the game presents? there’s an awesome possibility here for emergent and clever gameplay.

and all of these things are possible to code, and in many cases, would be quite easy to code. and with a bit of EXTRA work on my part, such elements could be used to create some more-interesting challenges (with multiple solutions) beyond our current “button-triggered forcefield blocks fuel!”

unfortunately, this is not something I’ll be implementing for release this month (gotta’ get this new sector map and alien civilization stuff done first!) but it’s absolutely something I’ll be thinking about more in the months to come!

thanks for reading, and thanks for playing Mysterious Space!

donation update

(tl;dr: $500 donated to Games For Change!)

after doing all my taxes, it appears I was being overly-cautious with the Mysterious Space profits: there’s a bit of money left over that can still be donated!

and really, this is fine: it’s absolutely better to be over-cautious than to be reckless, AND it means there can be an exciting period of donations at the start of the year 🙂

I can donate to FOUR non-profits, and having just donated to JAXA – in the category of space – the first place to start is education! (check out the “donations” page for more about my donation categories and process.)

I’m particularly interested in how games can be used in education, so began my research along those lines. this search lead me, eventually, to Games For Change.

I had a feeling I’d like these guys when I saw this “Sex Etc. Game Design Contest” post from a couple years ago. especially compared to some other non-profits I found (which, for example, seem to be worrying themselves over which games are appropriate for children, and which aren’t), Games For Change is actually interested in CREATING good, educational games! wonderful!

but digging in more, Games For Change isn’t just about education: looking over their various projects, education is definitely a part of what they do, but it seems almost like it’s more often a side-effect of what they do… which is possibly EVEN COOLER of them, but it DOES make me feel that “misc” might be a better category for them than “education”.

and so: $500 Misc to Games For Change! done! (but the hunt for something more-strictly “education” is still on!)

and I’ll definitely be keeping an eye on these guys! I’d especially be interested in other programming challenges or game jams they host – I might participate!

having skipped to the “misc” category, I should also mention “health”! I have some leads on a health-related donation, but there’s a super-specific cause I want to support (antibiotic resistance), and finding something related is proving difficult… so there’s more to do there, too! I think the use of antibiotics in the meat industry is going to be a good avenue… but again, I still need to look around.

I’ll let you guys know what I find, of course 🙂 but that’s all I have for now.

so: thanks for reading, and thanks for playing (and buying :P) Mysterious Space!

0.9.0 updates

Just a quick clarification: what I had been previously calling version 0.8.7 has ballooned into quite a big change, and so I’m now calling it 0.9.0. Really, I should have done this from the start: the civilizations and new sector map are conceptually large… why I didn’t realize this at the start, I’m not sure 😛

But anyway, that’s whatever. Who cares.

What I REALLY want to talk about is my current progress. I did not release at the end of January since the game was not in a playable state at that time.

It’s been two weeks, and the game STILL isn’t ready for release, I’m pretty confident it will be ready at the end of THIS month, so look forward to a release then 🙂

There’s not a lot to say about the progress these last two weeks. For one, my full-time job was super-busy last week. A few co-workers came in from out of town for a big meeting (the development team, which I’m a part of, works remotely). Besides the long days that week, several days were made even longer by after-work dinners and socializing. This is all to say that zero Mysterious Space work was done during that week, or indeed zero ANYTHING ELSE 😛 It was a stressful, but fun week – no regrets! 🙂

It also seems that no matter what month, week, or day, there’s always some other side-project I’m working on. An educational game… a board game… a game jam… I’m not going to apologize for these stealing my time, anymore 😛 Even though they’re unrelated to Mysterious Space, they’re all opportunities for me to do something new, and learn something more. Hopefully, I’m learning a little something from each one, leveling up my real-life skills, getting better at everything I do, including Mysterious Space.

THAT BEING SAID: I’d like to talk about my most-recent side-project, since it is Mysterious Space-related, although not in a way you’d probably expect: I have been planning and writing a story which takes place in the Mysterious Space setting. I would not consider myself a skilled writer, but it is always something I’ve enjoyed doing from time to time, and as I sat down to plan I realized that there are some writing-related tips and tricks that I’ve learned from studying game design (a lot of game design pulls from other media, anyway, including movies and books).

How far will I take this writing project? If I had to guess, I’d say one in every 10 to 20 of my side-projects turn into anything worth sharing, so… we’ll see how this one goes! 😛 But even if it’s something I never finish, I’m sure it will inspire changes to Mysterious Space in the future 🙂

Sorry again about missing last month’s release, but I hope you’ll look forward to this month’s. I’ll try to post a game-play/update video in the coming week, as well, to show you guys some of the new content!

Thanks for reading, and thanks for playing Mysterious Space! 🙂

a big change for 0.8.7

I’ve recently been playing the game co-op with a friend, and we’ve been able to beat Mysterious Space! it took a few tries, and I almost never beat the game, even when I sit down and try, so that was kinda’ cool… but we both agreed that the ending is kind of… “meh”.

like, you win, and there’s a tiny cut scene, and you see some credits, but… I dunno. it was hard to beat the game, sure, but somehow “beating a hard thing” wasn’t reward enough for us.

and I can’t help but think that other people will feel the same way.

so I’ve set about trying to fix this. and it’s entirely possible that my approach will fail, but I’m not TOO bothered by that, because I think that my “solution” will still add something fun and unique to the game.

anyway: I’ll stop beating around the bush, and tell you what I’ve done. then I can explain more about “why” afterwards.

The Changes

Mysterious Space will now feature five alien races who are native to the ZZ-Omega-9 Sector. the sector map will no longer have a fixed layout (it will be procedurally-generated), and will also be much larger than bebefore (it no longer all fits on one screen), but most-importantly, about 20-25% of the systems will be controlled by one race or another.

(it may also be worth mentioning: though the sector is much larger, you will still visit approximately the same number of planets in one play-through. it’s just that there are now more possible paths to take.)

the races themselves are not procedurally-generated. I want your interactions with them, and the consequences of those interactions, to be discrete and easy to understand, so making them fixed seemed like the way to go. (I’m sure I COULD still accomplish this with procedurally-generated races, and I may move to having them proceudrally-generated in the future, but for now, in the interest of ease of programming, they are fixed.)

so what are these races? how will you interact with them?

aliens

from left to right, they are:

Lyra (The Lyran Empire)

this civilization is at war with The Aquilan Empire (next) for control over the very same Mysterious Source that the player is after! The Lyran Empire will not let the player enter their systems unless the player agrees to help them. agreeing to help Lyra makes the player an enemy of Aquila.

I don’t have a super-fleshed out personality for this race, except that, being at war, they do not have time to mess about. you can either agree to help them, or be on your way.

Aquila (The Aquilan Empire)

your interactions with The Aquilan Empire is basically symmetrical with The Lyran. I may put in some slightly different bonuses you get for allying with one or the other, but what it really comes down to is “do you side with one of these empires in order to reach the Mysterious Source, knowing the other will hate you? or do side with neither.”

after discovering the Mysterious Source, there will be a confrontation with both of these civilizations, regardless of who (if any) you allied with. how you resolve that confrontation will definitely impact the last half of the game (your journey home).

Pisces

this tentacled race, along with Auriga and Ophiuchus, are each smaller than either Lyra or Aquila, but have joined together to form The Triad. they are not involved in the war for the Mysterious Source; their main purpose in the game is to give you opportunities to trade for supplies and other services.

I haven’t worked out the details quite yet, but the outposts that are currently in the game will definitely be reworked to tie into The Triad (and possibly Aquila and Lyra as well).

Pisces, specifically, are a welcoming and forgiving species, eager to trade. they will have more-unusual items to sell you than the other races (I’m sure I’ll end up making some items which can only be acquired through Pisces).

Ophiuchus

the Ophiuchustians are the most reclusive of The Triad. they are a race of silent watchers, gathering information, and then dispensing it when they feel “it is time.” before they are willing to deal with you at all, you must prove that you have good intentions.

besides basic services, I’m not sure what exactly I will have the Ophiuchus offer. something information-based, obviously… item identification, perhaps… maps… things of this nature.

Auriga

while Pisces is rather cheerful, and Ophiuchus is reclusive, the Auriga are more middle-ground, and straightforward.

obey their laws, and you are welcome.

their services will be similarly basic and straightforward. I don’t really have much to say about them 😛 I’m not sure if I should strive to make them more unique, or if it’s valuable to have something more neutral in the game. I’ll continue to think on this…

Why These Changes?

previously, Sector ZZ-Omega-9 was a kind of empty place. sure, there were enemies and little outposts, but there were no other entities that seemed to have a definite purpose for being there. it was essentially you against space.

my hope is that by adding other entities to the Sector – each with their own purposes, and each of who you can interact with – I can give you (the player) some interesting choices to make beyond just “which armor do I want to equip?” and also give you an enemy (or two) whose motivations make sense and have purpose, so that, when (if) you win, you can you feel like you actually beat someone/something worth beating.

overall, I hope these changes will give a little context to Sector ZZ-Omega-9, and your adventures within it.

… and again: maybe they won’t!

maybe this idea is all wrong, and winning the game will still feel lackluster, even after these changes. but even if that’s the case, I still think it will have been a good addition! I don’t think I’ve seen something quite like this in another roguelike(like(lite)). it feels “original”; gives Mysterious Space a little uniqueness (though if there’s another game out there with a similar idea, I would not be surprised; I can’t say I wasn’t at least a little inspired by the Civilization games). it will also be a good framework for expanding the game in the future.

I hope you’re looking forward to it!

thanks for reading, and thanks for playing Mysterious Space! 🙂