Screeps, standing for “scripted creeps”, is the MMO RTS that makes you code the AI of every unit or structure you control. It’s damn hard doing that absolutely basic stuff in this game, such as gathering resources, let alone mounting a full-scale attack on an enemy.
I was curious, so I popped a few bucks on the starter package anyway. Screeps is one of those long-term games that go for weeks and weeks, instead of just battling it out for 20 minutes. There needs to be time to implement your code, watch it break, fix it, watch it maybe work, and then watch your opponent respond.
The good news was, Screeps is quite well made. There’s a PC client with a good tutorial, but you can also play it in your browser, which meant before long I was logging in everywhere to see how my little Screeps were going. Most of the time, I didn’t actually have to log in though, because there are email notifications for whenever your code breaks or someone attacks you.
It’s quite common in this game to simply wake up and have everything wiped out, the result of an attack your neighbour pulled off while you were asleep. The truly vigilant could wake up when being attacked and respond somehow. Some people in the community have even worked out how to receive SMS alerts, and in true theme they had to code the solution themselves. But I never got that far. It’s amazing I got as far as I did…
Baby’s First Gatherer
The tutorial holds your hand quite a bit, and there’s a sense of dread for a noobie like me that when you’re finally out in the wild, you’re going to get eaten alive. That much was true.
My first attempts at writing my own code for extremely basic things like telling a harvester to go to the resource point were broken for almost an entire evening. Once it was at the resource point, it has to harvest. Then it has to head back.
This all takes quite a while in Screeps’ slow-paced world, but eventually I had a few gatherers out there doing the right thing, and some workers to make stuff for me. It was time to call it a night. I set a few construction projects, expecting them to be done in the morning.
When I woke up, everything was dead. One cool feature of Screeps is that everything that happens in your “room” is recorded, so I could actually see the one basic unit my neighbour sent slowly work its way through all of my creeps and buildings, killing them one by one, unopposed. I’m pretty sure it was one of those situations when someone says “Well look, if you’re going to make it that easy on me…”
Fully expecting to be wiped out again, I chose a spot right between two behemoths. The player to my left owned about 10 rooms. The player to my right owned about 4. I call that player the “Black Hole” player, since the logo is just a black circle. I figured I’d get my code right, not take it seriously, and then see what a full-scale attack looks like when a big player decides to squash someone.
Defences are stronger than attackers in Screeps, so once I had my first tower up, I was okay to expand and breathe easy. Or so I thought. Another night’s sleep, another morning waking up with everything dead. Watching the recording, my tower didn’t actually fire at the hostile creeps this time around. It turns out you have to code your towers, too. Duh.
I built in the same spot, because I didn’t get to see my massive battle yet. Got my tower up, and coded it to attack the first hostile it sees. I get to test it early, because Screeps sends hostile AI units at you periodically, similar to the barbarians in Civ. This raiding party had a healer with it, nullifying my tower damage. I had to edit my tower code on the fly to target the healer long enough for it to be separated from its partner, and then switch it again to kill the partner before the healer caught up.
Believe it or not, it gets tense. Needed some quick improv earlier. They attacked with healers. My code wasn't ready pic.twitter.com/ffVEFoXLLH
— Jeremy Ray (@TheJunglist) July 22, 2016
That’s when things started getting interesting.
You can view any room in Screeps, and I noticed the player to my right was in the middle of a takeover of another player. The other player had towers, but they had no energy. You have to code creeps to constantly dump energy into towers, but if they’re always firing, they’ll deplete themselves quickly.
Then, Black Hole started sending units into my room, only to be damaged, and then come back later when they were healed. The cheeky bugger had coded their towers to repair their creeps, while the creep just went back and forth between mine and their room. The goal was to deplete my towers of energy, just as they had with their other victim.
I adapted my creeps’ code to prioritise tower energy if the towers were below a certain point. After watching it for a while, it seemed to do the trick and I was safe for the time being.
A Rivalry Begins
I decided to try my luck at an attack. Making the biggest group of the biggest attacking units I could, I coded them to gather at a certain point in my room. When I changed the “Attacking” variable in their memory to “true”, they would switch into attack mode and invade the next room, targetting their towers first.
It was a complete failure. Not only did my attackers bunch up and get confused by the one-tile opening at the front of the Black Hole base, the enemy actually taunted me by building a set of construction sites in the shapes of the letters L O L. My units didn’t even reach the first tower.
Meanwhile, I had a success on the other side of my base. Black Hole player had been mining an energy node out in no man’s land, and I wanted to bully him off it. I killed his harvesters and started sending my own. That’s when Black Hole started grouping big, slow attackers for an attack of their own. I saw it coming, and made sure my creeps were ready to dump all possible energy into my towers.
Up until this point, I actually hadn’t seen anyone using Tower Defence strategies with their walls. I figured there might be a reason for that, but I was always one to learn the hard way. Black Hole sent his massive force with the tough task of snaking through my maze while being hammered by my towers. As it happens, they never got into the maze:
But as I found out in a later attack, a funny thing happens when a creep takes up all the space in one path — creeps behind that creep no longer view that as a valid path. The pathfinding AI starts to look for other ways, even if that means exiting the room. Black Hole’s first creep would just make it through the maze before getting killed, and the other creeps died a slow, confused death.
It did flag a potential weakness of mine though — my towers were coded to attack the first hostile, but what if he told his creeps to constantly heal the first hostile? Towers do more damage to units that are closer, so that might help… I started thinking of ways I could counter the counter-tower play. But that was thinking ahead — I was safe for now.
I ended up taking no man’s land from Black Hole, with one of the few bits of coding that I’m actually proud of. Remember how they were using big, slow units? I managed to make some AI for ranged units that would keep a certain amount of distance between them and their target, and somehow it actually worked. The skirmishers fought off Black Hole’s units until they could come up with some sort of counter solution.
But at this point in the game, we had established that neither player had the strength to kill each other. This is where Screeps starts to become a bit like Supreme Commander, strong static defences mean that players will sit back and play it safe until they acquire some kind of doomsday weapon. There is a nuke in Screeps, which both of us are still some ways away from getting. But there hasn’t been much to do in the meantime, and the pace of the game can drag out at times with nothing to do.
As I said at the start, this isn’t a game to learn coding in. But if you already know a bit, it’s a fun way to get from beginner to intermediate.