SlideShare a Scribd company logo
1 of 95
How to create the AI Wolf agent?
AIWolf project
Agenda
• Preparations for creating the agent
– Create the java project
– Configure the build path
– Javadoc location
– Run the game using your agent
• Create the seer agent
PREPARE FOR CREATING THE AGENT
Download the platform(1)
1. Visit http://aiwolf.org/en
2. Click “Developer”
Download the platform(2)
1. Visit http://aiwolf.org/en
2. Click “Developer”
3. Click “AIWolf Platform”
Download the platform(3)
1. Visit http://aiwolf.org/en
2. Click “Developer”
3. Click “AIWolf Platform”
4. Download aiwolf-ver0.4.5 and java doc
5. Unzip aiwolf-ver0.4.5
What is a platform(1)
AIWolf-ver0.4.5 Folder
• 5 JAR file
the following files are used to create the agent
aiwolf-client.jar , aiwolf-common.jar
• 4 shell script files(*.sh)
• 4 batch files(*.bat)
• 2 files for AutoStarter
(AutoStarter.ini, SampleSetting.cfg)
What is a platform(2)
Summary of the following files
aiwolf-client.jar , aiwolf-common.jar
• aiwolf-client.jar
Used for creating the agent
• aiwolf-common.jar
Used for creating the agent and running the game
What is a platform(3)
Other files are used for running the game
• StartServer
starting the game server using GUI
• StartClient
starting clients which access the game server
• StartGUIClient
starting clients which access the game server using GUI
• AutoStarter
running the game by following these files
(AutoStarter.ini and SampleSetting.cfg)
Create the java project(1)
File>New>Java Project
Create the java project (2)
Choose a name for
the project
(Example : DemoAgent)
Then press “Finish”
Create the folder(1)
Right-click > New>Folder
Create the folder (2)
Fill in a suitable name
(Example : lib)
Press “Finish”
Configure the Build Path(1)
1. Copy aiwolf-client.jar, aiwolf-common.jar,
aiwolf-docs-ver0.4.6.zip to lib
Configure the Build Path(2)
Right-click > Build Path > Configure Build Path
Configure the Build Path(3)
Libraries>Add JARs..
Configure the Build Path(4)
Select 3 jar file from the lib folder
Press “OK”
Javadoc location(1)
aiwolf-client.jar>Javadoc>Edit..
Javadoc location(2)
Javadoc in archive>External file>Archive path
>Browse
Javadoc location (3)
Browse>lib > aiwolf-docs-ver0.4.5.zip
Fill in [docs] on Path within archive
Press “Validate”
Javadoc location (4)
• If you verify the location then [OK]
• Set Javadoc for aiwolf-common.jar in the
same way
CREATE THE AGENT
Run the game with your agent
1. Creating a class using
AbstractRoleAssignPlayer(inheritance)
2. Preparing for running the game
3. Creating Agents for each role
4. Set agents on RoleAssignPlayer
Run the game with your agent
1. Creating a class using
AbstractRoleAssignPlayer(inheritance)
2. Preparing for running the game
3. Creating Agents for each role
4. Set agents on RoleAssignPlayer
First prepare the environment
Create Package(1)
DemoAgent>Right-click > New> Package
Create Package(2)
Fill in a suitable name
(Example:demo@aiwolf.org→org.aiwolf.demo)
For “Name”
Press “Finish”
Create Class(1)
org.aiwolf.demo>Right-click > New> Class
Create Class(2)
Superclass>Browse
> AbstractRoleAssignPlayer - org.aiwolf.sample.lib
And [OK]
Create Class(3)
You have already
created an agent as
strong as sample
player
Fill in a suitable name
(Example: DemoRoleAssignPlayer)
for “Name”
Press “Finish”
What is a DemoRoleAssignPlayer
DemoRole
AssignPlayer
Medium
class
Seer
class
Werewolf
class
Villager
class
How to make a JAR file(1)
DemoAgent>Right-click >Export
How to make a JAR file(2)
JAVA>JAR file>Next
How to make a JAR file(3)
JAR file>Browse > desktop/AIWolf-ver0.4.6
Fill in a suitable name
(Example: DemoAgent.jar)
on “JAR file”
Press “Finish”
Configurations
Connect some clients(AIWolf agent) to a server
and run
Edit .ini
• Open AutoStarter.ini
• Delete (WEREWOLF,SEER) from Sample1 and Sample2
• Comment out Sample5(insert #)
• Add the following line on the bottom
• [suitable name (Example:Demo)],[package name].[class
name]
Run with 4 sample players
and your own agent
lib=./
log=./log/
port=10000
game=10
view=true
setting=./SampleSetting.cfg
#agent=5
Sample1,org.aiwolf.sample.player.SampleRoleAssignPlayer
Sample2,org.aiwolf.sample.player.SampleRoleAssignPlayer
Sample3,org.aiwolf.sample.player.SampleRoleAssignPlayer
Sample4,org.aiwolf.sample.player.SampleRoleAssignPlayer
#Sample5,org.aiwolf.sample.player.SampleRoleAssignPlayer
Demo,org.aiwolf.demo.DemoRoleAssignPlayer
Run the game
• Windows : Run AutoStarter.bat
• Mac/Linux : Run AutoStarter.sh
Your agent is
playing the
game
Run the game with your agent
1. Creating a class using
AbstractRoleAssignPlayer(inheritance)
2. Preparing for running the game
3. Creating Agents for each role
4. Set agents on RoleAssignPlayer
Let’s make seer agent
Create a Class for Seer
• Create a new class in the same way as
RoleAssignPlayer
• Name : DemoSeer
• Superclass :
AbstractSeer
- org.aiwolf.sample.lib
Change RoleAssignPlayer
• Add the following constructor to
RoleAssignPlayer
– When your agent is assigned to seer, agent uses
DemoSeer
– When your agent is assigned to other roles, agent
uses Sample player
public DemoRoleAssignPlayer(){
setSeerPlayer(new DemoSeer());
}
Run the game
• After you export JAR file and run AutoStarter,
confirm whether the program is running or
not.
• DemoSeer has no method so does nothing
What kind of methods
should you implement?
Player Interface
Methods defined in Player interface
• Server calls these methods each time
• Update is called just before each method except for
initialize
 initialize(GameInfo, GameSetting)
 update(GameInfo)  getName()
 dayStart()  talk()
 whisper()  vote()
 attack()  divine()
 guard()  finish()
Stream of the Game
initialize
Night
divine(only seer)
whisper(only werewolf)
guard(only guardian)
attack(only werewolf)
Day time talk
vote
finish
Every
day
dayStart
End?
First Day?
whisper( only werewolf )
divine(only seer)
YES
NO
NO
YES
At night, you can use the result of votting
Return of each method
• void
• String
• Agent(method to select target agent)
initialize(GameInfo, GameSetting)
update(GameInfo)
dayStart()
finish()
vote() attack() divine() guard()
getName() talk() whisper()
Create the Seer Agent
• AbstractSeer
– The following methods are not inherited:
attack(), guard(), whisper(). They are useless for
seer.
• Implement other methods
Let’s create the seer agent
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
Field
• /** me */
• Agent me;
• /** newest GameInfo */
• GameInfo currentGameInfo;
• /** list of divining results which have never reported */
• Deque<Judge> myDivinationQueue = new LinkedList<>();
• /** list of human */
• List<Agent> whiteList = new ArrayList<>();
• /** list of werewolf */
• List<Agent> blackList = new ArrayList<>();
• /** list of gray */
• List<Agent> grayList;
• /** whether you have done coming-out or not */
• boolean isCO = false;
• /** GameInfo.talkList */
• int talkListHead; // initialize at dayStart()
• /** Coming-out information */
• Map<Agent, Role> comingoutMap = new HashMap<>(); // initialize at initialize
Utility method
/** whether agent is alive or not */
boolean isAlive(Agent agent) {
return currentGameInfo.getAliveAgentList().contains(agent);
}
/** return form list at random */
<T> T randomSelect(List<T> list) {
if (list.isEmpty()) {
return null;
} else {
return list.get((int) (Math.random() * list.size()));
}
}
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
getName(), update()
public String getName() {
return "DemoSeer";
}
public void update(GameInfo gameInfo) {
//updating currentGameInfo
currentGameInfo = gameInfo;
}
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
initialize()
public void initialize(GameInfo gameInfo,
GameSetting gameSetting) {
// initializing field
me = gameInfo.getAgent();
grayList = new ArrayList<>(gameInfo.getAgentList());
grayList.remove(me);
whiteList.clear();
blackList.clear();
myDivinationQueue.clear();
}
Initialize field
Avoiding remaining old game information
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
dayStart()
public void dayStart() {
// getting result of divining
Judge divination = currentGameInfo.getDivineResult();
if (divination != null) {
myDivinationQueue.offer(divination);
Agent target = divination.getTarget();
Species result = divination.getResult();
// updating gray・white・black list
grayList.remove(target);
if (result == Species.HUMAN) {
whiteList.add(target);
} else {
blackList.add(target);
}
}
//initializing
talkListHead=0;
}
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
vote()
1. Vote from alive werewolf at random
2. If there is no alive werewolf, vote from alive
gray agents at random
vote()
public Agent vote() {
// list of candidates
List<Agent> candidates = new ArrayList<>();
// adding alive werewolf to candidates
for (Agent agent : blackList) {
if (isAlive(agent)) {
candidates.add(agent);
}
}
// If there is no agent in candidates, adding alive gray player to candidates
if (candidates.isEmpty()) {
for (Agent agent : grayList) {
if (isAlive(agent)) {
candidates.add(agent);
}
}
}
続く
vote()
// If there is no agent in candidates, return null
//(voting at random from alive agent except for me)
if (candidates.isEmpty()) {
return null;
}
// voting at random from candidates
return randomSelect(candidates);
}
vote() (whole code)
public Agent vote() {
// list of candidates
List<Agent> candidates = new ArrayList<>();
// adding alive werewolf to candidates
for (Agent agent : blackList) {
if (isAlive(agent)) {
candidates.add(agent);
}
}
// If there is no agent in candidates, adding alive gray player to candidates
if (candidates.isEmpty()) {
for (Agent agent : grayList) {
if (isAlive(agent)) {
candidates.add(agent);
}
}
}
// If there is no agent in candidates, return null
//(voting at random from alive agent except for me)
if (candidates.isEmpty()) {
return null;
}
// voting at random from candidates
return randomSelect(candidates);
}
Go to divine()
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
divine()
Select from alive agents which have never been
divined except for itself at random
divine()
public Agent divine() {
// list of candidates
List<Agent> candidates = new ArrayList<>();
// adding alive gray player to candidates
for (Agent agent : grayList) {
if (isAlive(agent)) {
candidates.add(agent);
}
}
// don't divine if there is no agent in candidates
if (candidates.isEmpty()) {
return null;
}
// divining at random from candidates
return randomSelect(candidates);
}
Go to talk
Implementation
1. Define fields and utility methods
2. Implement [getName], [update]
3. Implement [initialize]
4. Implement [dayStart]
5. Implement [vote]:voting depends on the result
of divining
6. Implement [divine]:divining randomly
7. Implement [talk]:coming-out,talking about the
result of divining
talk, whisper
• Server calls talk() method by turn
Turn 1 ~ 20
talk, whisper
• 2 class used for talk
 org.aiwolf.client.lib.Content Classs
 org.aiwolf.client.lib.ContentBuilder sub Class
• Making utterance by following process
 ContentBuilder builder = ContentBuilder(for each subject);
 Content content = new Content(builder);
 String text = content.getText();
ContentBuilder Class(1)
1. EstimateContentBuilder(target, role): estimating target’s role to be
certain role
2. ComingoutContentBuilder (target, role) : coming out target’s role as
certain role
3. DivinationContentBuilder(target) : divining target
4. DivinedResultContentBuilder(target, result) : divining target and
reporting result
5. IdentContentBuilder(target, result) : identifiying target and reporting
result
6. GuardCandidateContentBuilder(target) : guarding target
7. GuardedAgentContentBuilder(target) : guarded
8. targetVoteContentBuilder(target) : voting for target
9. AttackContentBuilder(target) : attacking
10. targetAgreeContentBuilder(talkType, talkDay, talkID) : agreeing on
utterance(talkDay,talkType,talkID)
ContentBuilder Class(2)
11. DisagreeContentBuilder(talkType, talkDay, talkID) : disagreeing on
utterance(talkDay,talkType,talkID)
12. RequestContentBuilder(agent, content) : asking agent talk content
13. OverContentBuilder() : there is no content
OVER = new Content(new OverContentBuilder());
14. SkipContentBuilder() : seeing how things go
SKIP = new Content(new SkipContentBuilder());
Example
//getting divine result
Judge judge = getLatestDayGameInfo().getDivineResult();
//making content
ContentBuilder builder = new
DivinedResultContentBuilder(judge.getTarget(), judge.getResult();
String talk = new Content(builder).getText();
Making content reporting divine result
talk()
1. Coming out if you find werewolf
2. After coming out, reporting divine result
talk()
public String talk() {
// coming out if you find werewolf
if (!isCO) {
if (!myDivinationQueue.isEmpty() &&
myDivinationQueue.peekLast().getResult() == Species.WEREWOLF) {
isCO = true;
ContentBuilder builder = new ComingoutContentBuilder(me, Role.SEER);
return new Content(builder).getText();
}
}
To be continued
talk()
// After coming out, reporting divine result
else {
if (!myDivinationQueue.isEmpty()) {
Judge divination = myDivinationQueue.poll();
//making content
ContentBuilder builder = new DivinedResultContentBuilder(divination.getTarget(),
divination.getResult());
return new Content(builder).getText();
}
}
return Content.OVER.getText();
}
talk() (whole code)
public String talk() {
// coming out if you find werewolf
if (!isCO) {
if (!myDivinationQueue.isEmpty() &&
myDivinationQueue.peekLast().getResult() == Species.WEREWOLF) {
isCO = true;
ContentBuilder builder = new ComingoutContentBuilder(me, Role.SEER);
return new Content(builder).getText();
}
}
// After coming out, reporting divine result
else {
if (!myDivinationQueue.isEmpty()) {
Judge divination = myDivinationQueue.poll();
//making content
ContentBuilder builder = new DivinedResultContentBuilder(divination.getTarget(),
divination.getResult());
return new Content(builder).getText();
}
}
return Content.OVER.getText();
}
Let’s read other’s content
Read the Content
• List of content is got by GameInfo.getTalkList() as
List<Talk> Type
• Talk class method
– getAgent():getting Agent which is talking
– getText():getting Content (String)
– getDay():getting day(int)
– getIdx():getting order (int) of the day
– getTurn():getting turn (int) of the day
Read the Content
String from Talk.getText() are based on AIWolf protocol
Example:“DIVINED Agent[04] HUMAN”
In order to parse the String,get the String to constructor of
Content class
//In order to parse the String, get the String to constructor of Content class
Content content = new Content(talk.getText());
Content Class
return
value
Method name Description
String getText() Return content as it is
Operator getOperator() Return operator of content.If the content is simple sentence, then return null
Agent getSubject() Return subject
Topic getTopic() Return topic (COMINGOUT, DIVINED…)
Agent getTarget() Return target (Example:”DIVINED Agent[01] HUMAN” → Agent[01])
Role getRole() Return role(Example:”COMINGOUT Agent[02] SEER” → SEER)
Species getResult() Return result of divine or identificatiion(Example:”IDENTIFIED Agent[03]
WEREWOLF” → WEREWOLF)
TalkType getTalkType() If Topic is AGREE/DISAGREE,return type(TALK/WHISPER)
int getTalkDay() If Topic is AGREE/DISAGREE,return day(TALK/WHISPER)
int getTalkID() If Topic is AGREE/DISAGREE,return id(TALK/WHISPER)
List<Content> getContentList() If the content is a complex sentence, then return list of passage
To read content,
Correcting update() (1)
public void update(GameInfo gameInfo) {
// updating currentGameInfo
currentGameInfo = gameInfo;
// From GameInfo.talkList, getting CO・divine report・identifying report
for (int i = talkListHead; i < currentGameInfo.getTalkList().size(); i++) {
Talk talk = currentGameInfo.getTalkList().get(i);
Agent talker = talk.getAgent();
if (talker == me) {
continue;
}
Content content = new Content(talk.getText()); // parse content
To be continued
To read content,
Correcting update() (2)
switch (content.getTopic()) {
case COMINGOUT: // processing Coming-out
// reading Coming-out
comingoutMap.put(talker, content.getRole());
break;
case DIVINED: // processing divine result
break;
case IDENTIFIED: // processing identifying result
break;
default:
break;
}
}
talkListHead = currentGameInfo.getTalkList().size();
}
update()(whole code)
public void update(GameInfo gameInfo) {
// updating currentGameInfo
currentGameInfo = gameInfo;
// From GameInfo.talkList, getting CO・divine report・identifying report
for (int i = talkListHead; i < currentGameInfo.getTalkList().size(); i++) {
Talk talk = currentGameInfo.getTalkList().get(i);
Agent talker = talk.getAgent();
if (talker == me) {
continue;
}
Content content = new Content(talk.getText()); // parse content
switch (content.getTopic()) {
case COMINGOUT: // processing Coming-out
// reading Coming-out
break;
case DIVINED: // processing divine result
break;
case IDENTIFIED: // processing identifying result
break;
default:
break;
}
}
talkListHead = currentGameInfo.getTalkList().size();
}
Let’s read CO information
Read coming-out Information
public void update(GameInfo gameInfo) {
// updating currentGameInfo
currentGameInfo = gameInfo;
// From GameInfo.talkList, getting CO・divine report・identifying report
for (int i = talkListHead; i < currentGameInfo.getTalkList().size(); i++) {
Talk talk = currentGameInfo.getTalkList().get(i);
Agent talker = talk.getAgent();
if (talker == me) {
continue;
}
Content content = new Content(talk.getText()); // parse content
switch (content.getTopic()) {
case COMINGOUT: // processing Coming-out
// reading Coming-out
comingoutMap.put(talker, content.getRole());
break;
case DIVINED: // processing divine result
break;
case IDENTIFIED: // processing identifying result
break;
default:
break;
}
}
talkListHead = currentGameInfo.getTalkList().size();
}
Read coming-out Information
• Example : You can find out the fake seer agent
– What will you do if you have not come out yet?
– Whether the fake seer is werewolf or possessed?
– ・・・
Let’s think about these!!
supplement
Player method
• initialize(GameInfo)
– Called once in a beginning
of the game
– Getting GameInfo from
server
• update(GameInfo)
– Called before every action
– Getting GameInfo from
server
• dayStart()
– Called once in a beginning
of the day
• finish()
– Called once in an end of
the game
Player method
• vote()
– Selecting target to vote
• attack()
– Selecting target to attack
– Only for werewolf
• divine()
– Selecting target to divine
– Only for seer
• guard()
– Selecting target to guard
– Only for guardian
Methods called once at the end of the day
Return Agent
Player method
• talk()
– Talking for everyone
– For everyone
• whisper()
– Talking for werewolf
– Only for werewolf
Method for utterance
Return String
GameInfo
Return value Method name description
int getDay() Return day
Role getRole() Return one’s role
List<Agent> getExistingRoles() Return list of role existing in the game
Agent getAgent() Return oneself(Agent type)
List<Agent> getAgentList() Return list of all player
Species getMediumResult() Return identifying result(only for medium)
Species getDivineResult() Return divine result(only for seer)
Agent getGuardedAgent() Return target guarded yesterday(only for guardian)
List<Agent> getLastDeadAgentList() Return list of agents dead yesterday(including fox)
Agent getExecutedAgent() Return agent executed yesterday
Agent getLatestExecutedAgent() Return agent executed today(null before decision)
Agent getAttackedAgent() Return target attacked regardless of success of attack(only for
werewolf)
List<Vote> getVoteList() Return list of voting yesterday
List<Vote> getLatestVoteList() Return list of former voting if voting once more
List<Vote> getAttackVoteList() Return list of attacking(only for werewolf)
List<Vote> getLatestAttackVoteList() Return list of former attack voting if voting once more (only for
werewolf)
List<Talk> getTalkList() Return list of talking
List<Talk> getWhisperList() Return list of whisper(only for werewolf)
List<Agent> getAliveAgentList() Return list of agents alive
Map<Agent, Status> getStatusMap() Return life or death of each player
Map<Agent, Role> getRoleMap()
Return role of each player. only role you can see.(if you are villager,
you can see only you. If you are werewolf, you can know other
werewolfs )you can get every role after end of the game
Run the game using GUI
Run the game using GUI
• Server Starter
– Windows : Double-click StartServer.bat
– Mac/Linux : Double-click StartSerber.sh
Configure server
• Num of players = 5
• Click [Connect]
Connect clients(1/3)
• Client Starter
– Windows : Start StartGuiClient.bat
– Mac/Linux : Start StartGuiClient.sh
Connect clients(2/3)
• Copy Jar and aiwolf-client.jar to JarFiles
Connect clients (3/3)
• Select JAR,player class
• Select Connect Agent
• You can also request by using Role
Run the game
• Your own agent v.s. SampleRoleAssignPlayer
• Server Starter > Click [Start Game]
5 Agent connected
(ServerStarter)
Result
• You can see the result on right window
Example : (Villager) won

More Related Content

Similar to AIWolf programming guide

Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
Susan Gold
 
[JAM 1.2] Design & Multitasking (Andrew Solovey)
[JAM 1.2] Design & Multitasking (Andrew Solovey)[JAM 1.2] Design & Multitasking (Andrew Solovey)
[JAM 1.2] Design & Multitasking (Andrew Solovey)
Evgeny Kaziak
 

Similar to AIWolf programming guide (20)

Aiwolf seminar20180630
Aiwolf seminar20180630Aiwolf seminar20180630
Aiwolf seminar20180630
 
Rapid prototyping with ScriptableObjects
Rapid prototyping with ScriptableObjectsRapid prototyping with ScriptableObjects
Rapid prototyping with ScriptableObjects
 
libGDX: Scene2D
libGDX: Scene2DlibGDX: Scene2D
libGDX: Scene2D
 
How to make an artificial intelligence based werewolf agent in C# using Visua...
How to make an artificial intelligence based werewolf agent in C# using Visua...How to make an artificial intelligence based werewolf agent in C# using Visua...
How to make an artificial intelligence based werewolf agent in C# using Visua...
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
IntroToEngineDevelopment.pdf
IntroToEngineDevelopment.pdfIntroToEngineDevelopment.pdf
IntroToEngineDevelopment.pdf
 
The Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation PlatformsThe Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation Platforms
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
Java & Script ─ 清羽
Java & Script ─ 清羽Java & Script ─ 清羽
Java & Script ─ 清羽
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
[JAM 1.2] Design & Multitasking (Andrew Solovey)
[JAM 1.2] Design & Multitasking (Andrew Solovey)[JAM 1.2] Design & Multitasking (Andrew Solovey)
[JAM 1.2] Design & Multitasking (Andrew Solovey)
 
Анатолій Ландишев - “Незв’язний код у Unity” GameCC 2017
Анатолій Ландишев - “Незв’язний код у Unity” GameCC 2017Анатолій Ландишев - “Незв’язний код у Unity” GameCC 2017
Анатолій Ландишев - “Незв’язний код у Unity” GameCC 2017
 
AIWolfPy v0.4.9
AIWolfPy v0.4.9AIWolfPy v0.4.9
AIWolfPy v0.4.9
 
Unity3D Programming
Unity3D ProgrammingUnity3D Programming
Unity3D Programming
 
Phaser presentation
Phaser presentationPhaser presentation
Phaser presentation
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Flutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by StepFlutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by Step
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 

Recently uploaded

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 

AIWolf programming guide

  • 1. How to create the AI Wolf agent? AIWolf project
  • 2. Agenda • Preparations for creating the agent – Create the java project – Configure the build path – Javadoc location – Run the game using your agent • Create the seer agent
  • 4. Download the platform(1) 1. Visit http://aiwolf.org/en 2. Click “Developer”
  • 5. Download the platform(2) 1. Visit http://aiwolf.org/en 2. Click “Developer” 3. Click “AIWolf Platform”
  • 6. Download the platform(3) 1. Visit http://aiwolf.org/en 2. Click “Developer” 3. Click “AIWolf Platform” 4. Download aiwolf-ver0.4.5 and java doc 5. Unzip aiwolf-ver0.4.5
  • 7. What is a platform(1) AIWolf-ver0.4.5 Folder • 5 JAR file the following files are used to create the agent aiwolf-client.jar , aiwolf-common.jar • 4 shell script files(*.sh) • 4 batch files(*.bat) • 2 files for AutoStarter (AutoStarter.ini, SampleSetting.cfg)
  • 8. What is a platform(2) Summary of the following files aiwolf-client.jar , aiwolf-common.jar • aiwolf-client.jar Used for creating the agent • aiwolf-common.jar Used for creating the agent and running the game
  • 9. What is a platform(3) Other files are used for running the game • StartServer starting the game server using GUI • StartClient starting clients which access the game server • StartGUIClient starting clients which access the game server using GUI • AutoStarter running the game by following these files (AutoStarter.ini and SampleSetting.cfg)
  • 10. Create the java project(1) File>New>Java Project
  • 11. Create the java project (2) Choose a name for the project (Example : DemoAgent) Then press “Finish”
  • 13. Create the folder (2) Fill in a suitable name (Example : lib) Press “Finish”
  • 14. Configure the Build Path(1) 1. Copy aiwolf-client.jar, aiwolf-common.jar, aiwolf-docs-ver0.4.6.zip to lib
  • 15. Configure the Build Path(2) Right-click > Build Path > Configure Build Path
  • 16. Configure the Build Path(3) Libraries>Add JARs..
  • 17. Configure the Build Path(4) Select 3 jar file from the lib folder Press “OK”
  • 19. Javadoc location(2) Javadoc in archive>External file>Archive path >Browse
  • 20. Javadoc location (3) Browse>lib > aiwolf-docs-ver0.4.5.zip Fill in [docs] on Path within archive Press “Validate”
  • 21. Javadoc location (4) • If you verify the location then [OK] • Set Javadoc for aiwolf-common.jar in the same way
  • 23. Run the game with your agent 1. Creating a class using AbstractRoleAssignPlayer(inheritance) 2. Preparing for running the game 3. Creating Agents for each role 4. Set agents on RoleAssignPlayer
  • 24. Run the game with your agent 1. Creating a class using AbstractRoleAssignPlayer(inheritance) 2. Preparing for running the game 3. Creating Agents for each role 4. Set agents on RoleAssignPlayer First prepare the environment
  • 26. Create Package(2) Fill in a suitable name (Example:demo@aiwolf.org→org.aiwolf.demo) For “Name” Press “Finish”
  • 29. Create Class(3) You have already created an agent as strong as sample player Fill in a suitable name (Example: DemoRoleAssignPlayer) for “Name” Press “Finish”
  • 30. What is a DemoRoleAssignPlayer DemoRole AssignPlayer Medium class Seer class Werewolf class Villager class
  • 31. How to make a JAR file(1) DemoAgent>Right-click >Export
  • 32. How to make a JAR file(2) JAVA>JAR file>Next
  • 33. How to make a JAR file(3) JAR file>Browse > desktop/AIWolf-ver0.4.6 Fill in a suitable name (Example: DemoAgent.jar) on “JAR file” Press “Finish”
  • 34. Configurations Connect some clients(AIWolf agent) to a server and run
  • 35. Edit .ini • Open AutoStarter.ini • Delete (WEREWOLF,SEER) from Sample1 and Sample2 • Comment out Sample5(insert #) • Add the following line on the bottom • [suitable name (Example:Demo)],[package name].[class name] Run with 4 sample players and your own agent lib=./ log=./log/ port=10000 game=10 view=true setting=./SampleSetting.cfg #agent=5 Sample1,org.aiwolf.sample.player.SampleRoleAssignPlayer Sample2,org.aiwolf.sample.player.SampleRoleAssignPlayer Sample3,org.aiwolf.sample.player.SampleRoleAssignPlayer Sample4,org.aiwolf.sample.player.SampleRoleAssignPlayer #Sample5,org.aiwolf.sample.player.SampleRoleAssignPlayer Demo,org.aiwolf.demo.DemoRoleAssignPlayer
  • 36. Run the game • Windows : Run AutoStarter.bat • Mac/Linux : Run AutoStarter.sh Your agent is playing the game
  • 37. Run the game with your agent 1. Creating a class using AbstractRoleAssignPlayer(inheritance) 2. Preparing for running the game 3. Creating Agents for each role 4. Set agents on RoleAssignPlayer Let’s make seer agent
  • 38. Create a Class for Seer • Create a new class in the same way as RoleAssignPlayer • Name : DemoSeer • Superclass : AbstractSeer - org.aiwolf.sample.lib
  • 39. Change RoleAssignPlayer • Add the following constructor to RoleAssignPlayer – When your agent is assigned to seer, agent uses DemoSeer – When your agent is assigned to other roles, agent uses Sample player public DemoRoleAssignPlayer(){ setSeerPlayer(new DemoSeer()); }
  • 40. Run the game • After you export JAR file and run AutoStarter, confirm whether the program is running or not. • DemoSeer has no method so does nothing What kind of methods should you implement?
  • 41. Player Interface Methods defined in Player interface • Server calls these methods each time • Update is called just before each method except for initialize  initialize(GameInfo, GameSetting)  update(GameInfo)  getName()  dayStart()  talk()  whisper()  vote()  attack()  divine()  guard()  finish()
  • 42. Stream of the Game initialize Night divine(only seer) whisper(only werewolf) guard(only guardian) attack(only werewolf) Day time talk vote finish Every day dayStart End? First Day? whisper( only werewolf ) divine(only seer) YES NO NO YES At night, you can use the result of votting
  • 43. Return of each method • void • String • Agent(method to select target agent) initialize(GameInfo, GameSetting) update(GameInfo) dayStart() finish() vote() attack() divine() guard() getName() talk() whisper()
  • 44. Create the Seer Agent • AbstractSeer – The following methods are not inherited: attack(), guard(), whisper(). They are useless for seer. • Implement other methods
  • 45. Let’s create the seer agent
  • 46. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 47. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 48. Field • /** me */ • Agent me; • /** newest GameInfo */ • GameInfo currentGameInfo; • /** list of divining results which have never reported */ • Deque<Judge> myDivinationQueue = new LinkedList<>(); • /** list of human */ • List<Agent> whiteList = new ArrayList<>(); • /** list of werewolf */ • List<Agent> blackList = new ArrayList<>(); • /** list of gray */ • List<Agent> grayList; • /** whether you have done coming-out or not */ • boolean isCO = false; • /** GameInfo.talkList */ • int talkListHead; // initialize at dayStart() • /** Coming-out information */ • Map<Agent, Role> comingoutMap = new HashMap<>(); // initialize at initialize
  • 49. Utility method /** whether agent is alive or not */ boolean isAlive(Agent agent) { return currentGameInfo.getAliveAgentList().contains(agent); } /** return form list at random */ <T> T randomSelect(List<T> list) { if (list.isEmpty()) { return null; } else { return list.get((int) (Math.random() * list.size())); } }
  • 50. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 51. getName(), update() public String getName() { return "DemoSeer"; } public void update(GameInfo gameInfo) { //updating currentGameInfo currentGameInfo = gameInfo; }
  • 52. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 53. initialize() public void initialize(GameInfo gameInfo, GameSetting gameSetting) { // initializing field me = gameInfo.getAgent(); grayList = new ArrayList<>(gameInfo.getAgentList()); grayList.remove(me); whiteList.clear(); blackList.clear(); myDivinationQueue.clear(); } Initialize field Avoiding remaining old game information
  • 54. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 55. dayStart() public void dayStart() { // getting result of divining Judge divination = currentGameInfo.getDivineResult(); if (divination != null) { myDivinationQueue.offer(divination); Agent target = divination.getTarget(); Species result = divination.getResult(); // updating gray・white・black list grayList.remove(target); if (result == Species.HUMAN) { whiteList.add(target); } else { blackList.add(target); } } //initializing talkListHead=0; }
  • 56. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 57. vote() 1. Vote from alive werewolf at random 2. If there is no alive werewolf, vote from alive gray agents at random
  • 58. vote() public Agent vote() { // list of candidates List<Agent> candidates = new ArrayList<>(); // adding alive werewolf to candidates for (Agent agent : blackList) { if (isAlive(agent)) { candidates.add(agent); } } // If there is no agent in candidates, adding alive gray player to candidates if (candidates.isEmpty()) { for (Agent agent : grayList) { if (isAlive(agent)) { candidates.add(agent); } } } 続く
  • 59. vote() // If there is no agent in candidates, return null //(voting at random from alive agent except for me) if (candidates.isEmpty()) { return null; } // voting at random from candidates return randomSelect(candidates); }
  • 60. vote() (whole code) public Agent vote() { // list of candidates List<Agent> candidates = new ArrayList<>(); // adding alive werewolf to candidates for (Agent agent : blackList) { if (isAlive(agent)) { candidates.add(agent); } } // If there is no agent in candidates, adding alive gray player to candidates if (candidates.isEmpty()) { for (Agent agent : grayList) { if (isAlive(agent)) { candidates.add(agent); } } } // If there is no agent in candidates, return null //(voting at random from alive agent except for me) if (candidates.isEmpty()) { return null; } // voting at random from candidates return randomSelect(candidates); } Go to divine()
  • 61. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 62. divine() Select from alive agents which have never been divined except for itself at random
  • 63. divine() public Agent divine() { // list of candidates List<Agent> candidates = new ArrayList<>(); // adding alive gray player to candidates for (Agent agent : grayList) { if (isAlive(agent)) { candidates.add(agent); } } // don't divine if there is no agent in candidates if (candidates.isEmpty()) { return null; } // divining at random from candidates return randomSelect(candidates); } Go to talk
  • 64. Implementation 1. Define fields and utility methods 2. Implement [getName], [update] 3. Implement [initialize] 4. Implement [dayStart] 5. Implement [vote]:voting depends on the result of divining 6. Implement [divine]:divining randomly 7. Implement [talk]:coming-out,talking about the result of divining
  • 65. talk, whisper • Server calls talk() method by turn Turn 1 ~ 20
  • 66. talk, whisper • 2 class used for talk  org.aiwolf.client.lib.Content Classs  org.aiwolf.client.lib.ContentBuilder sub Class • Making utterance by following process  ContentBuilder builder = ContentBuilder(for each subject);  Content content = new Content(builder);  String text = content.getText();
  • 67. ContentBuilder Class(1) 1. EstimateContentBuilder(target, role): estimating target’s role to be certain role 2. ComingoutContentBuilder (target, role) : coming out target’s role as certain role 3. DivinationContentBuilder(target) : divining target 4. DivinedResultContentBuilder(target, result) : divining target and reporting result 5. IdentContentBuilder(target, result) : identifiying target and reporting result 6. GuardCandidateContentBuilder(target) : guarding target 7. GuardedAgentContentBuilder(target) : guarded 8. targetVoteContentBuilder(target) : voting for target 9. AttackContentBuilder(target) : attacking 10. targetAgreeContentBuilder(talkType, talkDay, talkID) : agreeing on utterance(talkDay,talkType,talkID)
  • 68. ContentBuilder Class(2) 11. DisagreeContentBuilder(talkType, talkDay, talkID) : disagreeing on utterance(talkDay,talkType,talkID) 12. RequestContentBuilder(agent, content) : asking agent talk content 13. OverContentBuilder() : there is no content OVER = new Content(new OverContentBuilder()); 14. SkipContentBuilder() : seeing how things go SKIP = new Content(new SkipContentBuilder());
  • 69. Example //getting divine result Judge judge = getLatestDayGameInfo().getDivineResult(); //making content ContentBuilder builder = new DivinedResultContentBuilder(judge.getTarget(), judge.getResult(); String talk = new Content(builder).getText(); Making content reporting divine result
  • 70. talk() 1. Coming out if you find werewolf 2. After coming out, reporting divine result
  • 71. talk() public String talk() { // coming out if you find werewolf if (!isCO) { if (!myDivinationQueue.isEmpty() && myDivinationQueue.peekLast().getResult() == Species.WEREWOLF) { isCO = true; ContentBuilder builder = new ComingoutContentBuilder(me, Role.SEER); return new Content(builder).getText(); } } To be continued
  • 72. talk() // After coming out, reporting divine result else { if (!myDivinationQueue.isEmpty()) { Judge divination = myDivinationQueue.poll(); //making content ContentBuilder builder = new DivinedResultContentBuilder(divination.getTarget(), divination.getResult()); return new Content(builder).getText(); } } return Content.OVER.getText(); }
  • 73. talk() (whole code) public String talk() { // coming out if you find werewolf if (!isCO) { if (!myDivinationQueue.isEmpty() && myDivinationQueue.peekLast().getResult() == Species.WEREWOLF) { isCO = true; ContentBuilder builder = new ComingoutContentBuilder(me, Role.SEER); return new Content(builder).getText(); } } // After coming out, reporting divine result else { if (!myDivinationQueue.isEmpty()) { Judge divination = myDivinationQueue.poll(); //making content ContentBuilder builder = new DivinedResultContentBuilder(divination.getTarget(), divination.getResult()); return new Content(builder).getText(); } } return Content.OVER.getText(); } Let’s read other’s content
  • 74. Read the Content • List of content is got by GameInfo.getTalkList() as List<Talk> Type • Talk class method – getAgent():getting Agent which is talking – getText():getting Content (String) – getDay():getting day(int) – getIdx():getting order (int) of the day – getTurn():getting turn (int) of the day
  • 75. Read the Content String from Talk.getText() are based on AIWolf protocol Example:“DIVINED Agent[04] HUMAN” In order to parse the String,get the String to constructor of Content class //In order to parse the String, get the String to constructor of Content class Content content = new Content(talk.getText());
  • 76. Content Class return value Method name Description String getText() Return content as it is Operator getOperator() Return operator of content.If the content is simple sentence, then return null Agent getSubject() Return subject Topic getTopic() Return topic (COMINGOUT, DIVINED…) Agent getTarget() Return target (Example:”DIVINED Agent[01] HUMAN” → Agent[01]) Role getRole() Return role(Example:”COMINGOUT Agent[02] SEER” → SEER) Species getResult() Return result of divine or identificatiion(Example:”IDENTIFIED Agent[03] WEREWOLF” → WEREWOLF) TalkType getTalkType() If Topic is AGREE/DISAGREE,return type(TALK/WHISPER) int getTalkDay() If Topic is AGREE/DISAGREE,return day(TALK/WHISPER) int getTalkID() If Topic is AGREE/DISAGREE,return id(TALK/WHISPER) List<Content> getContentList() If the content is a complex sentence, then return list of passage
  • 77. To read content, Correcting update() (1) public void update(GameInfo gameInfo) { // updating currentGameInfo currentGameInfo = gameInfo; // From GameInfo.talkList, getting CO・divine report・identifying report for (int i = talkListHead; i < currentGameInfo.getTalkList().size(); i++) { Talk talk = currentGameInfo.getTalkList().get(i); Agent talker = talk.getAgent(); if (talker == me) { continue; } Content content = new Content(talk.getText()); // parse content To be continued
  • 78. To read content, Correcting update() (2) switch (content.getTopic()) { case COMINGOUT: // processing Coming-out // reading Coming-out comingoutMap.put(talker, content.getRole()); break; case DIVINED: // processing divine result break; case IDENTIFIED: // processing identifying result break; default: break; } } talkListHead = currentGameInfo.getTalkList().size(); }
  • 79. update()(whole code) public void update(GameInfo gameInfo) { // updating currentGameInfo currentGameInfo = gameInfo; // From GameInfo.talkList, getting CO・divine report・identifying report for (int i = talkListHead; i < currentGameInfo.getTalkList().size(); i++) { Talk talk = currentGameInfo.getTalkList().get(i); Agent talker = talk.getAgent(); if (talker == me) { continue; } Content content = new Content(talk.getText()); // parse content switch (content.getTopic()) { case COMINGOUT: // processing Coming-out // reading Coming-out break; case DIVINED: // processing divine result break; case IDENTIFIED: // processing identifying result break; default: break; } } talkListHead = currentGameInfo.getTalkList().size(); } Let’s read CO information
  • 80. Read coming-out Information public void update(GameInfo gameInfo) { // updating currentGameInfo currentGameInfo = gameInfo; // From GameInfo.talkList, getting CO・divine report・identifying report for (int i = talkListHead; i < currentGameInfo.getTalkList().size(); i++) { Talk talk = currentGameInfo.getTalkList().get(i); Agent talker = talk.getAgent(); if (talker == me) { continue; } Content content = new Content(talk.getText()); // parse content switch (content.getTopic()) { case COMINGOUT: // processing Coming-out // reading Coming-out comingoutMap.put(talker, content.getRole()); break; case DIVINED: // processing divine result break; case IDENTIFIED: // processing identifying result break; default: break; } } talkListHead = currentGameInfo.getTalkList().size(); }
  • 81. Read coming-out Information • Example : You can find out the fake seer agent – What will you do if you have not come out yet? – Whether the fake seer is werewolf or possessed? – ・・・ Let’s think about these!!
  • 83. Player method • initialize(GameInfo) – Called once in a beginning of the game – Getting GameInfo from server • update(GameInfo) – Called before every action – Getting GameInfo from server • dayStart() – Called once in a beginning of the day • finish() – Called once in an end of the game
  • 84. Player method • vote() – Selecting target to vote • attack() – Selecting target to attack – Only for werewolf • divine() – Selecting target to divine – Only for seer • guard() – Selecting target to guard – Only for guardian Methods called once at the end of the day Return Agent
  • 85. Player method • talk() – Talking for everyone – For everyone • whisper() – Talking for werewolf – Only for werewolf Method for utterance Return String
  • 86. GameInfo Return value Method name description int getDay() Return day Role getRole() Return one’s role List<Agent> getExistingRoles() Return list of role existing in the game Agent getAgent() Return oneself(Agent type) List<Agent> getAgentList() Return list of all player Species getMediumResult() Return identifying result(only for medium) Species getDivineResult() Return divine result(only for seer) Agent getGuardedAgent() Return target guarded yesterday(only for guardian) List<Agent> getLastDeadAgentList() Return list of agents dead yesterday(including fox) Agent getExecutedAgent() Return agent executed yesterday Agent getLatestExecutedAgent() Return agent executed today(null before decision) Agent getAttackedAgent() Return target attacked regardless of success of attack(only for werewolf) List<Vote> getVoteList() Return list of voting yesterday List<Vote> getLatestVoteList() Return list of former voting if voting once more List<Vote> getAttackVoteList() Return list of attacking(only for werewolf) List<Vote> getLatestAttackVoteList() Return list of former attack voting if voting once more (only for werewolf) List<Talk> getTalkList() Return list of talking List<Talk> getWhisperList() Return list of whisper(only for werewolf) List<Agent> getAliveAgentList() Return list of agents alive Map<Agent, Status> getStatusMap() Return life or death of each player Map<Agent, Role> getRoleMap() Return role of each player. only role you can see.(if you are villager, you can see only you. If you are werewolf, you can know other werewolfs )you can get every role after end of the game
  • 87.
  • 88. Run the game using GUI
  • 89. Run the game using GUI • Server Starter – Windows : Double-click StartServer.bat – Mac/Linux : Double-click StartSerber.sh
  • 90. Configure server • Num of players = 5 • Click [Connect]
  • 91. Connect clients(1/3) • Client Starter – Windows : Start StartGuiClient.bat – Mac/Linux : Start StartGuiClient.sh
  • 92. Connect clients(2/3) • Copy Jar and aiwolf-client.jar to JarFiles
  • 93. Connect clients (3/3) • Select JAR,player class • Select Connect Agent • You can also request by using Role
  • 94. Run the game • Your own agent v.s. SampleRoleAssignPlayer • Server Starter > Click [Start Game] 5 Agent connected (ServerStarter)
  • 95. Result • You can see the result on right window Example : (Villager) won

Editor's Notes

  1. 占い師