forked from ehauckdo/AIWoof
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrandom-silent.py
109 lines (86 loc) · 2.97 KB
/
random-silent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division
# Sample random python-based agent for AIWolf
# Based on https://github.com/k-harada/AIWolfPy
# Developed for aiwolf 0.4.12 (2018/06/16)
# Author: ehauckdo
import aiwolfpy
import aiwolfpy.contentbuilder as cb
##printing of nested dicts and pandas
import json
from tabulate import tabulate
import time
import random
import optparse
import sys
from utility import *
class SampleAgent(object):
def __init__(self, agent_name):
self.myname = agent_name
self.sleeptime = 0.1
def getName(self):
return self.myname
def initialize(self, base_info, diff_data, game_setting):
self.base_info = base_info
self.game_setting = game_setting
#printGameSetting(game_setting)
def update(self, base_info, diff_data, request):
self.base_info = base_info
#print(getTimeStamp()+" inside Update")
#printBaseInfo(base_info)
#printDiffData(diff_data)
def dayStart(self):
#print(" inside dayStart")
return None
def talk(self):
#print(getTimeStamp()+" inside Talk")
selected = randomPlayerId(self.base_info)
#print("Selected ID for talk: "+str(selected))
return cb.vote(selected)
def whisper(self):
#print(getTimeStamp()+" inside Whisper")
selected = randomPlayerId(self.base_info)
#print("Selected ID for whisper: "+str(selected))
return cb.attack(selected)
def vote(self):
#print(getTimeStamp()+" inside Vote")
selected = randomPlayerId(self.base_info)
#print("Selected ID for vote: "+str(selected))
return selected
def attack(self):
#print(getTimeStamp()+" inside Attack")
selected = randomPlayerId(self.base_info)
#print("Selected ID for attack: "+str(selected))
return selected
def divine(self):
#print(getTimeStamp()+" inside Divine")
selected = randomPlayerId(self.base_info)
#print("Selected ID for divine: "+str(selected))
return selected
def guard(self):
#print(getTimeStamp()+" inside Guard")
selected = randomPlayerId(self.base_info)
#print("Selected ID for guard: "+str(selected))
return selected
def finish(self):
#print(getTimeStamp()+" inside Finish")
return None
def parseArgs(args):
usage = "usage: %prog [options]"
parser = optparse.OptionParser(usage=usage)
# need this to ensure -h can be used as an option
parser.set_conflict_handler("resolve")
parser.add_option('-h', action="store", type="string", dest="hostname",
help="IP address of the AIWolf server", default=None)
parser.add_option('-p', action="store", type="int", dest="port",
help="Port to connect in the server", default=None)
parser.add_option('-r', action="store", type="string", dest="port",
help="Role request to the server", default=-1)
(opt, args) = parser.parse_args()
if opt.hostname == None or opt.port == -1:
parser.print_help()
sys.exit()
if __name__ == '__main__':
parseArgs(sys.argv[1:])
aiwolfpy.connect_parse(SampleAgent("FoxuFoxu"))