← Back to Here To Slay

Here To Slay, part 10: how a bot should think

Before I started developing Here To Slay's bots, I read up on how other people build game bots. What I found about play styles, about scoring every move and about reacting at a table with several players.

#tecnico

An online card game has a very simple problem: if nobody is around, there’s no game. With Here To Slay live and a few friends testing it, the next question came almost on its own: “what if you could play against bots?”.

There was just one detail: I had never built a game bot. So, before opening the editor, I went researching. Not a literature review, just a few academic papers and some talks by people who make AI for commercial games, always thinking about my own case: a small card game, with several players at the table, running on a single-processor server. This post is about that research, before any code.

Can the bot see the cards?

The first question was the obvious one: what if the bot cheats? Here To Slay is a hidden-information game, you can’t see other players’ hands or the next card in the deck. A bot that sees everything is much easier to write.

In papers about card games, this bot exists and even has a name: the “cheating” agent. But it isn’t used to play. It’s a reference, the best possible result, to measure how close the honest bots get. The honest bots deal with what they don’t know in pretty creative ways, like sampling several possible versions of the table and testing the move on each one (so-called determinization), or searching over every possible table at once, as in Cowling, Powley and Whitehouse’s Information Set MCTS.

Reading that, I realized those techniques are for people who want the strongest bot possible, and that wasn’t my goal. I wanted a bot that was fun to play against. And for that, the most important rule was also the simplest: the bot can only know what a person sitting in that seat would know.

Every bot with its own style

Anyone who has played Here To Slay in a group knows everyone has their own way of playing: some only think about slaying monsters, some want to complete their classes no matter what and some spend the match getting in everyone’s way. I wanted the bots to be like that too, not several copies of the same robot.

To my surprise, there’s a whole line of research on this, under the name personas. Holmgård, Liapis, Togelius and Yannakakis compared two ways of creating bots with different styles: copying how real people play, from recorded matches, or simply deciding, as a designer, what each style values. The result: the hand-made personas captured how people make decisions as well as the copied ones. Good news for someone like me, who had no recorded matches at all.

A 2021 paper by Perez-Liebana et al., on the strategy game Tribes, shows what this looks like in practice: the same bot, with the same logic, gets different styles just by changing the weights of what it values, while still playing well. And in 2024, Lin et al. proposed a way to measure an agent’s style, by comparing the decisions it makes in similar situations (they tested it on Go and 2048, not card games, but the idea holds).

My takeaway: a style doesn’t need its own rules. It’s a matter of preference, of what the bot picks when it has several good options. And that fits Here To Slay well, with its two clear paths to victory (completing classes or slaying monsters) and a third one everybody ends up using: getting in other people’s way.

Giving every move a score

This was the question that worried me most: how does a bot actually decide what to do?

Many board game papers use tree search, like MCTS, where the bot simulates thousands of continuations of the match before each move. It works very well, but it’s heavy, and a small server running several matches at once has no processor to spare for that.

The answer came from commercial games, in a much lighter approach called utility AI, with Dave Mark as one of its main advocates, through a book and GDC talks. The idea is simple: at each moment, the bot looks at every possible action and gives each one a score. That score is made of several factors, like how much it brings you closer to winning, how much it costs and how likely it is to work. And each factor goes through a response curve, which turns the raw value into a score from 0 to 1.

The curve is where the behavior shows up. One more card is worth a lot when the hand is empty and almost nothing when it’s full. A monster is worth more the closer it puts you to victory. Instead of writing a pile of “if this happens, do that”, you describe how much each thing matters, and the behavior comes out of the scores.

With the scores ready, the bot can just pick the highest one or draw among the best, giving better odds to higher scores. That draw is what keeps the bot from being predictable.

What convinced me most was how this connects to everything else. Styles become different weights on the same scores. An easier bot can just be a bot with less precise scores. And in a dice game like Here To Slay, the chance of a roll succeeding is easy to calculate, so it goes straight into the math.

Everyone against the leader

Here came a curious discovery: almost all classic game AI theory was built for two players. Chess, checkers, Go… In those games, what’s good for me is bad for you, and that’s it. With three or four players at the table, that logic stops working.

Research has a few answers to this. At one end, each player thinks only about itself and ignores the others. At the other, paranoid search, where the bot assumes everyone is teaming up against it. Both extremes are a bit unrealistic, because at a real table alliances shift all the time, as someone pulls ahead.

The paper that helped me most was MP-Mix, by Zuckerman, Felner and Kraus, tested on games like Hearts and Risk. In it, the bot changes its stance by looking at the gap between first and second place. If it’s far ahead, it defends. If another player is far ahead, it goes after that player.

That’s very Here To Slay. Nobody leaves alone the player who is one class away from victory, and that’s exactly what keeps matches close until the end. The same idea applies to reactions outside your own turn, which happen all the time in this game: challenging a card or playing a modifier on someone’s roll depends a lot on who is playing.

Seeming human

The last point wasn’t even in my plans, but it came up in almost everything I read about bots that play with people. A 2025 survey on agents that try to seem human in games points to two problems that keep coming back: reaction time and mistakes. A bot that always answers instantly is obvious. So is a bot that never makes a mistake. The survey itself admits that deciding where and how a bot should make convincing mistakes is still an open question.

In a card game, this is easier than in a shooter, because nobody has to aim. But pace matters: if the bot plays at the speed of light, the table loses the time to see what happened and react. And the most convincing mistake isn’t the absurd move, but the missed opportunity, like someone who only remembers they had a challenge in hand after the card is already in play.

What I took from all this

After all that reading, I knew much better what I wanted than when I started. The ideal bot would be:

  • honest, knowing only what a person in that seat would know;
  • light, scoring its options instead of simulating the whole match;
  • with style, with different preferences on the same scores;
  • aware of the table, always watching who is close to winning;
  • with a human pace, waiting a bit before playing and, now and then, letting something slip by.

Reading before writing saved me from reinventing the wheel and changed the question I was asking. At first it was “how do I make the strongest bot?”. By the end, it had become “how do I make a bot that’s fun to face?”.

For anyone who wants to dig deeper