|
|
# The Resistance Framework
|
|
|
See the [youtube video](https://youtu.be/9vs4XkW_IQY) giving an overview of how to use the framework and use callbacks.
|
|
|
|
|
|
## Game Stucture
|
|
|
|
|
|
## Game Structure
|
|
|
|
|
|
```mermaid
|
|
|
graph TD;
|
... | ... | @@ -14,8 +14,7 @@ graph TD; |
|
|
Preparation-->Selection;
|
|
|
```
|
|
|
|
|
|
Between each phase, the game checks if any of the following has occoured, if it
|
|
|
has then the game is terminated and the game end callback is triggered:
|
|
|
Between each phase, the game checks if any of the following has occurred, if it has then the game is terminated and the game end callback is triggered:
|
|
|
|
|
|
* 3 wins for either team (causing a win overall)
|
|
|
* 5 missions have been played
|
... | ... | @@ -24,7 +23,7 @@ has then the game is terminated and the game end callback is triggered: |
|
|
### Selection
|
|
|
Pick the mission leader and ask the leader for a team selection.
|
|
|
|
|
|
The mission leader's ```select(players, count)``` method is called. The leader returns a list of player objects that corrispond to the players the leader wishes to send on the mission.
|
|
|
The mission leader's ```select(players, count)``` method is called. The leader returns a list of player objects that correspond to the players the leader wishes to send on the mission.
|
|
|
|
|
|
When the leader has made a selection, the bots will be informed that a team has been selected using the `onTeamSelected(leader, team)` callback.
|
|
|
|
... | ... | @@ -39,33 +38,36 @@ If not, the leadership will pass to the next player in sequence and they will ne |
|
|
If the team fails to reach a majority 5 missions in a row, the game will auto-fail the game, causing a win for the spies.
|
|
|
|
|
|
### Mission Phase
|
|
|
During the mission phase, if the team member is a resitance member, they will automaticlly get marked at successes. If the player is a spy, then the will be asked if they wish to fail the mission. This is done using the `sabotage()` callback. The agent should return true if they wish to fail the mission, or false if they don't want to fail it.
|
|
|
During the mission phase, if the team member is a resistance member, they will automatically get marked at successes. If the player is a spy, then the will be asked if they wish to fail the mission. This is done using the `sabotage()` callback. The agent should return true if they wish to fail the mission, or false if they don't want to fail it.
|
|
|
|
|
|
If **any** player sabotages the mission, the mission will fail. This is consistant with the five player varient of the game.
|
|
|
If **any** player sabotages the mission, the mission will fail. This is consistent with the five player variant of the game.
|
|
|
|
|
|
Once the mission has been resolved (success or fail) the agents will receive the ```onMissionComplete(sabotaged)``` - the value passed in represents the number of stabotages which have been resolved.
|
|
|
Once the mission has been resolved (success or fail) the agents will receive the ```onMissionComplete(sabotaged)``` - the value passed in represents the number of sabotages which have been resolved.
|
|
|
|
|
|
#### End of the Game
|
|
|
If the game hits the maximum number of missions, or the game becomes unwinnable for one of the teams, the game is terminated.
|
|
|
The ```onGameComplete(wins, spies)``` callback is triggered.
|
|
|
|
|
|
### Announcement Phase
|
|
|
The players announce any suspictions they have about other players. This is a mapping of player to level of suspission.
|
|
|
The players announce any suspicions they have about other players. This is a mapping of player to level of suspicions.
|
|
|
|
|
|
Once these have been accounted for, they are shared with other players using ```onAnnouncement(source, suspissions)```. These can be used to share information between players.
|
|
|
Once these have been accounted for, they are shared with other players using ```onAnnouncement(source, suspicions)```. These can be used to share information between players.
|
|
|
|
|
|
After the announcements are complete, the next leader is selected and the selection for the next mission begins.
|
|
|
|
|
|
### Prepartion Phase
|
|
|
At the end of the game, the players are told who the spies were, the ```onGameRevealed(players, spies)``` this lets the players know at the end of the game who was a spy - which can be used to reveal infomation.
|
|
|
### Preparation Phase
|
|
|
At the end of the game, the players are told who the spies were, the ```onGameRevealed(players, spies)``` this lets the players know at the end of the game who was a spy - which can be used to reveal information.
|
|
|
|
|
|
# Bot API
|
|
|
|
|
|
All the accessible API functions can be seen in [player.py](https://cseegit.essex.ac.uk/ce811/assignment1/-/blob/master/player.py), with comments and description of the arguments and
|
|
|
expected return. All functions are called if implemented by the bot. The following text elaborates on some of those API functions.
|
|
|
|
|
|
## Actions
|
|
|
* select - as a mission leader, select who to send on a mission
|
|
|
* vote - as a player, decide if you want the players to on on the mission
|
|
|
* sabotage - as a spy on the mission, decide if you want to sabotage the mission
|
|
|
* announce - talk to other players about your suspissions
|
|
|
* announce - talk to other players about your suspicions
|
|
|
|
|
|
### Helper Methods
|
|
|
* Say - log/say something in global chat
|
... | ... | @@ -78,12 +80,12 @@ At the end of the game, the players are told who the spies were, the ```onGameRe |
|
|
* onVoteComplete - callback for when the whole team has voted - revealing the votes
|
|
|
* onMissionComplete - callback once the mission has been run - how many sabotages were there?
|
|
|
* onMissionFailed - callback if the voting phase fails, **this happens if 5 votes fail**
|
|
|
* onAnnouncement - callback informing the player of other people's suspissions
|
|
|
* onAnnouncement - callback informing the player of other people's suspicions
|
|
|
* onMessage - callback when a player issues a free form chat message (probably shouldn't use this...)
|
|
|
* onGameComplete - reveal the spies at the end of the game
|
|
|
|
|
|
# Game State
|
|
|
At all points in the game, the players have access to a shared state, ```self.game``` which holds useful infomation about the game state.
|
|
|
At all points in the game, the players have access to a shared state, ```self.game``` which holds useful information about the game state.
|
|
|
|
|
|
* phase - the current phase of the game
|
|
|
* turn - the mission number (1 to 5)
|
... | ... | @@ -97,4 +99,16 @@ At all points in the game, the players have access to a shared state, ```self.ga |
|
|
* sabotages - the number of sabotages
|
|
|
|
|
|
## Cheating
|
|
|
You must not attempt to modify this object - if you attempt to modify the game state you will receive a mark of 0 for attempting to cheat. |
|
|
\ No newline at end of file |
|
|
You must not attempt to modify the game state object - if you do so then you will receive a mark of 0 for attempting to cheat.
|
|
|
|
|
|
# In order to create your own bot:
|
|
|
|
|
|
1. Implement a new class that extends from the class *bot*. You only modify content in this class, do not alter the other classes of the framework.
|
|
|
|
|
|
2. Implement (i.e., overwrite from the parent class) these three necessary functions: select, vote and sabotage. All of the other functions and callbacks are optional to use.
|
|
|
|
|
|
3. Implement as many of the optional methods as you want for extra information.
|
|
|
|
|
|
# Video Tutorial
|
|
|
|
|
|
See the [youtube video](https://youtu.be/9vs4XkW_IQY) giving an overview of how to use the framework and use callbacks. |
|
|
\ No newline at end of file |