Quick! How much is 3 times 28? Or in Powargrid terms: do you have enough juice to double charge this tower?
We realized, again as we were watching people play our game, that we make you do a lot of mental math. Now, Powargrid is not supposed to be easy, but it's definitely not meant to be a chore! Last time I heard, computers were pretty good at math, so let us help you out by having them do some for you :)
Yep, the tool tip now tells you how much a double charge will cost, and it'll light up in red if you don't have enough. You're welcome, and sorry it took this long!
Hi, Michiel here! After watching a few videos of people playing Powargrid, I noticed that they were often looking for a place they could place a certain building, moving the mouse around until they found a good spot where they could afford to build it. I've been working on this game so long, I mostly just know without even thinking about it -- so that was a good wakeup call that something could be improved there.
I'm now trying out a little visual aid, by highlighting the tiles you can build on and "lowlighting" (is that a word? de-emphasizing!) invalid tiles.
For me, it's REALLY weird to change anything to the core visuals after staring at them for years -- but I think this is going to be an improvement!
I've just set the new build live on Steam, so everyone should be receiving the new version shortly. Tell us what you think!
Welcome to part 4 of our series about the AI scripting interface, that lets you program your own Powargrid AI in Lua!
This time, I'd like to talk about some of the implementation details of our AI scripting framework. If you just want to write your own AI, you don't need to know about any of this! Still, I'm sure some folks will find it interesting :)
Our game is made in Unity, which gave us several options to embed a scripting language. We went with MoonSharp, for a few reasons:
Playing against someone else's AI means running their code on your computer. We have to ensure that it's safe to do so: we don't want an AI to give someone else access to your computer, to delete your files, or in fact even look at them. That's why the AI scripts run in a secure environment, called a sandbox.
The sandbox strictly limits the files an AI script can access: you can use the "require" function to load additional modules, but you can only load Lua files, and only from two places: the AI's own directory, and the Shared directory that contains utility modules you may want to share between different AIs, like our ailib module.
We also limit the built-in Lua modules you can use. For example, you can have math, string and table, but not os, the interface to the operating system.
Threading and command queue
We had several requirements for the AI framework:
To make that happen, each AI script gets its own Lua interpreter and runs in a separate thread.
Multithreading is hard, especially when you're trying to share data between threads - so we don't, or at least, we share the absolute minimum.
When it's the AI's turn, the framework takes a snapshot of the current game state: how much power does each player have, what buildings are on the board, how many charges does each weapon have, etc.
If the AI calls a function that just returns information about the game state, this is answered based on the snapshot. Since Powargrid is a turn based game, nothing can change until the current player makes a move.
When an AI calls a function to change the game — for example, placing a building — the AI thread enqueues this command and on the next frame, the AI framework, running on the main thread, picks up the command, tries to execute the action, puts the result (whether it was built or not) on the response queue, and takes a new snapshot. The AI thread that was blocking on the response queue picks up the response and returns that to the Lua script as the result of the "build" command, and the AI can continue.
Tomorrow, October 5th, we're launching Powargrid after more than 5 years of working on it. We've talked about that process before here on the blog, but today I found myself just mulling over the idea of making things.
Because, strange as it may sound, I'm really excited by the fact that we've made something that wouldn't have existed if we hadn't made it. Obvious? Yes. But that doesn't make it any less true for me :). If all goes well, starting tomorrow, people will buy, play and enjoy our game. And that's just amazing.
Anyway, we're really looking forward to the launch tomorrow. We're also very curious (and a little terrified) to hear what people think about it. We'll share any reviews, let's plays and other coverage through our Twitter account (@weefreestudio).
- Willem -
PS: just in case you haven't seen our Steam store page yet, here's a link :)
We're Michiel and Willem. Hi!