New game: Nick Bentley's Product#317
Conversation
Perlkonig
left a comment
There was a problem hiding this comment.
See comments for a couple changes and questions. Thanks again for doing this work!
src/games/product.ts
Outdated
| { uid: "size-6", group: "board" }, | ||
| { uid: "size-7", group: "board" }, | ||
| ], | ||
| flags: ["scores", "no-moves"] |
There was a problem hiding this comment.
Please always add the experimental flag to new games.
src/games/product.ts
Outdated
| currplayer: playerid; | ||
| board: Map<string, playerid>; | ||
| lastmove?: string; | ||
| scores: [number, number]; |
There was a problem hiding this comment.
Since calculating the scores is trivial, there's no need to continually track the score move after move. It just inflates the game state. Just rely on getPlayerScore() (the backend uses this) and getPlayersScores() (what the front end uses, for reasons).
src/games/product.ts
Outdated
| public stack!: Array<IMoveState>; | ||
| public results: Array<APMoveResult> = []; | ||
| public boardSize = 5; | ||
| public scores: [number, number] = [0, 0]; |
src/games/product.ts
Outdated
| _timestamp: new Date(), | ||
| currplayer: 1, | ||
| board: new Map(), | ||
| scores: [0, 0], |
| return otherCoordinates; | ||
| } | ||
|
|
||
| public handleClick(move: string, row: number, col: number, piece?: string): IClickResult { |
There was a problem hiding this comment.
I'm not quite clear on how players choose what colour stone to place. How do they place a piece belonging to the other player? You can see games like Manalath and Wunchunk for existing examples.
There was a problem hiding this comment.
Oh, but this way is much more user-friendly comparing to Wunchuck. All pieces of the current turn can cycle between friend -> enemy -> empty hex -> friend -> ...
There was a problem hiding this comment.
I don't understand. I haven't tried to run it locally yet. You're saying they click multiple times on the same cell and the piece toggles between them? If so, we've done that in the past and got some push back (I don't remember the details now). I'm willing to try something, it just wasn't immediately clear to me how the code was working.
There was a problem hiding this comment.
When a player clicks two hexes, it will be something like 1h4,1h5. If he clicks h2 again, the program will remake the move as 1h4,2h5, and another click on h2 will remake the move as 1h4 (a partial move, in this case). This happens in method processMoves.
It is much more pleasant that continuing going to the outside pieces in Wunchuck to play opponent pieces.
There was a problem hiding this comment.
Very well. I will test this locally when we merge and see how it goes. What I like about the Wunchunk approach is that it is very explicit. It's hard to be confused. But I'll wait until I see it in action.
There was a problem hiding this comment.
Thanks. It is almost like clicking on a current stone to make the hex empty again. Just an extra step in the cycle :-)
| currentMove = move.slice(1); | ||
| const [, y] = this.graph.algebraic2coords(move.slice(1)); | ||
| // `algebraic2coords` does not check if the cell is on the board fully. | ||
| if (y < 0) { throw new Error("Invalid cell."); } |
There was a problem hiding this comment.
I guess this works. The graph does give you a list of valid cells, so you can do a simple if (!this.graph.listCells().includes(cell)). Whatever works.
There was a problem hiding this comment.
Your alternative is much clearer, but I wrote this
if (! this.graph.listCells().includes(currentMove)) {
throw new Error("Invalid cell.");
}
and it gave me a strange compiler error: Argument of type 'string' is not assignable to parameter of type 'string & string[]. But, anyway, it's not that relevant.
src/games/product.ts
Outdated
| currplayer: this.currplayer, | ||
| lastmove: this.lastmove, | ||
| board: new Map(this.board), | ||
| scores: [...this.scores] |
| } | ||
| return status; | ||
| } | ||
|
|
There was a problem hiding this comment.
When valid moves can have different forms/orders, it is usually necessary to add a sameMove() function. You can see Streetcar Suburb as an example. Because you already have a normaliseMove() function, it's as simple as the following:
public sameMove(move1: string, move2: string): boolean {
return this.normaliseMove(move1) === this.normaliseMove(move2);
}This is needed because of how exploration works.
No description provided.