Official development blog

Special Mode Design: Battle Royale

Every good game needs a Battle Royale mode, right? Okay maybe that’s something you’d be more likely to expect from an actual online multiplayer AAA title looking to jump on a bandwagon, rather than a traditional roguelike :P

Nonetheless, I did build one for Cogmind! It was going to be Cogmind’s next April Fools Day event, with the idea originally sparked by a player’s “what if”-style comment on Discord earlier this year.

If you’re not familiar, “Battle Royale” is basically free-for-all survival of the fittest gameplay across a shrinking play area filled with random gear. So here you’d basically be up against a bunch of other Cogmind-like bots trying to survive. I’d never actually played any of the staple games in this genre, my first and only relevant experience coming during 7DRL reviewing for 2019, when I played B-Line, a take on the BR genre within a traditional roguelike framework (original video, when I was going back and playing the top 7DRLs for the year).

I say “was going to be” the next AFD event because although it reached a playable and somewhat fun state, I ended up cancelling it! I’ll talk more about why later on, but first let’s look at the development process and its challenges and solutions…


Like many ideas, as a pure concept “Cogmind: Battle Royale” sounded pretty interesting, but I wasn’t sure just how feasible it would be on a technical level. I mean sure it’s doable, but would the cost be worth it? A pair of very important questions needed to be answered first, so development started with an exploratory phase directed at answering them before actually building this as a special mode.

The first question had to do with factions. Cogmind’s whole relationship system is based on a limited set of hard-coded factions, and there are only 10 of these internally. How to build a system to support free-for-all hostilities between numerous robots? The most straightforward solution would be to dynamically create a unique new “faction” for every single robot. What might this break? I had no idea, since lots and lots of assumptions had been made and reinforced since development began in… 2012 for 7DRL xD. I wasn’t sure how flexible the faction system was, but this was a natural place to start since it would be much easier to test than question #2 to come. I simply created a bunch of extra factions and dropped a single Grunt in each, heading off the few problems that might result and sure enough, each one was running around shooting anything that moved and otherwise behaving as expected. Yay!


Grunts successfully wreaking havoc on -10/Materials, and each other.

The second question would unfortunately be much much harder to answer. It would take a while to explore the feasibility of an AI with Cogmind-like behavior, having the ability to put together and maintain a build from found and salvaged parts, and also manage inventory.

Now if I was just doing this purely for a short special event then I’d be less willing to venture into complex AI territory, essentially because it’s an endless time sink (!), but I liked how this little detour could bring me one step closer to another project I’ve thought about off and on over the years: Having a bot that can actually play Cogmind.

So it was worth a shot and I spent some days hacking together an AI much more complex than anything else in Cogmind (robots normally have relatively simple and predictable behaviors unique to their class, where interesting scenarios are produced by interactions with numerous AIs at once rather than especially smart and capable individuals).

AI Development

Technically I wasn’t starting from scratch on this AI. Quite conveniently there was already another smaller stepping stone in place: Abominations from last year’s Halloween event.

Abominations in that mode are capable of gathering parts to build themselves, but do so very haphazardly and take a lot of shortcuts, being capable of telekinetically attracting any parts they see and pretty much ignoring balance because they don’t need to worry about energy or heat and always have a permanent form of natural propulsion and built-in backup weapon. For build management purposes, architecturally there’s a pretty big difference between an AI allowed to both decide on and complete an action in a single moment, and one that makes a decision then follows it up over multiple turns in a changing environment.

In short, Abominations are a far cry from a true Cogmind-like inventory management AI. But they did require repurposing the player item autoswap feature for AI use, which would form an important backbone of the new AI. As small as it was, at least that bit was already done. To recap, back in Alpha 5c (2015) I added the ability to use a series of simple and predictable rules and to automatically perform obvious inventory management actions on request.


The original diagram I made to explain the smart/automated inventory management system back when it was first added.

Nearly all the same logic could be used by AIs as well, so we have a pretty solid foundation to work from!

The new AI clearly still had a wider range of needs, though, so at this point I didn’t actually start creating the new mode or a Battle Royale map, instead basic AI testing simply happened in a regular Cogmind map. In the first phase of development, I added the following features in this order--the AI could:

  • use core hover (normally all robots other than the player are immobile if they have no external propulsion)
  • switch to different faster forms of propulsion if more efficient
  • collect parts to fill empty slots and also upgrade existing attached parts (however, because this is the AI rather than a player, it can take even more liberties with the swapping, for example removing inactive propulsion that doesn’t match the current movement mode to make room for more of the active type)
  • manage mass vs. support, for example avoiding adding so much mass it goes past a desired overweight threshold, and tries to shed heavier parts if it’s suddenly gotten heavier due to build changes, to maintain speed
  • wander the map while improving its build without fleeing under fire (since it needs to prioritize searching for and collecting weapons if it’s been disarmed)
  • seek out Matter and Protomatter

The first-ever AI to pick up its own parts, when I first started the project.



A slightly less stupid (but still very stupid) later version.

Here I also considered adding ramming to their basic abilities, so that like Cogmind the AI could also have a useful attack while disarmed, but found there were too many complications so although I figured out how it would be possible, ultimately decided it wouldn’t be worth it for this event.

I didn’t get into personalized behavior of any kind, like AIs with a preferred style, since there’s already plenty of randomization and variety coming from the many many parts and their conditions at a given time. This would be a natural future step for a more involved project, however.

The complete non-combat portion of the AI can be summarized with pseudocode like so:


Cogmind Battle Royale AI pseudocode (non-combat state).

Once the Battle Royale AI reached this stage, it had started getting complex enough that it was really annoying trying to fine tune it while working in regular Cogmind/0b10 maps where there are too many distractions. About time to make the new map!

The Arena

The idea behind this mode was that there’d be only one map, the first ever Cogmind mode to pare down the game into such a small “world.” Initial plans set it at 200×200, the same size as Factory/Research, based on my experience designing maps of that size relative to movement speeds, the ranges of sensors and weapons, and perhaps most importantly the total number of participants. 30 seemed like a good number.

At first it was going to be like a typical Cogmind room-and-corridors style map, with a final central room on which the last living bots would naturally converge as the accessible area shrank. Here I was just starting out getting the map generator building out from the central room:


Early WIP Cogmind Battle Royale map layout sample with central room.

As I was fooling around with trying to get it to do what I wanted, a different better idea popped into my head: What if instead of using the normal subterranean-style maps we instead directly converted it to a sort of overland map where rooms are instead “structures”?

This would significantly open up the map, creating additional pathways and a sort of “organized chaos” in the form of a little town without clear straight roads, but all locations are still accessible.


Sample Cogmind Battle Royale map layout.



Sample Cogmind Battle Royale map layout.

I like it! Some of the strategy implications of this approach:

  • makes it much easier to navigate and reach the center (if necessary one can technically even just blow through walls to reach the center once you have orientation)
  • makes it easier to escape if you’re faster than a pursuer, harder if you’re slower (and harder to give chase if you’re slower)
  • easier to spot enemies and be spotted because generally more open
  • less likely to get unnecessarily trapped by the closing circle of death

Plus it’s also kinda neat just to have a different kind of map to play around with.

I called the map “Wartown.”

Mechanics and Features

