Bringing the Ninja Into the Dojo

The upcoming Hidden Blades expansion is the first time the Hidden Path Dojo will include hidden information.

Up until now, every piece on the board has been visible. You can see every Disciple, every Sensei, every movement card in play. If you lose, you can think back through the game and point to the exact turn where things went wrong.

The Ninja changes that rhythm completely. It moves in secret, it can share a square with another hidden Ninja, and sometimes the game literally asks you, “Are you sure they are standing there?” and lets you commit to that guess.

This post is about the Ninja itself and what it took to make that one piece work inside a system that started life as a pure perfect information game.


How the Ninja behaves

The Ninja uses the same movement cards as everything else, but it sneaks in a second move each turn.

On your turn you still start the same way: pick a card, move a visible piece according to that card’s pattern. That part has not changed at all. The Ninja lives in the next step. After you complete that visible move, you may move your Ninja using the same card.

Moving the visible piece is mandatory if there is a legal move. Moving the Ninja is entirely optional. Sometimes it is correct to dart forward into danger to take a piece. Sometimes it is better to stay absolutely still and let your opponent convince themselves you moved.

Ninjas start hidden. At the start of your next turn, your Ninja hides again automatically. Two hidden Ninjas are allowed to stand on the same square at the same time. If a Disciple or a Sensei moves onto a square where an enemy Ninja is standing, whether that Ninja is hidden or revealed, the Ninja is captured and removed from the board.

Capturing with your own Ninja can happen in two ways. The straightforward way is to move your Ninja onto a piece like any other capture. You reveal yourself, take the piece, and then your Ninja will slip back into the shadows at the start of your next turn. The more dramatic option is the guess. If your opponent’s Ninja is still hidden, you can select your own hidden Ninja, pick a square where you think theirs is hiding, and commit. If the enemy Ninja really is there, you take it. If not, nothing happens. In either case your Ninja is now revealed until your next turn.

So each turn has two layers now. There is the public layer that both players see and can reason about, and the private Ninja layer that only you know. Most of the tension in Hidden Blades lives in that gap.


Teaching the engine about secrets

The original engine for Hidden Path Dojo was built with a very simple model in mind: there is one board and everyone sees it. That is true for both human players and for the AI. A replay could simply show every move because there was never anything to hide.

The Ninja forced that model to split.

Now there is the true board that the server knows about, and two separate views of that board, one for each player. Your view includes the exact position of your own Ninja and whatever can be deduced about your opponent’s. Their view does the same from the other side. Both of you see the same visible pieces, but your Ninjas live in your own private layer.

That meant refactoring a lot of code that used to just ask “what piece is on this square” into “what does this player think is on this square right now.” It meant changing how we store move histories so that replays can show “what you knew at the time” instead of accidentally showing every hidden step your opponent took. It also meant teaching the UI to draw the same board in slightly different ways depending on whose screen we are talking about.

From the outside, you just see your Ninja standing in a highlighted square and an empty square where theirs could be. Under the hood the game is now very careful about who is allowed to see which.


Letting the AI play fair

Once the rules and the board were split into those different views, the next problem was the AI.

On the server, it would be very easy to let the AI look up the true location of every Ninja and act accordingly. That would make for a strong opponent and a completely miserable experience. If the computer hits every guess capture perfectly, it stops feeling like a mind game and starts feeling like playing against someone who can see through the board.

So the AI is not allowed to peek.

Instead, when the AI is thinking about moves, it treats hidden Ninjas as unknowns and fills in that unknown with a bunch of “possible worlds.” When it simulates the future, it first asks “where could a hidden Ninja be right now” and places them on empty, legal squares in those simulations. It then plays out those simulations as if those were the real positions.

From its point of view, Ninjas are always somewhere that makes sense on an empty board, but never in a place that comes from secret knowledge. Sometimes that means the AI accidentally plays around a threat that is not really there. Sometimes it walks into a real Ninja because the simulated one happened to be somewhere else. Over many games this gives it a healthy respect for the Ninja without making it feel like a mind reader.

The details of that system will keep getting tuned. The important part is the constraint. The AI has to live under the same information limits that you do.


Where the Ninja is right now

Hidden Blades is still in active development, and the Ninja is in the testing phase, but the core piece is already behaving the way it is supposed to.

The basics are in:

  • Ninjas move with the same cards as everything else, after your normal move.

  • They hide and reveal at the right times.

  • You can stack hidden Ninjas, you can take them with visible pieces, and you can try to snipe them by guessing.

  • The AI respects hidden information and still plays real games around the possibility that a Ninja might be waiting on the other side of the board.

Most of the work left on this front is about clarity and feel. The UI needs to be very clear about when you actually caught a hidden Ninja and when you did not. Replays need to show Ninja movements from your perspective without spoiling the other side’s secrets. There will also be lots of little edge cases that only show up once more people start trying strange things.

There is a lot more to say about how Ninjas change opening plans, how endgames feel when both sides are afraid there might be a blade in the dark two squares away, and how this interacts with other expansions. That will come in later posts.

For now, the important part is that the Ninja actually exists inside the dojo and that the engine underneath it has learned how to keep a straight face while one piece is doing things the other player is not allowed to see.

Comments

Popular posts from this blog

Mastering the Master’s Path

Quickplay Matchmaking, Friend Challenges, and Reconnects

Welcome to Hidden Path Dojo