log

Implementation Log: Fanorona

A record of implementing the Malagasy national game 'Fanorona' on the Parlourite engine. Covers the game overview, cultural context, and implementation decisions.

I implemented Fanorona on the Parlourite engine. This is a record of the work, created as the game is added to the public lineup.

About Fanorona

Fanorona is a nationally beloved board game in Madagascar. Lines are drawn on a 5×9 board, with stones placed at intersections. Each player has 22 stones, starting with only the center point empty.

The distinctive feature is the capture mechanism. When moving a stone one step, you capture by “approach” or “withdraw.” Approach captures all opponent stones lined up beyond the destination. Withdraw captures all opponent stones lined up behind the origin. If both are possible, you choose.

As long as captures remain, you can continue with the same stone. However, you cannot return to the same point or move in the same direction twice consecutively. Within these constraints, how far can you extend the chain? Or how do you cut off your opponent’s chain?

The player who loses all stones loses the game. A single turn can transform the board, and the tide can turn dramatically.

A Game from an Island Nation

I have never been to Madagascar. An island floating in the Indian Ocean, east of the African continent. Far from Japan.

I love animals, so Madagascar is one of my dream destinations. Lemurs, chameleons, baobabs. Creatures that evolved uniquely on an island separated from the continent. It sits on my list of places to visit someday.

Fanorona has been played in that Madagascar for centuries. It was a game for royalty and commoners alike. According to tradition, it was even involved in the rise and fall of a 17th-century kingdom—important decisions were supposedly determined by Fanorona matches. Whether true or not, the game clearly held cultural weight.

As island nations, Madagascar and Japan share something in common. Surrounded by sea, unique games are refined. The approach-and-withdraw capture rule follows a lineage different from chess or checkers. Where did it come from? How did it emerge? Its history piques my curiosity.

Implementation Notes

Capture processing was trickier than it appeared.

“Capture all opponent stones lined up along the line” sounds simple. But implementation requires traversing the line and counting opponent stones. In my first version, I wrote the loop incorrectly and only captured the first stone—a discrepancy appeared on the very first move during verification.

I rewrote it to hold a cursor as a flag and traverse the line sequentially. This was a correction based on DSL behavior: let inside while doesn’t modify outer variables. A small detail, but these are where stumbles happen.

Chain constraints were also complex. Cannot return to the same point, cannot continue in the same direction twice. I consolidated these two prohibitions into chain_ok, managing turn history with flags.

Initially, I wrote stone filtering for chains in two places: narrowing from candidates in capture, and checking in chain_ok. Redundant, but I noticed breaking either one still passed tests—mutation probe didn’t turn red. I consolidated the rule into one place and generalized the candidates.

Verification involved visual inspection of 8 games. All games reached conclusion by exhausting stones, with legal moves and winners matching.

Independent Decisions

Even “standard” rules have interpretive variations. This implementation decided as follows.

  • Moving in the same direction twice consecutively during a chain is prohibited
  • The rule limiting captures to once on the first turn (some regions) was not adopted
  • Handicap rules like vela (the loser doesn’t capture in the next game) were not implemented

Reflections

Interest in Madagascar as a place was part of why I chose this game. A board game played for centuries on an island far from Japan. Just knowing it exists makes the world feel a bit larger.

The approach-and-withdraw capture mechanism is distinctive, rarely seen in other games. Dynamism where a single turn loses many stones. Delicacy in reading chain constraints. A game that combines both.

If I ever have the chance to visit Madagascar, I would like to play Fanorona with locals. Seeing lemurs, lining up stones under baobabs. That would be quite a luxurious journey.