#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int compare(int i, int j)
{
if (i < j)
return (-1);
if (i == j)
return (0);
if (i > j)
return (1);
}
int main()
{
int index;
int day;
int turn;
int slash_index;
int to_die;
int num_alive;
int mine_alive;
int turn_to_return;
bool returned;
string line;
vector<int> last_returns;
vector<int> today_returns;
getline(cin, line);
if (line.compare(0, 6, "INDEX ") != 0)
{
cerr << "INVALID INDEX LINE \"" << line << "\"" << endl;
return (-1);
}
index = atoi(line.substr(6).c_str()) - 1;
while (1) // Day loop
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 9, "START_DAY") != 0 || (slash_index = line.find('/')) == string::npos)
{
cerr << "INVALID START_DAY \"" << line << "\"" << endl;
return (-1);
}
day = atoi(line.substr(10, slash_index - 10).c_str());
to_die = atoi(line.substr(slash_index + 1, line.length() - slash_index - 1).c_str());
if (day != 1)
{
if (to_die > num_alive + 1)
{
turn_to_return = 30;
}
else
{
turn_to_return = last_returns[last_returns.size() - to_die - 1]to_die] - 1;
}
}
returned = false;
for (turn = 1; turn <= 30; ++turn)
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 7, "END_DAY") == 0)
{
goto end_day;
}
if (line.compare(0, 10, "START_TURN") != 0)
{
cerr << "INVALID START_TURN \"" << line << "\"" << endl;
}
if (day == 1)
{
switch (compare(turn, 1430))
{
case -1:
cout << "S,S,S,S,S" << endl;
break;
case 0:
cout << "R,R,R,R,R" << endl;
break;
case 1:
cout << "N,N,N,N,N" << endl;
break;
}
}
else
{
if (returned)
{
cout << "N,N,N,N,N" << endl;
}
/*
else if (num_alive - today_returns.size() < to_die)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
*/
else if (turn >= turn_to_return)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
else
{
cout << "S,S,S,S,S" << endl;
}
}
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 8, "END_TURN") != 0)
{
cerr << "INVALID END_TURN \"" << line << "\"" << endl;
}
stringstream ss(line);
string item;
int i = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
int num_to_add = count(item.begin(), item.end(), 'R'); // Add turn to today_returns for each servant that returned
for (int j = 0; j < num_to_add; j++)
{
today_returns.push_back(turn);
}
}
}
}
getline(cin, line);
end_day:
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 7, "END_DAY") != 0)
{
cerr << "INVALID END_DAY \"" << line << "\"" << endl;
return (-1);
}
stringstream ss(line);
string item;
int i = 0;
num_alive = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
num_alive += count(item.begin(), item.end(), 'A');
}
else if (i - 3 == index)
{
mine_alive = count(item.begin(), item.end(), 'A');
}
}
last_returns = today_returns;
today_returns.clear();
}
return (0);
}
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int compare(int i, int j)
{
if (i < j)
return (-1);
if (i == j)
return (0);
if (i > j)
return (1);
}
int main()
{
int index;
int day;
int turn;
int slash_index;
int to_die;
int num_alive;
int mine_alive;
int turn_to_return;
bool returned;
string line;
vector<int> last_returns;
vector<int> today_returns;
getline(cin, line);
if (line.compare(0, 6, "INDEX ") != 0)
{
cerr << "INVALID INDEX LINE \"" << line << "\"" << endl;
return (-1);
}
index = atoi(line.substr(6).c_str()) - 1;
while (1) // Day loop
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 9, "START_DAY") != 0 || (slash_index = line.find('/')) == string::npos)
{
cerr << "INVALID START_DAY \"" << line << "\"" << endl;
return (-1);
}
day = atoi(line.substr(10, slash_index - 10).c_str());
to_die = atoi(line.substr(slash_index + 1, line.length() - slash_index - 1).c_str());
if (day != 1)
{
if (to_die > num_alive + 1)
{
turn_to_return = 30;
}
else
{
turn_to_return = last_returns[last_returns.size() - to_die - 1] - 1;
}
}
returned = false;
for (turn = 1; turn <= 30; ++turn)
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 7, "END_DAY") == 0)
{
goto end_day;
}
if (line.compare(0, 10, "START_TURN") != 0)
{
cerr << "INVALID START_TURN \"" << line << "\"" << endl;
}
if (day == 1)
{
switch (compare(turn, 14))
{
case -1:
cout << "S,S,S,S,S" << endl;
break;
case 0:
cout << "R,R,R,R,R" << endl;
break;
case 1:
cout << "N,N,N,N,N" << endl;
break;
}
}
else
{
if (returned)
{
cout << "N,N,N,N,N" << endl;
}
/*
else if (num_alive - today_returns.size() < to_die)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
*/
else if (turn >= turn_to_return)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
else
{
cout << "S,S,S,S,S" << endl;
}
}
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 8, "END_TURN") != 0)
{
cerr << "INVALID END_TURN \"" << line << "\"" << endl;
}
stringstream ss(line);
string item;
int i = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
int num_to_add = count(item.begin(), item.end(), 'R'); // Add turn to today_returns for each servant that returned
for (int j = 0; j < num_to_add; j++)
{
today_returns.push_back(turn);
}
}
}
}
getline(cin, line);
end_day:
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 7, "END_DAY") != 0)
{
cerr << "INVALID END_DAY \"" << line << "\"" << endl;
return (-1);
}
stringstream ss(line);
string item;
int i = 0;
num_alive = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
num_alive += count(item.begin(), item.end(), 'A');
}
else if (i - 3 == index)
{
mine_alive = count(item.begin(), item.end(), 'A');
}
}
last_returns = today_returns;
today_returns.clear();
}
return (0);
}
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int compare(int i, int j)
{
if (i < j)
return (-1);
if (i == j)
return (0);
if (i > j)
return (1);
}
int main()
{
int index;
int day;
int turn;
int slash_index;
int to_die;
int num_alive;
int mine_alive;
int turn_to_return;
bool returned;
string line;
vector<int> last_returns;
vector<int> today_returns;
getline(cin, line);
if (line.compare(0, 6, "INDEX ") != 0)
{
cerr << "INVALID INDEX LINE \"" << line << "\"" << endl;
return (-1);
}
index = atoi(line.substr(6).c_str()) - 1;
while (1) // Day loop
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 9, "START_DAY") != 0 || (slash_index = line.find('/')) == string::npos)
{
cerr << "INVALID START_DAY \"" << line << "\"" << endl;
return (-1);
}
day = atoi(line.substr(10, slash_index - 10).c_str());
to_die = atoi(line.substr(slash_index + 1, line.length() - slash_index - 1).c_str());
if (day != 1)
{
if (to_die > num_alive)
{
turn_to_return = 30;
}
else
{
turn_to_return = last_returns[last_returns.size() - to_die] - 1;
}
}
returned = false;
for (turn = 1; turn <= 30; ++turn)
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 7, "END_DAY") == 0)
{
goto end_day;
}
if (line.compare(0, 10, "START_TURN") != 0)
{
cerr << "INVALID START_TURN \"" << line << "\"" << endl;
}
if (day == 1)
{
switch (compare(turn, 30))
{
case -1:
cout << "S,S,S,S,S" << endl;
break;
case 0:
cout << "R,R,R,R,R" << endl;
break;
case 1:
cout << "N,N,N,N,N" << endl;
break;
}
}
else
{
if (returned)
{
cout << "N,N,N,N,N" << endl;
}
/*
else if (num_alive - today_returns.size() < to_die)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
*/
else if (turn >= turn_to_return)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
else
{
cout << "S,S,S,S,S" << endl;
}
}
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 8, "END_TURN") != 0)
{
cerr << "INVALID END_TURN \"" << line << "\"" << endl;
}
stringstream ss(line);
string item;
int i = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
int num_to_add = count(item.begin(), item.end(), 'R'); // Add turn to today_returns for each servant that returned
for (int j = 0; j < num_to_add; j++)
{
today_returns.push_back(turn);
}
}
}
}
getline(cin, line);
end_day:
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 7, "END_DAY") != 0)
{
cerr << "INVALID END_DAY \"" << line << "\"" << endl;
return (-1);
}
stringstream ss(line);
string item;
int i = 0;
num_alive = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
num_alive += count(item.begin(), item.end(), 'A');
}
else if (i - 3 == index)
{
mine_alive = count(item.begin(), item.end(), 'A');
}
}
last_returns = today_returns;
today_returns.clear();
}
return (0);
}
Bob - C++
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int compare(int i, int j)
{
if (i < j)
return (-1);
if (i == j)
return (0);
if (i > j)
return (1);
}
int main()
{
int index;
int day;
int turn;
int slash_index;
int to_die;
int num_alive;
int mine_alive;
int turn_to_return;
bool returned;
string line;
vector<int> last_returns;
vector<int> today_returns;
getline(cin, line);
if (line.compare(0, 6, "INDEX ") != 0)
{
cerr << "INVALID INDEX LINE \"" << line << "\"" << endl;
return (-1);
}
index = atoi(line.substr(6).c_str()) - 1;
while (1) // Day loop
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 9, "START_DAY") != 0 || (slash_index = line.find('/')) == string::npos)
{
cerr << "INVALID START_DAY \"" << line << "\"" << endl;
return (-1);
}
day = atoi(line.substr(10, slash_index - 10).c_str());
to_die = atoi(line.substr(slash_index + 1, line.length() - slash_index - 1).c_str());
if (day != 1)
{
if (to_die > num_alive + 1)
{
turn_to_return = 30;
}
else
{
turn_to_return = last_returns[last_returns.size() - to_die - 1] - 1;
}
}
returned = false;
for (turn = 1; turn <= 30; ++turn)
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 7, "END_DAY") == 0)
{
goto end_day;
}
if (line.compare(0, 10, "START_TURN") != 0)
{
cerr << "INVALID START_TURN \"" << line << "\"" << endl;
}
if (day == 1)
{
switch (compare(turn, 14))
{
case -1:
cout << "S,S,S,S,S" << endl;
break;
case 0:
cout << "R,R,R,R,R" << endl;
break;
case 1:
cout << "N,N,N,N,N" << endl;
break;
}
}
else
{
if (returned)
{
cout << "N,N,N,N,N" << endl;
}
/*
else if (num_alive - today_returns.size() < to_die)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
*/
else if (turn >= turn_to_return)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
else
{
cout << "S,S,S,S,S" << endl;
}
}
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 8, "END_TURN") != 0)
{
cerr << "INVALID END_TURN \"" << line << "\"" << endl;
}
stringstream ss(line);
string item;
int i = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
int num_to_add = count(item.begin(), item.end(), 'R'); // Add turn to today_returns for each servant that returned
for (int j = 0; j < num_to_add; j++)
{
today_returns.push_back(turn);
}
}
}
}
getline(cin, line);
end_day:
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 7, "END_DAY") != 0)
{
cerr << "INVALID END_DAY \"" << line << "\"" << endl;
return (-1);
}
stringstream ss(line);
string item;
int i = 0;
num_alive = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
num_alive += count(item.begin(), item.end(), 'A');
}
else if (i - 3 == index)
{
mine_alive = count(item.begin(), item.end(), 'A');
}
}
last_returns = today_returns;
today_returns.clear();
}
return (0);
}
Bob is currently out for repairs.To Compile:
g++ -o Bob.exe Bob.cpp
To Run:
./players/Bob/Bob.exe
Bob
Bob is currently out for repairs.
Bob - C++
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
int compare(int i, int j)
{
if (i < j)
return (-1);
if (i == j)
return (0);
if (i > j)
return (1);
}
int main()
{
int index;
int day;
int turn;
int slash_index;
int to_die;
int num_alive;
int mine_alive;
int turn_to_return;
bool returned;
string line;
vector<int> last_returns;
vector<int> today_returns;
getline(cin, line);
if (line.compare(0, 6, "INDEX ") != 0)
{
cerr << "INVALID INDEX LINE \"" << line << "\"" << endl;
return (-1);
}
index = atoi(line.substr(6).c_str()) - 1;
while (1) // Day loop
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 9, "START_DAY") != 0 || (slash_index = line.find('/')) == string::npos)
{
cerr << "INVALID START_DAY \"" << line << "\"" << endl;
return (-1);
}
day = atoi(line.substr(10, slash_index - 10).c_str());
to_die = atoi(line.substr(slash_index + 1, line.length() - slash_index - 1).c_str());
if (day != 1)
{
if (to_die > num_alive + 1)
{
turn_to_return = 30;
}
else
{
turn_to_return = last_returns[last_returns.size() - to_die - 1] - 1;
}
}
returned = false;
for (turn = 1; turn <= 30; ++turn)
{
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 7, "END_DAY") == 0)
{
goto end_day;
}
if (line.compare(0, 10, "START_TURN") != 0)
{
cerr << "INVALID START_TURN \"" << line << "\"" << endl;
}
if (day == 1)
{
switch (compare(turn, 14))
{
case -1:
cout << "S,S,S,S,S" << endl;
break;
case 0:
cout << "R,R,R,R,R" << endl;
break;
case 1:
cout << "N,N,N,N,N" << endl;
break;
}
}
else
{
if (returned)
{
cout << "N,N,N,N,N" << endl;
}
/*
else if (num_alive - today_returns.size() < to_die)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
*/
else if (turn >= turn_to_return)
{
cout << "R,R,R,R,R" << endl;
returned = true;
}
else
{
cout << "S,S,S,S,S" << endl;
}
}
getline(cin, line);
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
if (line.compare(0, 8, "END_TURN") != 0)
{
cerr << "INVALID END_TURN \"" << line << "\"" << endl;
}
stringstream ss(line);
string item;
int i = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
int num_to_add = count(item.begin(), item.end(), 'R'); // Add turn to today_returns for each servant that returned
for (int j = 0; j < num_to_add; j++)
{
today_returns.push_back(turn);
}
}
}
}
getline(cin, line);
end_day:
if (line.compare(0, 4, "EXIT") == 0)
{
return (0);
}
else if (line.compare(0, 7, "END_DAY") != 0)
{
cerr << "INVALID END_DAY \"" << line << "\"" << endl;
return (-1);
}
stringstream ss(line);
string item;
int i = 0;
num_alive = 0;
while (getline(ss, item, ' '))
{
i++;
if (i > 2 && i - 3 != index)
{
num_alive += count(item.begin(), item.end(), 'A');
}
else if (i - 3 == index)
{
mine_alive = count(item.begin(), item.end(), 'A');
}
}
last_returns = today_returns;
today_returns.clear();
}
return (0);
}
To Compile:
g++ -o Bob.exe Bob.cpp
To Run:
./players/Bob/Bob.exe
Post Undeleted by user31611
Post Deleted by user31611
Bob - Python 3
I haven't been able to test Bob due to issues with the controller, but I'm hoping he'll perform well. His current strategy is to stay alive by remembering when each bot returned last turn, and returning before the nth-to-last bot returns (n being the number of players to die)
from enum import Enum
from random import choice, random
from math import ceil
class ServantState(Enum):
dead = 0,
camp = 1,
searching = 2
states = (ServantState.dead, ServantState.camp, ServantState.searching)
class ServantMove(Enum):
none = 0, # dead or stay in camp
search = 1, # search for treasure
come_back = 2 # return to camp
moves = (ServantMove.none, ServantMove.search, ServantMove.come_back)
class MoveResult(Enum):
returned = 0,
failed_to_return = 1,
searching = 2,
dead = 3,
camp = 4
move_results = (MoveResult.returned, MoveResult.failed_to_return,
MoveResult.searching, MoveResult.dead, MoveResult.camp)
def result_to_state(result):
if result == MoveResult.returned or result == MoveResult.camp:
return ServantState.camp
elif result == MoveResult.failed_to_return or result == MoveResult.dead:
return ServantState.dead
else:
return ServantState.searching
def memory_move(num_to_die, last_return, bots, turn):
flattened = [servant for i, bot in enumerate(last_return)
for j, servant in enumerate(bot)
if i != my_index - 1 and bots[i][j] == ServantState.searching]
if len(flattened) <= num_to_die:
return ServantMove.come_back
if turn >= min(sorted(flattened)[-num_to_die:]) - 1:
return ServantMove.come_back
return ServantMove.search
def process_turn_results(raw_results):
split = raw_results[9:]
split = split[split.index(' ') + 1:].split(' ')
if len(split) == 1:
raise Exception("Invalid END_TURN")
results = []
for bot_results in split:
servant_results = bot_results.split(',')
results.append([move_results["RrSDN".index(char)] for char in servant_results])
return results
def process_day_results(raw_results):
raw_results = raw_results[7:][raw_results.index(' ') + 1:].split(' ')
results = []
for bot_results in raw_results:
servant_results = bot_results.split(',')
results.append([(ServantState.searching, ServantState.dead)["AD".index(char)] for char in servant_results])
return results
buffer = []
def my_read():
read = input()
if read.startswith("EXIT"):
exit(0)
return read
my_index = int(my_read()[6:])
my_servants = [ServantState.camp for _ in range(5)]
day = 1
while True:
start_day_line = my_read()
split_index = start_day_line.index('/')
day_num = int(start_day_line[10:split_index])
num_to_die = int(start_day_line[split_index+1:])
if day == 1:
if num_to_die == 3: # 2, or 3 bots
bots = [[ServantState.searching for _ in range(5)] for _ in range(3)]
else: # num of bots is num_to_die * 4 rounded up to the nearest 5
bots = [[ServantState.searching for _ in range(5)]
for _ in range(int(ceil(num_to_die*4)/5.0))]
last_return = [[14 for _ in range(5)] for _ in range(len(bots))]
my_servants = bots[my_index - 1]
for turn in range(1, 31):
start_turn = my_read() # We keep our own turn number
if start_turn.startswith("END_DAY"):
end_day = start_turn
break
num_alive = sum([(servant == ServantState.searching or
servant == ServantState.camp)
for bot in bots for servant in bot])
mine_alive = sum([(servant == ServantState.searching or
servant == ServantState.camp)
for servant in my_servants])
my_moves = [ServantMove.search for _ in range(5)]
my_move = ",".join(["NSR"[moves.index(memory_move(num_to_die,
last_return,
bots,
turn))]] * 5)
print (my_move)
results = process_turn_results(my_read())
bots = [[result_to_state(servant) for servant in bot] for bot in results]
if len(last_return) != len(bots):
last_return = [[14 for _ in range(5)] for _ in range(len(bots))]
for i, bot in enumerate(results):
for j in range(5):
if bot[j] == MoveResult.returned:
last_return[i][j] = turn
my_servants = bots[my_index - 1]
else:
end_day = my_read()
bots = process_day_results(end_day)
my_servants = bots[my_index - 1]
day += 1
command:currently out for repairs.
python players/Bob/Bob.py
Bob - Python 3
I haven't been able to test Bob due to issues with the controller, but I'm hoping he'll perform well. His current strategy is to stay alive by remembering when each bot returned last turn, and returning before the nth-to-last bot returns (n being the number of players to die)
from enum import Enum
from random import choice, random
from math import ceil
class ServantState(Enum):
dead = 0,
camp = 1,
searching = 2
states = (ServantState.dead, ServantState.camp, ServantState.searching)
class ServantMove(Enum):
none = 0, # dead or stay in camp
search = 1, # search for treasure
come_back = 2 # return to camp
moves = (ServantMove.none, ServantMove.search, ServantMove.come_back)
class MoveResult(Enum):
returned = 0,
failed_to_return = 1,
searching = 2,
dead = 3,
camp = 4
move_results = (MoveResult.returned, MoveResult.failed_to_return,
MoveResult.searching, MoveResult.dead, MoveResult.camp)
def result_to_state(result):
if result == MoveResult.returned or result == MoveResult.camp:
return ServantState.camp
elif result == MoveResult.failed_to_return or result == MoveResult.dead:
return ServantState.dead
else:
return ServantState.searching
def memory_move(num_to_die, last_return, bots, turn):
flattened = [servant for i, bot in enumerate(last_return)
for j, servant in enumerate(bot)
if i != my_index - 1 and bots[i][j] == ServantState.searching]
if len(flattened) <= num_to_die:
return ServantMove.come_back
if turn >= min(sorted(flattened)[-num_to_die:]) - 1:
return ServantMove.come_back
return ServantMove.search
def process_turn_results(raw_results):
split = raw_results[9:]
split = split[split.index(' ') + 1:].split(' ')
if len(split) == 1:
raise Exception("Invalid END_TURN")
results = []
for bot_results in split:
servant_results = bot_results.split(',')
results.append([move_results["RrSDN".index(char)] for char in servant_results])
return results
def process_day_results(raw_results):
raw_results = raw_results[7:][raw_results.index(' ') + 1:].split(' ')
results = []
for bot_results in raw_results:
servant_results = bot_results.split(',')
results.append([(ServantState.searching, ServantState.dead)["AD".index(char)] for char in servant_results])
return results
buffer = []
def my_read():
read = input()
if read.startswith("EXIT"):
exit(0)
return read
my_index = int(my_read()[6:])
my_servants = [ServantState.camp for _ in range(5)]
day = 1
while True:
start_day_line = my_read()
split_index = start_day_line.index('/')
day_num = int(start_day_line[10:split_index])
num_to_die = int(start_day_line[split_index+1:])
if day == 1:
if num_to_die == 3: # 2, or 3 bots
bots = [[ServantState.searching for _ in range(5)] for _ in range(3)]
else: # num of bots is num_to_die * 4 rounded up to the nearest 5
bots = [[ServantState.searching for _ in range(5)]
for _ in range(int(ceil(num_to_die*4)/5.0))]
last_return = [[14 for _ in range(5)] for _ in range(len(bots))]
my_servants = bots[my_index - 1]
for turn in range(1, 31):
start_turn = my_read() # We keep our own turn number
if start_turn.startswith("END_DAY"):
end_day = start_turn
break
num_alive = sum([(servant == ServantState.searching or
servant == ServantState.camp)
for bot in bots for servant in bot])
mine_alive = sum([(servant == ServantState.searching or
servant == ServantState.camp)
for servant in my_servants])
my_moves = [ServantMove.search for _ in range(5)]
my_move = ",".join(["NSR"[moves.index(memory_move(num_to_die,
last_return,
bots,
turn))]] * 5)
print (my_move)
results = process_turn_results(my_read())
bots = [[result_to_state(servant) for servant in bot] for bot in results]
if len(last_return) != len(bots):
last_return = [[14 for _ in range(5)] for _ in range(len(bots))]
for i, bot in enumerate(results):
for j in range(5):
if bot[j] == MoveResult.returned:
last_return[i][j] = turn
my_servants = bots[my_index - 1]
else:
end_day = my_read()
bots = process_day_results(end_day)
my_servants = bots[my_index - 1]
day += 1
command:
python players/Bob/Bob.py
Bob
Bob is currently out for repairs.