Spaces:
Sleeping
Sleeping
bulk 3
Browse files- patches/convex/aiTown/agentOperations.ts +16 -16
- patches/convex/aiTown/gameCycle.ts +12 -6
- patches/convex/aiTown/player.ts +1 -0
- patches/src/App.tsx +36 -31
patches/convex/aiTown/agentOperations.ts
CHANGED
|
@@ -128,21 +128,21 @@ export const agentDoSomething = internalAction({
|
|
| 128 |
return;
|
| 129 |
} else {
|
| 130 |
// TODO: have LLM choose the activity & emoji
|
| 131 |
-
const activity = ACTIVITIES[Math.floor(Math.random() * ACTIVITIES.length)];
|
| 132 |
-
await sleep(Math.random() * 1000);
|
| 133 |
-
await ctx.runMutation(api.aiTown.main.sendInput, {
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
});
|
| 146 |
return;
|
| 147 |
}
|
| 148 |
}
|
|
@@ -177,4 +177,4 @@ function wanderDestination(worldMap: WorldMap) {
|
|
| 177 |
x: 1 + Math.floor(Math.random() * (worldMap.width - 2)),
|
| 178 |
y: 1 + Math.floor(Math.random() * (worldMap.height - 2)),
|
| 179 |
};
|
| 180 |
-
}
|
|
|
|
| 128 |
return;
|
| 129 |
} else {
|
| 130 |
// TODO: have LLM choose the activity & emoji
|
| 131 |
+
// const activity = ACTIVITIES[Math.floor(Math.random() * ACTIVITIES.length)];
|
| 132 |
+
// await sleep(Math.random() * 1000);
|
| 133 |
+
// await ctx.runMutation(api.aiTown.main.sendInput, {
|
| 134 |
+
// worldId: args.worldId,
|
| 135 |
+
// name: 'finishDoSomething',
|
| 136 |
+
// args: {
|
| 137 |
+
// operationId: args.operationId,
|
| 138 |
+
// agentId: agent.id,
|
| 139 |
+
// activity: {
|
| 140 |
+
// description: activity.description,
|
| 141 |
+
// emoji: activity.emoji,
|
| 142 |
+
// until: Date.now() + activity.duration,
|
| 143 |
+
// },
|
| 144 |
+
// },
|
| 145 |
+
// });
|
| 146 |
return;
|
| 147 |
}
|
| 148 |
}
|
|
|
|
| 177 |
x: 1 + Math.floor(Math.random() * (worldMap.width - 2)),
|
| 178 |
y: 1 + Math.floor(Math.random() * (worldMap.height - 2)),
|
| 179 |
};
|
| 180 |
+
}
|
patches/convex/aiTown/gameCycle.ts
CHANGED
|
@@ -115,11 +115,18 @@ const onStateChange = (prevState: CycleState, newState: CycleState, game: Game,
|
|
| 115 |
})
|
| 116 |
};
|
| 117 |
if (prevState === 'PlayerKillVoting') {
|
| 118 |
-
const
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
if (
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
game.world.gameVotes = [];
|
| 125 |
}
|
|
@@ -168,7 +175,6 @@ export class GameCycle {
|
|
| 168 |
|
| 169 |
// Tick method to increment the counter
|
| 170 |
tick(game: Game, tickDuration: number) {
|
| 171 |
-
console.log(process.env.GITHUB_TOKEN)
|
| 172 |
this.currentTime += tickDuration;
|
| 173 |
|
| 174 |
if (this.currentTime >= stateDurations[this.cycleState]) {
|
|
|
|
| 115 |
})
|
| 116 |
};
|
| 117 |
if (prevState === 'PlayerKillVoting') {
|
| 118 |
+
const werewolves = [...game.world.players.values()].filter((were) => {
|
| 119 |
+
game.playerDescriptions.get(were.id)?.type === 'werewolf'
|
| 120 |
+
})
|
| 121 |
+
if (werewolves.length != 0) {
|
| 122 |
+
const mostVotedPlayer = processVotes(game.world.gameVotes, [...game.world.players.values()])[0];
|
| 123 |
+
const playerToKill = game.world.players.get(mostVotedPlayer.playerId);
|
| 124 |
+
console.log(`killing: ${playerToKill?.id}, with ${game.world.gameVotes.length} votes`)
|
| 125 |
+
if (playerToKill) {
|
| 126 |
+
playerToKill.kill(game, now);
|
| 127 |
+
}
|
| 128 |
+
} else {
|
| 129 |
+
console.log('no werewolves, nobody was killed')
|
| 130 |
}
|
| 131 |
game.world.gameVotes = [];
|
| 132 |
}
|
|
|
|
| 175 |
|
| 176 |
// Tick method to increment the counter
|
| 177 |
tick(game: Game, tickDuration: number) {
|
|
|
|
| 178 |
this.currentTime += tickDuration;
|
| 179 |
|
| 180 |
if (this.currentTime >= stateDurations[this.cycleState]) {
|
patches/convex/aiTown/player.ts
CHANGED
|
@@ -282,6 +282,7 @@ export class Player {
|
|
| 282 |
if (agent) {
|
| 283 |
agent.kill(game, now)
|
| 284 |
}
|
|
|
|
| 285 |
}
|
| 286 |
|
| 287 |
serialize(): SerializedPlayer {
|
|
|
|
| 282 |
if (agent) {
|
| 283 |
agent.kill(game, now)
|
| 284 |
}
|
| 285 |
+
|
| 286 |
}
|
| 287 |
|
| 288 |
serialize(): SerializedPlayer {
|
patches/src/App.tsx
CHANGED
|
@@ -31,37 +31,42 @@ export default function Home() {
|
|
| 31 |
ariaHideApp={false}
|
| 32 |
>
|
| 33 |
<div className="font-body">
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
{/*<div className="p-3 absolute top-0 right-0 z-10 text-2xl">
|
| 66 |
<Authenticated>
|
| 67 |
<UserButton afterSignOutUrl="/ai-town" />
|
|
|
|
| 31 |
ariaHideApp={false}
|
| 32 |
>
|
| 33 |
<div className="font-body">
|
| 34 |
+
<h1 className="text-center text-6xl font-bold font-display game-title">Help</h1>
|
| 35 |
+
<p>
|
| 36 |
+
Welcome to Matou Garou. To play, you have to be logged in{' '}
|
| 37 |
+
<i>as player</i>.
|
| 38 |
+
</p>
|
| 39 |
+
<h2 className="text-4xl mt-4">Spectating</h2>
|
| 40 |
+
<p>
|
| 41 |
+
Click and drag to move around the village, and scroll in and out to zoom. You can click on
|
| 42 |
+
an individual character to view its chat history.
|
| 43 |
+
</p>
|
| 44 |
+
<h2 className="text-4xl mt-4">Playing</h2>
|
| 45 |
+
<p>
|
| 46 |
+
If you log in, you can join the game and directly interact with different characters! After
|
| 47 |
+
logging in, click the "Play" button, and your character will appear somewhere in the village with a highlighted circle underneath you.
|
| 48 |
+
</p>
|
| 49 |
+
<p className="text-2xl mt-2">Controls:</p>
|
| 50 |
+
<p className="mt-4">Click to navigate around.</p>
|
| 51 |
+
<p className="mt-4">
|
| 52 |
+
To talk to a character, click on them and then click "Start conversation," which will ask
|
| 53 |
+
them to start walking towards you. Once they're nearby, the conversation will start, and
|
| 54 |
+
you can speak to each other. You can leave at any time by closing the conversation pane
|
| 55 |
+
or moving away. They may propose a conversation to you - you'll see a button to accept
|
| 56 |
+
in the messages panel.
|
| 57 |
+
</p>
|
| 58 |
+
<h2 className="text-4xl mt-4">Rules</h2>
|
| 59 |
+
<p>
|
| 60 |
+
When the game starts, players will be assigned roles randomly (team Villagers and team Matou Garou). The primary objective is
|
| 61 |
+
to vote against another team to kick them out of the game (the game ends once there's no members left of one of the teams).
|
| 62 |
+
The bonus objective is to discover which players are actually powered by an LLM (you can vote at any moment even if your character was kicked out).
|
| 63 |
+
</p>
|
| 64 |
+
<p className="mt-4">
|
| 65 |
+
Matou Garou only supports {MAX_HUMAN_PLAYERS} human players at a time. If you're idle for five
|
| 66 |
+
minutes, you'll be automatically removed from the game.
|
| 67 |
+
</p>
|
| 68 |
+
</div>
|
| 69 |
+
</ReactModal>
|
| 70 |
{/*<div className="p-3 absolute top-0 right-0 z-10 text-2xl">
|
| 71 |
<Authenticated>
|
| 72 |
<UserButton afterSignOutUrl="/ai-town" />
|