jkomoros / boardgame

An in-progress framework in golang to easily build boardgame Progressive Web Apps
Apache License 2.0
31 stars 4 forks source link

Fix the hacky "Moves with no phase are omitted from MoveProgressionMatching" behavior #646

Closed jkomoros closed 6 years ago

jkomoros commented 6 years ago

It's documented in tutorial, and it's necessary for things like ShuffleDiscardToDraw that are always legal.

But the behavior should probably be something more akin to "Filter out any moves that are explicitly enumerated as being legal in this phase but have no moveProgression, which includes moves that have no explicitly legal phase when PhaseEnum is a tree".

Noticed while fixing #627.

jkomoros commented 6 years ago

The fix for this will likely interact with #640, because creating the list of move names to elide is expensive and only really needs to be done once, but where to cache it is non-obvious.

jkomoros commented 6 years ago

It might just literally be "filter out any moves that don't have a moveProgression set". Because moves can only be registered once, which means that if they don't have a moveprogression then they could have applied. And then we don't have to worry about other moves because they couldn't have applied int his phase anyway if they weren't legal in this phase or one of its parents.

Also I think the alwaysLegalMovetypes might be incorrect; it checkes that the given base move has legalPhases of len 0, but I think it should be move.LegalPhases at line 475

jkomoros commented 6 years ago

Note that before doing this will need to save a lot more goldens for various games to ensure I don't break them