Skip to content

Yesterday, I solved a longstanding AI issue in my turn-based strategy. Here's what it was and how I did it.

Not downloaded yet
impossiblebottlegames.substack.comhttps://impossiblebottlegames.substack.com/p/threat-modeling-in-multi-turn-strategy

You may (big may, I know) remember my post a few months ago about quitting my job to work on my own strategy game. Well I haven't given up yet, and the game is slowly (oh God so slowly) coming together.

Yesterday I decided I'd take a vacation from endless UI/UX improvements and work on a longstanding AI issue that keeps coming up in playtests. I have professional experience working on AI for games like mine (I used to work on Total War campaign AI), but this is an issue I've not run into before. In my game, the AI is able to plan multiple turns ahead (like a Chess AI might), and that's been screwing around with how it identifies that it is threatened by other players.

Bit of a long story, but I wrote this post about it (actually I wrote the post while I was working on it, which turns out is a great way to organize your thoughts). I've always felt there isn't enough information out there for developing strategy game AI, so thought I'd contribute. Curious what people here think. Did you have this problem and solve it differently?

54 points14 comments
Open on Reddit
About this post
Posted
Archived
Score
54 · 90% up
Kind
Image
ID
1sn61ea

Author

8
posts
34
comments
7
media
View profile

15 comments

Really informative write up thanks! I've been surprised at how decent an AI I've been able to throw together with just assessing current turn options fo rn my hex tactics game, but getting into it planning is definitely the next step and this is really useful in thinking about that criticaly

3 points

It’s definitely a big investment in time to go for multi-turn planning. I knew I wanted to aim for a really dynamic AI from the start of this project so I designed my game and engine around being able to do so. Even then it’s been a lot of work to even get it where it is (which is not done). I don’t think the trade-off is probably worth it for most people.

Optimistically: maybe once I’m done with it I’ll have enough lessons that it lowers the bar for future projects (mine and others’).

But if you ever want to attempt it I’m happy to discuss how I’ve done it or any issues you run into. I find this stuff very fun, so always happy to do more of it.

2 points

Gotcha, thanks for the realistic advice there and also for the offer to chat more about it! Genuinely will take you up on that when Im at that stage, look forward to chatting more (and following along your substack) :)

2 points

I guess my question/concern is. The chess AI has a weighted system where it understands the position of the board as being favored or not. Does your AI have something akin? I think if not, then this is sort of a pitfall.

With all due respect im sure youre more qualified to speak on the matter. However i feel as though a system that understands the balance of poke/sustain/kill and what units serve what role. Then using that info to inform aggressive or defensive postures would go a long way in mimicing human decision making.

2 points

I think I see what you’re asking. A Chess AI typically needs some sort of evaluation function to score a board state since it can’t progress all the way to a game end state. My AI works the same way, with a Polemarch-specific value function that I wrote.

The “threat modeling” I’m referring to in the post is actually part of that function. This post is in part about taking that evaluation logic and moving it into the actual search tree-but in a way that is practical.

2 points

Great read, need to read rest of blog posts. Game also looks interesting, do you have any alpha / beta available to try?

2 points

Thanks :). There isn't currently a public build to playtest, but I want to do that at some point once things are a little more polished. The best way to stay in the loop is probably subscribing to the blog for now, since I'll definitely have a post up there if/when I widen the playtesting.

1 points

So refreshing to read about non-ml actual ai

2 points

I am new to your project and I found the article hard to decipher, there are so many hidden assumptions about the gameplay and the terminology and while the statements in it are true, they are not necessarily written in a way to build a mental image of what is going on from scratch for someone who doesn't already know the context. For example by reading I only learn at the end that player and AI plan their move in parallel? Also I don't know why there are two actions per turn and what the term "plan" really means. Maybe I am not the target audience.

You referred to chess and maybe there are some ideas from chess that can be re-used in your scenario. I am referring to how players evaluate chess positions taking into account factors that go beyond calculation of individual moves and moves tree search, for example development, piece activity and control of the centre. In other words we developed an understanding of chess that identifies more human and more manageable concepts for our minds that lack the computing power of an engine. Conversely we put these concepts in chess engines to supplement pure raw calculation. Maybe you can do the same.

One last thing. I am from Sicily and I can assure you that Carthage wasn't there, lol

1 points

I agree with you about the assumptions. I try to find a balance, but I find it difficult to balance article length with background info.

Your chess comment is similar to the other chess guy. Actually this is how my AI works, with a handwritten evaluation function that prioritizes various soft factors I personally decide on. At some point I’ll probably do a post about how all of the AI fits together-although it’s still changing.

To clarify I have the Carthage faction based in Western Sicily but not the actual city of Carthage there. Similar for Persia, whose home in the game is around Sardis.

1 points

Я столкнулся с другой проблемой. Жёсткие рамки ИИ дают более стабильную, но мертвую генерацию. А слабые рамки дают более живую, но слишком свободную. И сотни тестов системы дают о себе знать. Тут все зависит от подхода, что вы хотите. Можно настроить и заставить ИИ каждый ход считать уровень угрозы от аппонентов. 

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.