Notice: This king-of-the-hill challenge has completed. This means that the green checkmark, which has been awarded to C5H8NNaO4 for their entry The Observer will not be moved to any new answer.
You may still submit new entries, but there may be delays in new tournaments running as I am not actively checking for new entries anymore.
Introduction
In this challenge, you are playing an arcade game titled The Ultimate Samurai Showdown Ultimate Edition Special Version 2.0 X Alpha Omega Turbo (or just Ultimate Samurai Showdown for short). Your opponents? None other than the other members of Programming Puzzles & Code Golf!
As you might expect from a PPCG arcade game, you do not play Ultimate Samurai Showdown directly, but rather write a program that will play the game for you. This program will fight against programs submitted by other users in one on one duels. The most skilled program will be crowned the Ultimate Samurai of PPCG, and be granted the green tick of legend.
Game Description
This section describes the mechanics behind the game.
Victory Condition
A match consists of two samurai which are facing off against each other. Each samurai begins each match with 20 hit points and 1 honour. A samurai wins if his opponent is dead and he is still alive. There are two methods by which a samurai can die:
- If a samurai's hit points are brought down to 0, he will die.
- If a samurai brings their own honour below 0, he will be struck down by the gods for acting dishonourably in a duel.
Being struck down by the gods has higher priority over having hit points reduced to 0, so in a situation where one samurai is at 0 health points and the other is at -1 honour, the samurai with 0 health points will win. In a situation where both samurai are at -1 honour, they both get struck down by the gods and the game is a draw.
A match consists of up to 500 turns. If all 500 turns pass and the match has not been decided (neither samurai has died), the gods grow bored and strike down both of the samurai, thus resulting in a draw.
Actions
On each turn, the samurai must perform exactly one of the following actions:
W
The samurai shall wait and perform no action. This makes him look cool but doesn't help him defeat his opponent. This is also the default action.
B
The samurai shall bow to his opponent in an honourable fashion. This pleases the gods and thus the samurai will gain 1 Honour. Honour is vital to your samurai's success because Honour is essentially the "resource" for this game -- all moves apart from B
and W
can decrease Honour. Also, if a samurai gains 7 Honour or more, he is granted use of the Sword of the Gods. The implications of this are described below.
However, bowing to your opponent leaves you open if your opponent decides to strike you with his sword, so be careful when you choose to bow.
G
The samurai shall enter a defensive position and guard against any sword strikes. This move will successfully block all sword strikes, even ones made with the Sword of the Gods.
However, the gods frown upon an overly defensive samurai, so this move will consume 1 Honour if the samurai's action on the immediately preceding turn was also guarding. It does not consume Honour otherwise.
I
The samurai shall attempt to strike his opponent with a quick draw of his sword from its scabbard. If the samurai has 7 Honour or more, he will use the Sword of the Gods instead of his regular sword. This move consumes 1 Honour.
The quick draw is a fast strike that will beat slower overhead attacks, however, it will lose against parries. If the strike connects successfully it will do 1 damage, or 2 damage with the Sword of the Gods.
P
The samurai shall attempt to parry any incoming attack, then launch his own attack. If the samurai has 7 Honour or more, he will use the Sword of the Gods instead of his regular sword. This move consumes 1 Honour.
The parry is a good manoeuvre against fast strikes, but it will be overpowered by slower overhead attacks. If the strike connects successfully it will do 1 damage, or 2 damage with the Sword of the Gods.
O
The samurai shall attempt to strike his opponent with a slower overhead attack. If the samurai has 7 Honour or above, he will use the Sword of the Gods instead of his regular sword. This move consumes 1 honour.
The overhead strike can overpower parries, but it will lose against fast strikes. If the strike connects successfully it will do 1 damage, or 2 damage with the Sword of the Gods.
Sword of the Gods
A samurai with Honour that is 7 or more gains the ability to use the Sword of the Gods. If his Honour is reduced below 7, the ability to use the Sword of the Gods will be revoked from him. The Sword of the Gods deals 2 damage instead of 1.
The Sword of the Gods does not allow a strike to defeat a sword strike that it would not ordinarily defeat. For instance, a Sword of the Gods parry will still lose to an ordinary overhead strike, and a Sword of the Gods quick draw will not overpower an ordinary quick draw. Indeed, the so-called Sword of the Gods is actually not all that powerful -- perhaps it is a cosmic joke played by the gods...
Interaction Table
The Stack Snippet below contains a table which explicitly lists all the possible results of the different combinations of actions the two samurai can take. To view it, click on "Show Code Snippet", then click "Run Code Snippet".
td,
th {
border: 1px solid #ccc;
text-align: center;
font-family: sans-serif;
}
<table>
<tr>
<th></th>
<th>W (Wait)</th>
<th>B (Bow)</th>
<th>G (Guard)</th>
<th>I (Quick Draw)</th>
<th>P (Parry)</th>
<th>O (Overhead Strike)</th>
</tr>
<tr>
<td>W (Wait)</td>
<td>Nothing occurs.</td>
<td>The player that bowed gains +1 Honour.</td>
<td>If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>The player that waited takes 1 damage (or 2 if the Sword of the Gods was used.) The player that struck loses 1 Honour.</td>
<td>The player that waited takes 1 damage (or 2 if the Sword of the Gods was used.) The player that struck loses 1 Honour.</td>
<td>The player that waited takes 1 damage (or 2 if the Sword of the Gods was used.) The player that struck loses 1 Honour.</td>
</tr>
<tr>
<td>B (Bow)</td>
<td>The player that bowed gains +1 Honour.</td>
<td>Both players gain +1 Honour.</td>
<td>The player that bowed gains +1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour and takes 1 damage (or 2 if the Sword of the Gods was used). The player that struck loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour and takes 1 damage (or 2 if the Sword of the Gods was used). The player that struck loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour and takes 1 damage (or 2 if the Sword of the Gods was used). The player that struck loses 1 Honour.</td>
</tr>
<tr>
<td>G (Guard)</td>
<td>If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>If a guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>The player that struck loses 1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour. </td>
<td>The player that struck loses 1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>The player that struck loses 1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
</tr>
<tr>
<td>I (Quick Draw)</td>
<td>The player that waited takes 1 damage (or 2 if the Sword of the Gods was used.) The player that struck loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour and takes 1 damage (or 2 if the Sword of the Gods was used). The player that struck loses 1 Honour.</td>
<td>The player that struck loses 1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>Both players lose 1 Honour. </td>
<td>Both players lose 1 Honour. The player that quick drawed takes 1 damage (or 2 if the Sword of the Gods was used.).</td>
<td>Both players lose 1 Honour. The player that used an overhead strike takes 1 damage (or 2 if the Sword of the Gods was used.).</td>
</tr>
<tr>
<td>P (Parry)</td>
<td>The player that waited takes 1 damage (or 2 if the Sword of the Gods was used.) The player that struck loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour and takes 1 damage (or 2 if the Sword of the Gods was used). The player that struck loses 1 Honour.</td>
<td>The player that struck loses 1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>Both players lose 1 Honour. The player that quick drawed takes 1 damage (or 2 if the Sword of the Gods was used.).</td>
<td>Both players lose 1 Honour. </td>
<td>Both players lose 1 Honour. The player that parried takes 1 damage (or 2 if the Sword of the Gods was used.).</td>
</tr>
<tr>
<td>O (Overhead Strike)</td>
<td>The player that waited takes 1 damage (or 2 if the Sword of the Gods was used.) The player that struck loses 1 Honour.</td>
<td>The player that bowed gains +1 Honour and takes 1 damage (or 2 if the Sword of the Gods was used). The player that struck loses 1 Honour.</td>
<td>The player that struck loses 1 Honour. If the guarding player guarded the previous turn, that player loses 1 Honour.</td>
<td>Both players lose 1 Honour. The player that used an overhead strike takes 1 damage (or 2 if the Sword of the Gods was used.).</td>
<td>Both players lose 1 Honour. The player that parried takes 1 damage (or 2 if the Sword of the Gods was used.).</td>
<td>Both players lose 1 Honour. </td>
</tr>
</table>
Program Communication
To facilitate the running of the tournament, a controller program was written to play the role of the "gods" -- it keeps records of honour and health and smites samurai accordingly. This section describes how your program will communicate with the controller program.
Input Description
The controller program will call your program from the command line like this:
<command> <history> <enemy_history> <your_health> <enemy_health> <your_honour> <enemy_honour>
where:
<command>
is the command required to run your program. For instance, if your program is in a filesuper_sentai.pl
, the command is probablyperl super_sentai.pl
.<history>
is a history of moves that you made. For instance,WWBP
would mean you waited twice, bowed once, and parried once.<enemy_history>
is a history of moves your enemy made. For instance,BBBI
would mean your enemy bowed three times and performed one quick draw.<your_health>
is your current health.<enemy_health>
is the enemy's current health.<your_honour>
is your current honour.<enemy_honour>
is the enemy's current honour.
For the first turn, the history
and enemy_history
will be empty, so your program will just be called with the last four arguments like this:
<command> <your_health> <enemy_health> <your_honour> <enemy_honour>
Please be prepared for this!
Astute readers may notice that the four arguments providing the honour and health of both samurai are, to some extent, superfluous; since this is a perfect information game, the honour and health of the samurai can be determined using only the histories.
These values are provided for convenience purposes so that you do not have to parse the history arguments. This should prove useful for implementing simple strategies, such as not attacking when your Honour is 0.
Output Description
To choose an action, your program should output one of W
, B
, G
, I
, P
, or O
to standard output, depending on what action you want to make. If your program doesn't output anything within 1000ms, it will be terminated and your program will be treated as if it outputted W
.
If your program outputs more than one letter, only the first letter will be considered -- so outputting Parry
will be the same as outputting P
.
If the output of your program's first letter is not any of the options listed above, it will default to W
.
Submission Format
Submit a program as an answer to this post. You may submit multiple programs. If you are submitting multiple simple programs, I recommend submitting them as a single answer; if you are submitting multiple complex programs, I recommend submitting them as separate answers. Once I have successfully added your program/s to the tournament, I will make a commit to the git repository with your entry (linked below).
If I encounter problems that prevent your program from being added to the tournament, I will leave a comment on your entry indicating the problem.
Please include the following in your submission:
- The human readable name of your program, for use in scoreboards. Spaces are allowed here; commas and Unicode characters are not.
- The language your program is written in. Please avoid writing in strange, difficult to access languages like TinyMUSH.
- A short synopsis of your program. This can be a description on how the program works, or just some flavour text about your program (if you want to be all secretive), or perhaps both.
- The command/s required to run your program. For instance, if you were writing your submission in Java called
example.java
, you would provide compiling instructionsjavac example.java
then running instructionsjava example
. - The source code for the program.
To assist in submitting, I provide a submission template which can be found here. The template makes submissions look nicer. I strongly encourage using it.
I also provide two example entries. Although the example entries will be participating in the round robin, their main purpose is to clarify the submission and input/output formats for the tournament, rather than being serious contenders for the title of Ultimate Samurai.
Tournament Structure
This section describes how the tournament between the participants will be run.
Control Program
The control program is written in Python 2 and can be found on the Ultimate Samurai Showdown Github repository. If you'd like to run it yourself, instructions on how to run it are included in the README.md file in the link. However, only tournaments run on my computer will be official to avoid hardware differences affecting tournament results.
The control program will be ran on a laptop computer running Arch Linux. It has an Intel Core i7 processor and 8GB of RAM. I will endeavour to get all entries running on my computer, but I'd appreciate it immensely if you avoid languages that can't be accessed freely (as in no monetary cost).
Scoring System
The scoring system is a round robin. Each program will play eight matches against every other program. A win grants the program 1 point, a loss no points, and a draw 0.5 points. The program with the highest score wins the game. If there is a draw, I will duel the top two programs against each other to determine the winner.
The number of times each program will play each other program may be decreased from 8 if there is an extremely large number of entrants. I will add a note here if this occurs.
I will be running the round robin many times as new submissions are posted, but it is only the most recent round robin that will count.
Disqualifications
It is possible for your program to be disqualified from the tournament. Disqualification may occur if:
- Your program does not compile or run;
- Your program is a strategic duplicate of another program (that is, it implements the exact same strategy as another program);
- Your program attempts to sabotage other programs by modifying the controller code, other program's code, etc;
- Your program attempts to exploit a bug in the controller code. Instead of exploiting bugs you should instead open an issue in the git repository, make a comment here, or ping me in chat.
Past Results
Detailed results of all tournaments are made available at the wiki page.
The most recent tournament was completed on 2015-07-17 07:20. Here is a summary of the results:
The Observer: 209.0
Coward: 203.0
Monk: 173.0
Elephant Warrior: 157.0
Iniqy: 157.0
Agent 38: 144.0
Ninja: 138.0
Meiyo Senshi: 138.0
Kakashi: 136.0
Yoshimitsu: 131.0
Hermurai: 121.0
Warrior Princess: 120.0
Gargoyle: 119.5
The Honourable: 119.0
Hebi: 118.5
Predictor: 116.0
Whack-a-mole: 107.0
The Fool: 106.0
The Prophet: 105.0
Copy-san: 97.0
YAGMCSE: 80.0
The Waiter: 66.0
Swordsman: 43.0
Spork Holder: 32.5
Blessed Samurai: 27.5
Attacker: 27.0
The Terminator: 17.0
Master Yi: 16.0