We’ve got a basic AI and a basic map, next up are features!

  • Everyone spawns in their own room, usually out near the edges of the map.
  • Everyone starts with the same base stats and slot count, but completely randomized gear. It’s more interesting to be forced to adapt, but rather than having players gradually collect their parts from around the map, that entire process can be sped up by simply starting with it. This is more appropriate for Cogmind anyway, because one or two parts alone isn’t enough for an interesting or fun build--you really need a larger collection to be at all effective or to more quickly convert into something effective.
  • Random parts are also scattered across the map (some items found in the regular game are excluded, however, generally things that wouldn’t make sense in this mode).
  • There is no Matter cost associated with attaching parts. This rule change was partially put in place to make inventory management a little easier on the AI (no need to consider Matter waste alongside repeated build tweaking), and also to speed up gameplay in general because it would otherwise be easier for players to run low on or out of matter.
  • Attacks enforce RPGLIKE-like damage redirection where some part damage is transferred to the core, but in this case the rate is only 50% (and armor transfers only 25%). I wanted parts to still take plenty of damage and be destroyed, but at the same time didn’t want too much damage focused on target cores because otherwise bots wouldn’t last long enough in a confrontation, at least not long enough to allow for some tactical variety.
  • Cogmind’s parts do not have their usual high-integrity critical strike protection, and no bot can have their core automatically destroyed by a critical strike.
  • All bots use the normal player-Cogmind rules for increasing system corruption when his with EM damage (so it’s no longer as much of a threat to other robots as it normally is).
  • In addition to salvageable parts, destroyed bots drop both Matter and Protomatter, the latter of which does not decay and is applied in full each turn where necessary/available just by standing on it. Borrowing Protomatter from RPGLIKE mode was essential in maintaining balance because without a way to repair, attrition would inevitably lead to death after one or more confrontations.
  • On destroying a target, the attacker gains a new random slot (awarded on the following turn). This allows for a form of progression, ensuring it’s less advantageous to simply hide from everything and pop out at the end to kill the last remaining enemy, since whoever they are they’re quite possibly more powerful by then.
  • Ambient heat slowly spreads from the four corners of the map towards the center. This is the so-called “circle of death” mechanic important to Battle Royale games in order to force players into eventual contact with one another while keeping it from getting boring. I like the idea of using heat rather than damage to achieve this goal because it builds gradually as it approaches and builds with good dissipation can afford to stay near or in the hot area for longer, not to mention heat has different kinds of side effects. In the end no build can withstand the full intensity of the heat, of course, it just allows for more or less flexibility in that area. The AI is aware of the heat area and acts accordingly.
  • Once only a single bot remains, an exit appears in the center of the map.

Heat encroaching on the map’s center room.

The heat’s color effect is achieved via additive RGB based on the actual ambient heat per cell, so maximum heat actually appears yellow (although the animation still plays out for all hot locations so it’s not a constant yellow).


Full heat has filled the map, though it cannot enter the central room.



Catching the heat mid-glow after it’s covered the map. AKA making procedural art.



Recorded bird’s eye view of heat expanding from one corner over time.

Each player is also assigned a random name with their player number attached. For this I wrote up a list of hundreds of Cogmind-relevant words for use in compounds.


Sample generated Battle Royale “player names.”


Normally I would’ve cancelled an idea a lot sooner in development than this (like the real-time arcade version of Cogmind I never even wrote about here but released to patrons at one point :P) but due to the investment required to develop the necessary AI, it took a while to reach an MVP state so I didn’t get to testing whether it was actually a good idea for a while xD

As soon as it was semi-playable I immediately realized it wasn’t quite going to work, at least not without a huge amount of additional investment that just wouldn’t be worth it for a special mode.

In the end, Cogmind’s mechanics and gameplay weren’t designed to be all that compatible with 1v1 fights between equals, which is what Battle Royale tends to boil down to--you have a bunch of essentially identical players all vying for the win, but Cogmind is meant to be a more tactical one vs. many game (or many vs. many, with factions) in which most bots die quickly and the situation keeps changing as a result, rather than just sitting in one position pelting enemies, which is often what BR mode using Cogmind mechanics ends up as. Certainly you can do a fair amount of stationary farming in regular Cogmind, too, but there’s still a lot of thinking that goes into the plan before the fighting even starts, and that determines how the fight will be likely to go--this is something the AI can’t really do on an equal footing with the player, and it ends up being less interesting as a result.

