jackadamson / onitama

Play Onitama in your browser, compete with friends or lose to a bot
MIT License
78 stars 14 forks source link

Add Light & Shadow Expansion #23

Open onitamasuperfan opened 10 months ago

onitamasuperfan commented 10 months ago

The Light and Shadow expansion adds hidden information and asymmetric forces to Onitama. It adds two new Ninja pawns, a hidden Ninja board, and four Lantern tokens used by a special action to try to reveal opposing Ninja(s) that are hidden. The full rules are available in this pdf.

Adding this expansion to the web app would be a great boon to those interested in playing with it since it has a lower amount of favour amongst perfect information abstract strategy fans that are the general audience for Onitama. It also would eliminate the need to trust your opponent's moves on the hidden board. Personally I look forward to playing this variant against the AI especially.

I think it's important that in addition to making it optional to force either game mode, we also add it to the default random play experience, even if we add a toggle to turn it off. For that I suggest a 5% chance of the random game being either Light or Shadow, and then within that a 70% chance of Shadow (where each player has a Master, two Students and a Ninja) and a 30% chance of Light (where one player has only two Ninjas and the other player has a standard Master and four Students).

As for the Ninja pawn icon itself, I think a traditional Chess Knight would be most appropriate. Unlike the physical game there is no reason the Ninja's colour should not match the colour of the player who controls it.

Also, in the case of currently unimplemented Student/Master promotional cards, we need to either decide how the Ninja should move (since there is no official guidance at this time) or exclude those cards from games where the Ninjas are used for now.

Obviously this is an even more intensive addition than Way of the Wind, but I think they both merit inclusion in the web app. Adding support for these options could be useful for future game additions that may come as well.

jackadamson commented 10 months ago

This is a really interesting expansion and I really love playing it.

There are definitely some roadblocks to implementing it as the initial app design assumed players have perfect information.

Though perhaps might be easiest to implement as single player only, but that would also require changes to the AIs.

I don't suppose you're aware of any classical AI algorithms that work for non-perfect info games?

I feel that monte-carlo and minimax could be retrofitted but would perform abysmally.

onitamasuperfan commented 10 months ago

Personally being able to play even against a poor AI would be a boon since it is difficult to find human opponents for this expansion especially and their hidden Ninja will probably be quite unpredictable.

I do think monte-carlo and minimax have both been applied to games like Poker in the past, so you're probably right that it could be adapted to this.

onitamasuperfan commented 10 months ago

I've been thinking about the hidden information aspect of the Ninja in multiplayer games and I don't think that's the actual blocking issue in the code. We can just add an "isVisible" property to the pawns, and then it's just a matter of putting in the logic to show a Ninja when it's revealed and not show it to the other player when the board is rendered after a move.

This doesn't address how the AI "sees" or tracks where an opposing Ninja might be, but for multiplayer it should be sufficient to hide it from view when it's hidden.

I do see why it might not easily work for local play though without some additional screens. One way we could handle that is via a "pass and play" prompt that blocks the board from view until the next player takes the device, then that player would see their view of the board with their hidden Ninja, and then after their move the prompt would appear again if needed. We could dynamically decide whether to present the prompt based on whether or not there is still information to hide.