Final results
1st place goes to Follow!
Honourable mentions to The diff predictor (2nd), and Simple Killer, Low Blow and High to Low (joint 3rd).
Other winners:
(score competition) 1st - Simple Killer
Honourable mentions: The diff predictor and Naiive.
(wins competition) 1st - Crab
Honourable mentions: Follow and High to Low.
Full results:
By score:
1: Simple Killer with 1208099 points
2: The diff predictor with 1053087 points
3: Naiive with 1051505 points
4: Follow with 905731 points
5: The dedicated counter with 769680 points
6: The Desperate Fighter with 769663 points
7: Low Blow with 763357 points
8: High to Low with 734011 points
9: Naughty or Nice? with 714912 points
10: Grim Trigger with 713702 points
11: Tit for tat with 713067 points
12: The primitive looker with 621028 points
13: Hard-coded with 428934 points
14: Zoidberg with 395702 points
15: FunnyNumber with 335179 points
16: Random with 329023 points
17: Shortcut with 257190 points
18: Meandian with 223051 points
19: Hawk with 47608 points
20: Crab with 14852 points
By wins:
1: Crab with avg. 19.0/19 wins
2: Follow with avg. 17.1/19 wins
3: High to Low with avg. 15.8/19 wins
4: Low Blow with avg. 14.9/19 wins
5: The diff predictor with avg. 14.1/19 wins
6: Meandian with avg. 13.7/19 wins
7: Hawk with avg. 13.0/19 wins
8: Hard-coded with avg. 11.7/19 wins
9: Naughty or Nice? with avg. 11.0/19 wins
10: Simple Killer with avg. 10.4/19 wins
11: The primitive looker with avg. 8.0/19 wins
12: Naiive with avg. 6.6/19 wins
13: Zoidberg with avg. 6.3/19 wins
14: Shortcut with avg. 5.0/19 wins
14: Grim Trigger with avg. 5.0/19 wins
16: FunnyNumber with avg. 4.0/19 wins
17: Random with avg. 3.0/19 wins
18: Tit for tat with avg. 1.0/19 wins
19: The dedicated counter with avg. 0.0/19 wins
19: The Desperate Fighter with avg. 0.0/19 wins
Combined leaderboard (fewer pts = better):
1: Follow (6 pts)
2: The diff predictor (7 pts)
3: Simple Killer (11 pts)
3: Low Blow (11 pts)
3: High to Low (11 pts)
6: Naiive (15 pts)
7: Naughty or Nice? (18 pts)
8: Hard-coded (21 pts)
8: Crab (21 pts)
10: The primitive looker (23 pts)
11: The dedicated counter (24 pts)
11: Grim Trigger (24 pts)
11: Meandian (24 pts)
14: The Desperate Fighter (25 pts)
15: Hawk (26 pts)
16: Zoidberg (27 pts)
17: Tit for tat (29 pts)
18: FunnyNumber (31 pts)
18: Shortcut (31 pts)
20: Random (33 pts)
Cooperative Counting - Python 3 KOTH
Have you ever tried to count to 100 in an online forum or comment thread? It normally goes something like:
1
>2
>>3
>>>4
>>>>69 xD xD
the point being that someone will always try to ruin the fun.
The game
This is a bit like the counting example above, except to make sure that neither player has an advantage from going first, each player will count at the same time as the other.
Your bot will be pitted against another bot. Your goal? Cooperatively count to 100.
Each round, your bot decides how far it is willing to cooperatively count with its opponent.
Possible outcomes
One player stops counting before the other
The player who stopped counting first is awarded twice as many points as the value they counted up to. The other player gains no points.
Both you and your opponent stop counting at the same time
Neither of you gain any points.
Both you and your opponent count all the way to 100
Each player gains 100 points.
Example
- Player 1: decides to count to 80
- Player 2: decides to count to 30
Player 2 gets 60 points, player 1 gets 0 points.
In another round:
- Player 1: decides to count to 57
- Player 2: decides to count to 57
Neither player gets points.
In yet another round:
- Player 1: decides to count to 100
- Player 2: decides to count to 100
Each player gets 100 points.
Overall game flow
Your bot will be matched against other bots. It will play some number of rounds in a row, n
, against the same bot.
n
will be somewhere in the range of 100 - 1000. This allows your bot to adapt to the other bot's strategy.
Winning the KOTH
Each bot will have a go against each other bot. Your bot can win in three categories:
- Score: the total scores will be summed and the bot with the most points at the end will win.
- Wins: a 'win' is counted for the bot with the highest score after the
n
rounds have been played. - Overall: both the other categories combined
Technical details
Write a function in Python 3 with this signature:
def strategy(last_results: list[tuple[int, bool]]) -> int
strategy
is called once at the beginning of each round.last_results
is a list of previous results against the same opponent. Each item in the list is the result of a round in the form(value reached, won)
, wherewon
denotes whether the player won or not. If the player won through cooperation, this will beTrue
.- e.g.: if you lose your first round because your opponent stops counting at 79,
last_results
looks like[(79, False)]
at the start of round 2. If you then win round 2 by stopping counting at 34,last_results
will look like[(79, False), (34, True)]
at the start of round 3. strategy
should return the value at which the bot will stop counting.1
stops counting immediately,100
is an agreement to count cooperatively with the other bot all the way to the end, and e.g.47
will stop counting when the value is47
, earning the bot 84 points.
Example bot
'Naiive' counts up to one before the number that was reached last round if it lost, otherwise it counts up to and including the number it won on.
def strategy(last_games):
if len(last_games) == 0:
return 100
# Count up to one before the last number that was counted if we lost,
# otherwise just up to the last number that was counted.
if last_games[-1][1]:
return last_games[-1][0]
else:
return max(1, last_games[-1][0] - 1)
Legacy format (don't use)
I've decided on a simpler format since the last one was causing confusion. Here is the old one for reference purposes. New submissions should be in the new format. Submissions using the legacy format do not need to update their submission.
# Don't use this, see above
def strategy(last_results: list[tuple[int, bool]]) -> tuple:
pass
def turn(current_value: int, *args) -> bool:
pass
Rules
- No cheating by interfering directly with your opponent (through global variables etc.).
- Your function should be relatively quick to execute - the quicker it is, the better.
- You may submit multiple entries.
- Submissions close a week from the start of this post, at 2021-04-17 11:00 UTC
Controller, sandbox, arena
The controller is available at https://github.com/jthistle/KOTH-counting.
A couple of example bots are provided along with it to demonstrate how to use it.
sandbox.py
provides a place to try out your bot against others and debug it.
arena.py
is what I'll be using to calculate final scores. It pits each bot against each other bot.
contestants
folder, then adds them toarena.py
. If you notice any weird bugs let me know, this is probably my first time writing anything serious in Python :p \$\endgroup\$