In BR mode, AIs spot a target and then sit there doing their best to pummel it to death if they’re capable of attacking. Without a much smarter tactical AI that can come up with environment-related tactics and exercise more forethought and better react to spacial disadvantages, it just doesn’t work well.

In hindsight this all should’ve been obvious or could be realized via thought experiment alone, but I was clearly hyperfocused on the AI development aspect and really wanted to give it a try anyway :P

But Playable!

Before stopping work on BR mode, however,  I actually put some more hours into it so that it’d be a more complete and fully playable prototype for patrons who’d like to try it out, and feedback was actually decent! (maybe I was too harsh on the mode and should bring it back one day with a bit more development? :P) The heat mechanic, among some others, is an example of a feature that wasn’t even implemented yet when I first decided to cancel--I admit I also really wanted to see what it might look like :D

I released a special Battle Royale build on Patreon here, and since then have updated the build several more times (in place on the original page) to address bugs and further improve the AI.


A rather quick and explosive skirmish in BR mode.

Features missing from this mode, as released, but that I would have addressed later:

  • prefabs (including special stockpiles and especially better treatment for the center area)
  • more attention to machines (all I did was throw some random machines into the mapgen pool, where ideally the types and compositions would be selected for both better gameplay and atmosphere)
  • message log details about who is destroying who
  • Haulers that teleport in and carry lots of great gear, and everyone gets a ping of their locations (works as a mechanic to force confrontations and give extra rewards those who succeed)
  • different enemy colors to reflect their state
  • different game over screen, a leaderboard ranking all the “players” (unique scoring system) and showing their build classes
  • even better AI :P
  • a more balanced experience overall, or at least “balanced” to maximize FUN


Fortunately most of the work that went into this mode didn’t go to waste. Cogmind Battle Royale may have been cancelled, but the AI lives on! I’ve continued to improve on it (vastly!) for use in a different special event, and there is at least one part of the regular game where I’m interested in incorporating just such an AI. So I’d consider this project a success overall.

This side project also resulted in some general AI improvements and even discovering and fixing one relatively new AI behavior bug that hadn’t yet been reported.

I’m not sure whether I’ll ever get to that AI that can reasonably play the game, although the next little step towards that goal is only barely beyond what we have now--just take the first exit spotted ;)

