alexobviously / bishop

A chess logic package for Dart with flexible variant support
https://pub.dev/packages/bishop
Other
19 stars 8 forks source link

Custom state stored in secret board squares #39

Closed alexobviously closed 1 year ago

alexobviously commented 1 year ago

I've been thinking about allowing custom variant-specific state to be built into BishopState for a while now, but I don't really want to extend it with a generic or anything that will make the base use cases more cumbersome. Then I remembered that we have a whole invisible board on the side of the playable board full of empty squares. These squares have to be 'empty' for the off-board detection to work, but that only means the piece part of the square encoding has to be 0. There are 12 whole bits of flags on each square that can be used that currently don't do anything. It means the state is limited to ints but I think that's really the only likely use case anyway?

Technically this is currently already possible. You can use EffectModifySquare to modify one of the invisible squares, and read it in actions. However, it would nice to build some helpers for this, and a fully working example.

I was thinking about Taxi Chess as the example. Basically we just need to store two amounts (players' money balances), check them to validate moves, and adjust them based on moves made.

One issue with doing that is that I probably want to do custom output (variant-specific) first, so that I don't need to build some ugly output hack in the play example for showing cash.

alexobviously commented 1 year ago

Maybe Domination Chess is another interesting example. We don't currently have a move limit game end condition but we could add it.

alexobviously commented 1 year ago

Done in 1.2.0