Skip to content

Commit 320eb8d

Browse files
committed
Rincala: Try again to insert previous final state as first frame
1 parent 623c566 commit 320eb8d

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/games/rincala.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,16 @@ export class RincalaGame extends GameBase {
172172
if (this.gameover) { return []; }
173173

174174
const moves: string[] = [];
175-
this.recurseMoves(moves, null);
175+
176+
// for first move of the game, just do gatherMoves and leave it at that
177+
if (this.stack.length === 1) {
178+
moves.push(...this.gatherMoves().map(({move}) => move));
179+
}
180+
// otherwise, recurse
181+
else {
182+
this.recurseMoves(moves, null);
183+
}
184+
176185
return [...moves].sort((a,b) => {
177186
if (a.length === b.length) {
178187
return a.localeCompare(b);
@@ -406,7 +415,10 @@ export class RincalaGame extends GameBase {
406415
}
407416

408417
this.results = [];
409-
this.frames = [];
418+
this.frames = [{
419+
board: deepclone(this.board),
420+
hands: deepclone(this.hands),
421+
}];
410422
const capped: Colour[] = [];
411423

412424
const steps = m.split(",").filter(Boolean);
@@ -448,7 +460,7 @@ export class RincalaGame extends GameBase {
448460

449461
// remove the last frame to save space because the current state is the same
450462
this.frames.pop();
451-
if (this.results.length - this.frames.length !== 1) {
463+
if (this.results.length !== this.frames.length) {
452464
throw new Error("There's a mismatch in the length of the results array and the frames array. Something is wrong.");
453465
}
454466
this.lastmove = m;
@@ -533,7 +545,7 @@ export class RincalaGame extends GameBase {
533545
}
534546
let results: APMoveResult[] = [];
535547
if (this.results.length > 0) {
536-
const group = this.results[i];
548+
const group = this.results[i -1];
537549
if (group !== undefined && group.type !== "_group") {
538550
throw new Error("The only results that should be present are _group results!");
539551
} else if (group !== undefined) {

0 commit comments

Comments
 (0)