-
Notifications
You must be signed in to change notification settings - Fork 160
Add werewolf game to kaggle environments #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hannw
wants to merge
275
commits into
master
Choose a base branch
from
werewolf_harness
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+12,650
−44
Open
Changes from all commits
Commits
Show all changes
275 commits
Select commit
Hold shift + click to select a range
c2bff4c
delete obselete observation prep
hannw 02d90ba
temp commit test_engine.py
hannw dabde36
day of actions in event log rendered correctly now
hannw 9617951
separate day and night event logs into two shades in werewolf.js
hannw 426c53c
Event log rendering order completed correctly in werewolf.js
hannw 2d86ca9
add moderator announcement to event log in werewolf.js
hannw 5477cb5
UI related fixes
hannw 00aa200
add llm harness for werewolf
hannw aef05e7
fix the bug that reasoning and voting details were revealed to all pl…
hannw 35e6ab9
moderator announce roles and their abilities
hannw 8d0d1bc
support better end game logging
hannw b320b8e
fix supported llm model names
hannw f1d1856
refactor player schema in config
hannw 58ab350
add try except in llm werewolf harness
hannw e97fea8
add display name to agent schema
hannw e53a7c0
add more supported models to llm harness
hannw 7840fa6
refactor llm harness to have better instruction template to delineate…
hannw f3cd5fc
pass agent_config to llm harness
hannw a0c0050
fixed infinite voting loop problem and elected not eliminated problems
hannw 8df3c4a
resolve infinite voting loop bug
hannw 29e6cd8
add retry logic
hannw c6a334f
minor fixes
hannw 8cf1fb8
add event truncation to LLMWerewolfAgent
hannw 3a8a05f
add pydantic to requirements
hannw fbb8bae
fix prompt template json fences and wording
hannw 464aa5a
record timestamp during history entry creation
hannw d45646a
change default voting scheme to sequential voting
hannw d8b1eb7
simplify visuals in werewolf.js
hannw 413201a
add player capsules in werewolf rendering
hannw 51880b2
fix night action reasoning and actor id rendering
hannw ed49f6e
improve line spacing of moderator and game over messsage
hannw 1eadc42
fix issues in SequentialVoting protocol
hannw 58fae65
refactor action queue to use action specific queue
hannw 7f7d4eb
adjust phase separator style
hannw c812502
add perceived threat level to backend and frontend
hannw 53e9305
improve json schema export for pydantic basemodel
hannw 32ea70f
change the threat level indicator from aura to solid circle
hannw f8f93fa
refactor __run_interpreter to remove duplicated code
hannw cb6bc89
add comments to address debug mode branching
hannw 6bacbeb
Refactoring interpreter() for readability and adding some high level …
chuckcoder 0c92aca
minor new line improvement
hannw 71b7bc4
add checks to ensure all player ids are unique
hannw 26b7049
refactor phase transition to be more robust
hannw 74d23ed
make sure allow doctor self save is configurable
hannw 283bc74
Add actor id capsule to event log updates
hannw b5df7a3
fix sequential voting bug
hannw d4eda12
add voter capsule to day votes
hannw 8b59f89
add timeout display in werewolf.js
hannw 25093b8
adding additional llm models with quota for testing
chuckcoder 0a98644
adding snippet to track token usage
chuckcoder f619daf
fixing bug where single element instead of list is being returned
chuckcoder 150472d
Adding additonal packages that seem to be required from base image
chuckcoder 94dec4c
fixing issue with undefined 2d array for moderator and player roles n…
chuckcoder bf48565
making some options required
chuckcoder 5cb7197
Adding README.md to werwolf with bare bones example
chuckcoder 61c0370
adding branch to werewolf_harness
chuckcoder 910e8db
adding branch to werewolf_harness
chuckcoder 6811836
adding a flat() call as moderator results can be 2d, kind of a hack f…
chuckcoder 525ba8e
adding a flat() call as moderator results can be 2d, kind of a hack f…
chuckcoder 374805f
add werewolf runner scripts for simple testing and experimentation
hannw 3144123
remove print statements and use logger instead
hannw 4923f98
revert the voting index change
hannw 10fc7b2
add TTS to werewolf game replay
hannw a1d0382
Add continual audio to front end
hannw a7466ec
Add voices and association with model
hannw 81c03d6
fix werewolf.js black screen issue reporting "Waiting for game data..."
hannw 3533a93
making the audio speed bar persistent across playbacks
hannw f5929eb
minor fixes for dump_audio.py
hannw 501af44
add announcements to audio event
hannw 0c47ca4
add action announcements to audio event
hannw 33ca64a
add 3d background
hannw 8a99713
add 3d background rendering and portable replay folder
hannw 3c3b7f1
refactor dump_audio.py to be more modularized
hannw 25b3c0d
added wolf and windmill
hannw 897a40f
loaded 8 stickmans and idle animation
hannw ebf6247
adjusted stickman directions and numbers
hannw 51bd942
add nameplate on top of the stickman
hannw 5694a8b
add local image into asset for serving thumbnail
hannw 066aa4d
nameplate text aligned center
hannw b8a40c0
fix z placement of nameplate
hannw 67decf6
add moon to the scene
hannw dd0d495
add file dump
hannw f4ef22d
render audio script
hannw 77968f5
refactor dump_audio.py to enable debug path to play simple audio
hannw 08f1a10
refactor werewolf.js to have hover effect and select event to playback
hannw 372cd02
change text color during audio playback event
hannw d93dc80
refactor base.py instructions
hannw 902b2fb
fix finding audio key issues
hannw cacab28
add gpt-oss model
hannw da5cb2c
add new audio generation instructions and examples
hannw 76d298b
Improve on the audio prompts
hannw 9e8d901
add 3d werewolf script
hannw e176413
add assets
hannw 8302c67
resolve moderator obs bug
hannw e73bf26
use logger for self_play.py
hannw ba17ac8
resolve sequential voting protocol bug
hannw 1f7de7e
refactor dump_audio.py
hannw 40f3a31
add instructions for audio generation in README.md
hannw c7dae78
add instructions for audio generation in README.md
hannw 25c0843
add flask and gym back
hannw a97ca8d
remove redundant files
hannw b5bced0
clean up tests
hannw e3f8ec0
add agent action error code handling, default to game end if there is…
hannw 4ade683
fix out and err context
hannw 97c740e
fix input args of interpreter loop
hannw d5ba30b
improve exemplar formatting
hannw 866e984
Change the debug mode for tests to False for testing prod paths
hannw 7b38284
add game rules
hannw 16c4979
add violent language filter to discussion protocols
hannw 330c2db
enforce violent language filter in action initializer level
hannw f56a2dd
add optional reveal night elimination or day exile role
hannw 9cf377a
Fix bid driven discussion state machine and add turn by turn bidding …
hannw 5127eb4
refactor action queue to a single class and refine bidding driven dis…
hannw 700c4db
add bid data entry and bid result data entry
hannw 4c66922
use deterministic tie breaking mechanisms for UrgencyBidProtocol
hannw b25e89b
add bid_result_public to properties
hannw 79e55ba
add test_turn_by_turn_bidding_discussion
hannw 6beaf79
3d view changes
twmmason 229423d
Improved 3d layout
twmmason 5b383c9
Player list css improvements
twmmason 25ac213
Fix for emojis
twmmason dc3662d
3d scene effects
twmmason 7711de6
Player logo fading
twmmason aa101cc
Adjusted panel margins
twmmason b88642f
fix for flipped players
twmmason f6eb9b7
Day/night transitions
twmmason 0f3f160
Nameplate adjustments
twmmason db496f6
Status panel
twmmason bb4a6d6
fix animation so backward replay restore past state
hannw b037a0d
fix event log so backward replay restore past log state
hannw fc1905c
add moderator announcement back to event log
hannw 37c73bc
fix play bar event loop step alignment
hannw 1c270ed
disable key control of scene
hannw 3987619
add block experiment code for role balanced sampling
hannw f42bef5
add spotlight logic
hannw 9210b54
add more supported models
hannw dd2d8ba
report cost of inference for LLMs
hannw 36b75fb
enable configuring LLMWerewolfAgent and add text mode prompts
hannw 4388b62
add script to measure cost
hannw f6d3117
add bid action to llm harness
hannw a5fc8f2
enable harness bid reasoning config options and add cost tracker
hannw bcb1a26
refactor measure_cost.py to use new cost trackers
hannw d8ec634
fix day addition bug in engine.py
hannw 00270da
fix token trajectory plot
hannw 3bf6326
add agent reset mechanism to solve global agent state carry over acro…
hannw dddddc2
Load usage directly from litellm for cost analysis
hannw b2740ae
fix trajectory loading in measure_cost.py
hannw ec6fe31
add run.py script and refactor run_block.py to use it
hannw b021c61
rearrange config files
hannw db2b2c3
add toggle for reasoning traces
hannw 67c7eb4
Fix pulse and spotlight animation misalignment with actor
hannw 45f1989
add targeting arcs
hannw 49cb4f6
Improved vote target visualizer
hannw 48b939b
Change color of arcs for different actions
hannw 84089cc
Fixed day/night timing and werewolf turns red during night time
hannw 9c943e4
fix day voting arcs
hannw b5cfcf7
add phase divider logic to cleanly segment events
hannw 0252637
separate allEvents and visibleEvents to remove undisplayed events fro…
hannw 59d85db
fix night werewolf red light glitches
hannw 2116ef9
Fix night eliminated werewolf resurrection issues
hannw e75fb35
fix phase indicator on left panel
hannw e355d22
remove redundant code, change event log phase indicator text
hannw cf69712
Resolve event log duplication bug
hannw aba837d
Resolve game end phase indicator to no day count
hannw 3ef5ee6
change thumbnail size on left panel, clean up console logs
hannw 9c5a3db
Add display_name rendering and adjust thumbnail background to be white
hannw c400033
Add optional display name to 3d player nameplate
hannw df0f328
refactor run_block.py to use run.py as subprocess and parallelize the…
hannw 73bfd40
add option to append timestamp to output dir
hannw 5f9e1a3
add option to shuffle player ids
hannw e9ae14d
revise run_block.py instructions
hannw 37f836b
add LogExecutionTime context manager to keep track of task time
hannw eb8d11b
add instructions to configure agents
hannw c0e9a44
fix generate unique role permutations
hannw c6ddb6a
Add register agent method
hannw 801f295
add litellm_models.yaml config to register litellm model for cost pro…
hannw e976597
remove capital P from player logs
hannw 655008f
Fix reveal day and night elimination bug
hannw 6bc289b
Fix reveal text for no reveal situation in visualizer
hannw cf5300a
Update player capsule to show display name (placeholder for model name)
hannw a81ebbc
Handle capsule parsing better
hannw 178eb2a
add doctor and seer night glow
hannw 346de15
add options to choose random first actor for roundrobiin discussion a…
hannw feb44c5
fix sequential voting protocol voter bug and history visibility bug
hannw 9203beb
Minor format improvement to llm harness
hannw 72243c1
Minor format improvement
hannw 4b0bb16
Fix capsule regex for parsing "... <player_name>."
hannw 4623fed
correct threat level text
hannw 36ac40a
use orb as self assessed threat level detector
hannw 26cf831
add sound wave animation to speaker
hannw 51e96b0
change random message.
hannw 573496b
fix role_msg
hannw 5dc4899
add censor words, refactor censor pattern compile to global
hannw 0657867
add llm query logs, fix no cost logging
hannw 5a56b39
add flag to shuffle roles
hannw 3133722
refactor llm harness for better error handling and logging
hannw b7989ef
fix tally exposing player role bug
hannw a5e4428
add global toggle for turning reasoning on/off
hannw d80a0e3
add reveal rule messages in moderator announcement
hannw 256f3e8
refactor action schema for player
hannw a735a15
improve role specification formatting
hannw 5fbc99a
fix schema_for_player return None bug
hannw 291b439
add action to ActionDataMixin
hannw 8a2e6f8
add player first person view on click of player card at left panel
hannw 7c1a100
add reset button for 3d camera position
hannw 49d9cb8
fix query_parse bug, remove observation from action obj
hannw df53ce9
remove observations from actions.py which is causing recursive memory…
hannw c535a34
optimize imports
hannw 85171fc
[critical] fix public view bug resulted from Mixin method resolution …
hannw 226d68b
add missing error prompt
hannw 8d3c682
Refactor history entry access patterns
hannw 7b58189
Add visible history entry type control
hannw 4ae7a4a
fix raw observation key bug
hannw a444989
make actor data observable to the actor by specifying source
hannw 86d39f5
cache schema_for_player for better latency
hannw 1b0433a
refactor raw_observation consumer to use getter and setter
hannw 901c2e7
refactor llm harness to record self action and reasoning
hannw 13d9c35
Introduce StrEnum to be better json serializable and clearer types
hannw 9da18fe
add configs for llm experiment
hannw 9acab3e
add packages to requirements.txt
hannw b049df1
add pairwise zero sum game tournament
hannw 4307ae7
add task shuffling to reduce LLM api load
hannw 531b28f
reuse run_single_game_cli code
hannw fe0a71d
add display name to the right panel player name tag
hannw e805b15
revise self_play.py to run n games from a given config
hannw cb3b8f8
add "random" and "no exile" tie exile options in SimultaneousMajority…
hannw b365e87
Add RoundByRoundBiddingDiscussion
hannw 11fa4b1
refactor _handle_night_await_actions() into smaller methods for reada…
d53c035
Remove check for GOOGLE_APPLICATION_CREDENTIALS as sdk looks for them…
8b5b305
Updating docs to remove internal OCTO project
410604b
Refactor to use event driven architecture for Role extensibility
hannw ad5c048
Refactor protocols to be modules
hannw 20074c3
Improve on player id annotations
hannw f1449ad
standardize variable names from history entry to event
hannw 69d9a33
fix harness phase error
hannw 68f840d
add cost to litellm models
hannw 65e8491
remove general confirmation of action event to player
hannw a633b0c
Fix StrEnum repr
hannw 64462fc
Improve on prompting
hannw 1236b8d
Improve the state machine transition to be explicit in engine.py
hannw f8d7ec2
Add phase category as attribute of DetailedPhase
hannw d744d49
Resolve detailed_phase naming issue
hannw 91ef619
add utility to log git hash
hannw ea3394e
use wait random exponential to avoid "thundering herd" VM crash
hannw 49a0290
Use threadpool instead
hannw 0fd484c
refactor voting to use Ballot
hannw 67f59f4
Refactor Role initialization to use role_params dict
hannw 98792e2
Refactor day/night elimination reveal to use RevealLevel
hannw 7d8c99a
Fix seer team reveal level result blob
hannw 1c435e2
Add option to disallow doctor consecutive saving of same player
hannw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Werewolf: Game Rules | ||
|
||
Welcome to Werewolf, a game of social deduction, team collaboration, deception, and survival. Players are secretly assigned roles on one of two teams: the Village or the Werewolves. | ||
|
||
## Roles | ||
|
||
Each player is assigned one of the following roles: | ||
|
||
### Village Team | ||
|
||
The goal of the Village team is to exile all the werewolves. | ||
|
||
* **Villager:** You have no special abilities other than your power of observation and your voice. Use the discussion phase to identify suspicious behavior and vote to exile suspected werewolves. | ||
* **Seer:** Each night, you may choose one player to investigate. You will learn if that player is a Werewolf or not. Your goal is to share this information strategically to help the village without revealing your identity too soon. | ||
* **Doctor:** Each night, you may choose one player to protect. The player you protect cannot be eliminated by the werewolves that night. | ||
|
||
### Werewolf Team | ||
|
||
* **Werewolf:** Your goal is to eliminate villagers until the number of werewolves equals the number of remaining village members. Each night, you and your fellow werewolves will secretly agree on one player to eliminate. | ||
|
||
## Game Phases | ||
|
||
The game alternates between a Night phase and a Day phase. | ||
|
||
### Night Phase 🐺 | ||
|
||
During the night, all players close their eyes. The moderator will ask players with special roles to wake up and perform their actions in this order: | ||
|
||
1. **Doctor:** Chooses one player to protect. | ||
2. **Seer:** Chooses one player to investigate their alignment. | ||
3. **Werewolves:** Silently vote on one player to eliminate. | ||
|
||
### Day Phase ☀️ | ||
|
||
1. **Announcement:** The moderator announces which player, if any, was eliminated during the night. That player is removed from the game and may not speak or participate further. | ||
2. **Discussion:** The surviving players discuss who they think the werewolves are. | ||
3. **Exile Vote:** Players vote on who to exile from the village. The player who receives the most votes is exiled, removed from the game, and their role is revealed. | ||
|
||
The game continues with another Night phase until a winning condition is met. | ||
|
||
## Customizable Rules | ||
|
||
Before the game begins, the following options must be decided. | ||
|
||
### 1. Doctor's Self-Save | ||
|
||
* **Option A (Self-Save Allowed):** The Doctor is allowed to choose themselves as the target of their protection. | ||
* **Option B (No Self-Save):** The Doctor must choose another player to protect. | ||
|
||
### 2. Discussion Protocol | ||
|
||
* **Option A (Parallel Discussion):** All players may speak simultaneously for a number of rounds. | ||
* **Option B (Round Robin):** Each player speak one after another following a predefined order for a number of rounds. | ||
|
||
### 3. Voting Protocol | ||
The night wolf target election and the day exile election are both configurable. All voting protocols follow a random | ||
tie breaking mechanism, where a random draw is used when there multiple candidates with the same votes. | ||
|
||
* **Option A (Sequential Voting):** Voters cast their votes one after another, where each voter has visibility to all earlier vote. | ||
* **Option B (Parallel Voting):** All voters cast their votes simultaneously. | ||
|
||
## Winning the Game | ||
|
||
A team wins as soon as their winning condition is met. | ||
|
||
* **The Village Team wins** when all werewolves have been successfully exiled. | ||
* **The Werewolf Team wins** when the number of werewolves is equal to the number of remaining Village team members. | ||
|
||
### Rewards | ||
|
||
All members of the winning team will receive **1 reward**. This includes players who were eliminated before the end of the game. | ||
|
||
### Tie Game (Forfeit) | ||
|
||
If any back-end inference fails during the game, the match will immediately end. The game will be declared a **tie**, and no players will receive a reward. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not clear why there have to be two paths for self.debug here, looks like debug path is just removing try/catch and error logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping execution loop in try except catch-all would prevent debugger from functioning, defeating the purpose for debugging mode, which is why we separated the two modes here. I can add a comment to address it.