This entry was posted in Design and tagged , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.


  1. Haku
    Posted March 3, 2020 at 10:59 pm | Permalink

    There are two points that caught my interest in this article:

    * create bot that plays cogmind
    * BR mode being less interesting due to AI limitations

    Instead of BR of human vs bots, expose an API that people can use to create their bots and then pit them against each other in CoreWars fashion? That would level the playing field (all players are bots) and would help Cogmind to expand into another niche.

    Anyway, Cogmind is quite fun game, good luck with continuing development.

    • Kyzrati
      Posted March 3, 2020 at 11:28 pm | Permalink

      Yep, indeed that’s something I’ve considered before, if briefly, and was discussed a bit on Patreon when I first brought up the idea of an AI bot and shared my notes back in September, although even just an API would be a good amount of work that wouldn’t be worth it unless approached as more of a hobby-ish side project, seeing as Cogmind wasn’t really designed with all this in mind to begin with and it’s not really something that would bring in funds, either (can’t say I need yet more non-paying tasks/jobs than I already have here xD).

      Hours and hours of work and in the end only a few people ever get anything out of it… a small niche within an already small niche :P

      I’m certainly interested in it on an experimental level, as it seems like a lot of fun and I’ve always been fascinated by AI, but I feel like too few people would interact with such a thing on a serious level.

      But anyway, you never know. I mean late last year I was saying I’d probably never make a Cogmind-like AI, and yet shortly after that I did Abominations (step 1), then Battle Royale (step 2), and I’m in the middle of working on… step 3 ;). Also each of these steps is getting longer and more involved, which is maybe not a good direction when I should probably try hitting 1.0 some time this decade, heh.

      And thanks!

  2. Daza
    Posted April 4, 2020 at 5:04 pm | Permalink

    Just some thoughts. An interesting read. In many ways Cogmind is like a Battle Royale in a way, with having to find better gear and take chances, make decisions that could pay off or have you on the backfoot or die. You mentioned BR is usually 1 vs 1 when it boils down to the last 2 players, but that is not quite true with team mode in BR. You could have a team of 4 bots, but those teams which cuts cut down to 3 or 2 have a disadvantage when running into a full team.

    I hope in future maybe you might pick up this BR idea again and have another go. I think personally what would be interesting having a non-player mode (you watch) where you the player pick your favorite team, maybe even choose their starting loadout, name and perhaps tweak some ROE (rules of engagement) etc. Then as the game round starts the camera (i use this term loosely of course) will follow them. If they get wiped out, then the team that did so becomes the focus for the camera and the player can continue to watch. Also maybe the player can pan around the map which is completely revealed to the player and they can click on another team and have the focus/cam on them.

    Perhaps some of the main systems are modified, eg. integrity could be none existent or very slow decay to avoid parts that reach zero especially with movement.
    Some funny dialogue for when a team loses a teammate. Perhaps the community could come up with some good ones.

    Watching others play BR can be fun, without having to worry about making decisions, especially watching good players who are good at the game it can be quite entertaining. Rather than a circle of gas or fire or whatever, you could just have the outer parts of the map crumble (much like it does now after big explosions) and ai cannot move into the rubble areas, and some rooms can collapse on bots who are trapped or remain in rooms that collapse as the circle tightens.

    But without turning this into a ramble (if i haven’t already) the other hard part would be having Ai that work as a team, perhaps there could be several formation styles they can adapt diamond, box, line etc and maintain that.

    This makes me think of an RTS called Steel Division 2, not long ago they introduced some new features where the Ai could make their own decisions after the player orders them to take or defend an area and the Ai will determine how best they can do that, freeing up the player to have to do less micro-management. Imagine having a multiplayer mode using the Ai code from BR, where two players do not directly control bots but instead give them waypoints and orders. This could be a fun game to watch others play as well. But alas this is not what Cogmind is about and you do want to finish your game. So i doubt any of these ideas will see the light of day, but still another spin on the BR and Advanced Ai idea.

    • Kyzrati
      Posted April 4, 2020 at 9:04 pm | Permalink

      Yeah I was considering the differences and possibilities with team BR, which would honestly be really fun here, too, but that would be far beyond the scope of an event like this so I didn’t think about it in any serious capacity. It would most definitely be included if this were a (MUCH) bigger thing. Dialogue and more would of course be a thing in that case, too :). But yeah the main problem with the scope is as you say, with team-based AI, because that ideally requires a heavy emphasis on tactics, which is a simply massive amount of work. Like I could spend months and months doing that and it would still be subpar in an environment as complex as Cogmind.

      Regarding “non-player” modes, I agree, and it’s something I’ve got on my list to possibly try one day (although not likely with BR mechanics specifically). Having the new AI from Player 2, and wherever that eventually goes, certainly makes it even more likely now.

      As you allude to, balance of builds is certainly a big issue in Cogmind (outside of things like RPGLIKE mode), so you have to worry about suddenly and easily being rendered immobile :P

      Certainly the RTS concept is very much outside the realm of what Cogmind is intended to be, but is something I think about from time to time. Always too many possibilities and ideas that would be interesting to play with!

  3. Daza
    Posted April 4, 2020 at 5:06 pm | Permalink

    I cannot edit my prev post so i will stick this here..
    Talking about roguelike BR game/mode reminds me of this game in my youth, a C64 game.

    • Kyzrati
      Posted April 4, 2020 at 9:04 pm | Permalink

      Wow, that looks epic…

Post a Comment

Your email is never published nor shared. Only the anti-spam entry is required. See here for the privacy policy.

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>