diff --git a/models/gpt-4o.ts b/models/gpt-4o.ts index 632ae5b..4acda3a 100644 --- a/models/gpt-4o.ts +++ b/models/gpt-4o.ts @@ -24,7 +24,6 @@ export const gpt4o: ModelHandler = async (prompt, map) => { content: JSON.stringify(map), }, ], - temperature: 0.5, response_format: zodResponseFormat(ResponseSchema, "game_map"), }); diff --git a/models/index.ts b/models/index.ts index cdf26c5..9befe30 100644 --- a/models/index.ts +++ b/models/index.ts @@ -10,21 +10,64 @@ export type ModelHandler = ( reasoning: string; }>; -const prompt = `You're given a 2d grid of nums such that. +const prompt = ` + +Your task is to play a game. We will give you a 2d array of characters that represent the game board. Before the game starts, you have these two tasks: + +1. Place two blocks ("B") in locations which maximize the player's survival. +2. Place the player ("P") in a location which maximize the player's survival. + +# Placing Rules +- You can not place blocks in locations already used by zombies or rocks. +- You can not place the player in a location already used by a zombie or rock. +- You can not place a block over the player or another block. +- You must place both blocks and the player before starting the game. + +# Grid Descriptions +The 2d Grid is made up of characters, where each character has a meaning. " " represents an empty space. -"Z" represents a zombie. Zombies move one Manhattan step every turn and aim to reach the player. -"R" represents rocks, which players can shoot over but zombies cannot pass through or break. -"P" represents the player, who cannot move. The player's goal is to shoot and kill zombies before they reach them. +"Z" represents a zombie. +"R" represents rocks which zombies can not pass through and path finding will not allow them to go through. +"P" represents the player, who cannot move. The player's goal is to throw popsickles at zombies before they reach them. "B" represents blocks that can be placed before the round begins to hinder the zombies. -Your goal is to place the player ("P") in a location which maximize the player's survival. -You must place two blocks ("B") in locations which maximize the player's survival. -You can shoot any zombie regardless of where it is on the grid. -Returning a 2d grid with the player and blocks placed in the optimal locations, with the coordinates player ("P") and the blocks ("B"), also provide reasoning for the choices. -Zombies can only move horizontally or vertically, not diagonally. -You can't replace rocks R or zombies Z with blocks. -Players will always shoot at the closest zombie each turn. -If there is no room to place a block, do not place any.`; +# Game Rules +- The game is turn based. +- At the start of the turn, the player (P) throws a popsickle at the closest zombie (using euclidean distance). +- Popsickles deal 1 damage to zombies. +- A zombie is removed from the game when its health reaches 0. +- When all zombies are removed, the player wins. +- If a zombie reaches a player, the player loses. + +# Zombie Rules +- Zombies have 2 health. +- Zombies can only move horizontally or vertically. +- Zombies pathfinding will always be in the order of DOWN, LEFT, RIGHT, UP +- Zombies can't move diagonally. +- Zombies can't move through rocks. +- Zombies can't move through each other. +- Zombies always try to move towards the playing using BFS algorithm. + +# Player Rules +- Players can not move. +- Players throw one lollipops at the closest zombie at the start of each turn. + +# Placement Strategies + +- often it's good to wall off between the zombies and players if possible, this will slow the zombies down. +- You should never put a player directly next to a zombie. +- You should try to put blocks directly next to players + +# Output Format + +- Assume a position on the 2d grid is always represented as [ROW, COL]. +- Your output should be a JSON object with the following format: + +{ + "boxCoordinates": [[ROW, COL], [ROW, COL]], + "playerCoordinates": [ROW, COL] +} +`; export async function runModel( modelId: string, @@ -50,8 +93,8 @@ export async function runModel( } const originalMap = JSON.parse(JSON.stringify(map)); - const [playerRow, playerCol] = result.playerCoordinates; + const [playerRow, playerCol] = result.playerCoordinates; if (originalMap[playerRow][playerCol] !== " ") { throw new Error("Tried to place player in a non-empty space"); }