Skip to content

Commit

Permalink
idk what I did
Browse files Browse the repository at this point in the history
  • Loading branch information
webdevcody committed Nov 5, 2024
1 parent 6e9e325 commit 3816178
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
14 changes: 7 additions & 7 deletions convex/multiplayerGames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { api, internal } from "./_generated/api";
import { internalAction, internalMutation, query } from "./_generated/server";
import { ModelSlug } from "./constants";

const TURN_DELAY = 5000;
const TURN_DELAY = 500;

const boardState = `
Z.Z.Z. . . .B. . . . . . . . ,
Z.Z. . . . .B. . . . . . . . ,
Z. . . . .B. . . . . . . . . ,
. . . . . .B. . . . . . . . ,
. . . . . .B. . . . . . . . ,
. . . . .B. . . . . . . . . ,
. . . .R. . . . .R. . . . . ,
. . . .R. . . . .R. . . . . ,
. . . .R. . . . .R. . . . . ,
. . . . . . . .B. . . . . .Z,
. . . . . . .B. . . . . .Z.Z,
. . . . . . .B. . . . .Z.Z.Z,
. . . . . . . .B. . . . . . ,
. . . . . . .B. . . . . . . ,
. . . . . . .B. . . . . . . ,
`;

export const startMultiplayerGame = internalMutation({
Expand Down
3 changes: 3 additions & 0 deletions models/multiplayer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ export async function runMultiplayerModel(
"STAY",
];

const zombieLocations = ZombieSurvival.getZombieLocations(map);

const userPrompt =
`Grid: ${JSON.stringify(map)}\n\n` +
`Your Player Token: ${playerToken}\n\n` +
`Zombie Locations: ${JSON.stringify(zombieLocations)}\n\n` +
`Valid Move Locations: ${JSON.stringify(validDirections)}`;

let result;
Expand Down
14 changes: 14 additions & 0 deletions simulator/ZombieSurvival.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ export class ZombieSurvival {
return game.getPlayer() === null || !game.getPlayer()?.dead();
}

public static getZombieLocations(map: string[][]): Array<[number, number]> {
return map.flatMap((row, y) =>
row.reduce(
(acc, cell, x) => {
if (cell.startsWith("Z")) {
acc.push([y, x]);
}
return acc;
},
[] as Array<[number, number]>,
),
);
}

public static mapHasToken(map: string[][], token: string): boolean {
return map.flat().includes(token);
}
Expand Down

0 comments on commit 3816178

Please sign in to comment.