-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
removing players from activePlayers #446
Comments
For Proposal 2, we can also use a declarative approach if we want to remove a player from moves: {
discard: {
impl: (G, ctx) => { ... },
removeFromActivePlayers: true,
}
} This would be analogous to having a The imperative way of doing this would be: moves: {
discard: (G, ctx) => {
...
ctx.events.removeFromActivePlayers();
}
} We'll still need the imperative approach to support conditional removal, but the declarative approach is nicer for the simple case (so I'm proposing having both). We already support the long-form move syntax, so it's just a matter of adding an additional boolean option to it. |
I like both Do you know what profiling it was that suggested a multiplayer |
The long-form move syntax just provides the moves as an object instead of a function: // Short Form
moveA: (G, ctx) => { ... }
// Long Form
moveA: {
impl: (G, ctx) => { ... } // the move function
// options that apply to this move
optionA: true,
optionB: true,
...
} |
I used https://clinicjs.org/flame/ to run a profile and produce a flame graph. I also subsequently added It's possible that my implementation was just naive (and caused some deep object nesting that needed to be copied many times). However, if we can implement a solution that doesn't require these counters (which would be the case if we just implement |
I feel like
|
Spawning off a thread from a previous discussion at #442, which is talking about (among other things) the behavior of how players are removed from
activePlayers
.Background
activePlayers
is a map that keeps track of all the players that can make a move on the current turn. This is an evolution of the current conceptactionPlayers
. It also keeps track of what "stage" each active player is in. A "stage" is analogous to a "phase", and basically restricts what moves the player in that stage can make. It can be manipulated using something like this:which does the following things:
activePlayers
.discard
.activePlayers
.This allows implementing cards that allow other players to take an action before reverting back to the current player (the Militia card in Dominion, for example).
Problem
once: true
is too specific.Proposals
Add
moveLimit
to thestages
config. Now each stage can declare how many moves ought to be made before a player is removed fromactivePlayers
. This has the benefit that each stage can implement a differentmoveLimit
. The downside is that it cannot be customized at the call-site. It also has the downside that we have to track the number of moves made by each player, which is additional state that can slow things down.Create a
removeFromActivePlayers
event that can be called from a move. This can be used to remove players after a complex condition is met (rather than merely checking how many moves they have made).The text was updated successfully, but these errors were encountered: