152
55
Caveman mad. Other caveman take stick but stick was for me. Caveman fight!
Description
Caveman need sharp stick to stab other caveman. Other caveman also try to stab with sharp stick. Caveman can sharpen stick, poke with stick, or block poky sticks.
If caveman poke other caveman with sharp stick, other caveman run away and me victory. But if other caveman smartly blocking when me poking, nothing happen except my stick become blunt and me need to sharpen again.
Caveman lazy. Also, caveman dumb. Caveman no know what to do, so caveman need fancy techno computer program to tell caveman what to do.
Input
Your program's input will be a history of the events that have happened, where S
stands for sharpen (i.e. the caveman sharpened his stick), P
stands for poke, and B
stands for block. The input will be a history of both sides (you and the opponent), so your and the opponent's moves will be separated with a comma (,
).
Example input:
SPB,SBB
This means that the player sharpened his/her stick, then poked, then blocked, and the opponent sharpened, then blocked, then blocked again.
You will receive no input on turn 1.
Output
The output is very similar to the input (because the caveman is not very smart). Your program should output S
to sharpen, P
for poke, and B
for block. Only the first character of output will be taken into account, and any other input will be treated as a B
(block) command.
S
: sharpenWhen sharpening, the caveman's stick's sharpness goes up by 1 and the stick gets 1 extra poke. Each poke reduces the stick's sharpness by 1, and if the stick's sharpness is 0, it's too dull to poke with. Sharpness starts at 0. If sharpness gets to 5, the stick is a sword! (See below.)
If the opponent pokes while you are sharpening (and they have a sharpness > 0), the opponent wins!
P
: pokeWhen poking, the caveman's stick's sharpness goes down by 1 and you poke your opponent! If your opponent is sharpening, you win! If the opponent is poking, your stick hits your opponent's stick and they both get duller (by 1 "sharpness unit"). If the opponent is blocking, nothing happens except that your stick becomes duller.
If you poke when your stick's sharpness is 5 or greater, your stick becomes a sword and you always win! (Unless your opponent also has a sword and also chose
P
; in that case, they both become duller, and may revert to sticks if their sharpness falls below 5.)You cannot poke with a sharpness of 0. If you do, nothing will happen.
B
: blockWhen you block, nothing happens when your opponent pokes. If your opponent is not poking, block does nothing.
Blocking does not protect against a sword, even if you also have one!
Rules and constraints
Additional rules are:
- Your program can read and write files in its own folder (no stealing!) if you want to save data, but you can't access anything outside of it (and cavemen don't have internet connection out in the wilderness).
- Important note on files: If you save files, remember to save them in the directory
players/YourBotsName/somefile.foo
! The current working directory for your program will not be your program's!
- Important note on files: If you save files, remember to save them in the directory
- Cavemen are fair: One program can not have code specific for another program, and programs can not help each other. (You may have multiple programs, but they can't interact with each other in any way.)
- The caveman judge is not patient. If the cavemen take more than 100 turns each to decide a winner, the judge gets bored and both cavemen lose.
If your program breaks a rule or doesn't follow the specification, the program is disqualified, removed from playerlist.txt
, and all duels restart from the beginning. If your program is disqualified, the caveman leader (me!) will comment on your program's post and explain why. If you aren't breaking any rules, your program will be added to the leaderboard. (If your program is not on the leaderboard, there is no explanatory comment on your post, and you posted your program before the "Last updated" time below, tell the caveman leader! Maybe he forgot it.)
In your post, please include:
- A name.
- A shell command to run your program (ex.
java MyBot.java
,ruby MyBot.rb
,python3 MyBot.py
, etc.).- Note: input will be appended to this as a command line argument.
- The cavemen use Ubuntu 14.04, so make sure your code works (freely) on it.
- A version number, if your code works differently on different versions of your chosen language.
- Your code (obviously).
- How to compile the code, if necessary.
Controller code / testing, example bot
The caveman leader wrote the control code in C++, and posted it on a Github repo. You can run and test your program there.
A very, very simple program (1 line!) is also posted in the answers below.
Scoring and leaderboard
Scoring is easy. Whichever caveman wins gets a point. The caveman with the most points after 3 duels against every other caveman becomes the new caveman leader!
150 Watson
147 SpeculativeSylwester
146 Gruntt
141 BashMagnon
126 ChargerMan
125 PrisonRules
124 ViceLeader
122 MultiMarkov
122 CaveDoctor
120 RegExMan
120 Hodor
117 FancyTechnoAlgorithm
116 Semipatient
113 Watcher
108 BobCaves
105 MinimaxMan
104 Oracle
102 MaybeMarkov
97 Nash
95 Sicillian
95 Feint
95 Basilisk
94 SharpMan
93 Darwin
91 Nigel
91 JavaMan
88 Entertainer
88 CarefulBot
85 CaveMonkey
84 SSBBP
82 SirPokealot
79 MasterPoker
77 Unpredictable
76 IllogicalCaveman
75 SharpenBlockPoke
75 HuddleWolfWithStick
72 WoodenShield
68 PokeBackBot
68 PatientBlacksmith
66 PatientWolf
58 MonteCarloMan
58 BlindFury
56 BinaryCaveman
55 PokeBot
55 CavekidBlocks
53 Swordmaster
53 Blocker
52 NakedEarlyNerd
52 ModestCaveman
50 LatePokeBot
40 Trickster
39 SwordLover
38 ForeignCaveman
36 Swordsmith *
28 Touche
27 WantASword
27 FoolMeOnce
24 PeriodicalCavemanCicada
11 Aichmophobic
(this leaderboard was auto-magically generated)
Players marked with a *
threw some kind of error or exception at some point; these players also have a comment on their posts.
Players who could not be included in the tests for any reason (these players will have a comment on their posts explaining the problem): Monkey
, Elephant
, FacileFibonacci
, StudiousSylwester
.
Last updated: Aug 3 00:15 (UTC).
Does the program for matches automatically quit when one caveman loses? Or do we handle this in our caveman's code? – ASCIIThenANSI – 2015-04-09T15:06:10.637
2Is this still open? I see people adding new submissions, but I don't see the leaderboard being updated. – ASCIIThenANSI – 2015-04-10T16:36:09.543
I'm surprised no one seems to have attempted to find the minimax strategy yet. It seems like the obvious thing to do. – user2357112 supports Monica – 2014-07-24T15:47:38.330
@user2357112 I don't think minimax is an improvement here. I mean, you could design a minimax implementation, but since the logic is so simple, the same exact behavior can be expressed with a finite state machine. (i.e. the bot will never sharpen until the opponent is dull because if it does, the minimizing move of the opponent will be to poke and you lose, the bot will always block until we have a sword because the maximizing move for our bot will always be to block, etc.) – HuddleWolf – 2014-07-24T18:32:18.197
My friends and I usually play this game with hand-signalled "guns" instead... – Lily Chung – 2014-07-24T22:17:28.150
@HuddleWolf: I don't mean the minimax algorithm. That would require sequential decisions, and this is not a game of sequential decisions. I mean the minimax strategy; the set of move probabilities that maximizes the minimum expected score over all possible opponent strategies. – user2357112 supports Monica – 2014-07-25T01:10:01.387
if I were to train a markov chain generator on the output of all of the existing entries playing against each other, and put the resulting training data into my entry, would that break the "cavemen are fair" rule? – Sparr – 2014-07-25T03:29:49.987
@Sparr Yes, "One program can not have code specific for another program". (In fact, that code would be specific for every single other program!) – Doorknob – 2014-07-25T10:52:54.740
@Doorknob is there some degree of fuzziness that would make it acceptable? That is, if the chain length was restricted to, say, 5 moves, then no part of the lookup table would be specific to a single other program. That is, the best way to respond to SPBSS as a single datum isn't aiming at a particular other program, but would involve data on that behavior by every other program. – Sparr – 2014-07-25T22:30:08.043
@Doorknob: What about training against a composite opponent whose strategy for each move is equivalent to picking one of the existing opponents and asking it to choose the move? If that's barred, I don't think any further optimizations I can make are within the rules. I've written a minimax bot, so literally any deviation from the minimax strategy that improves its score would be optimizing for the specific spread of opponents. Any attempt to write new bots would be doing by hand the training the machine learning algorithm would do.
– user2357112 supports Monica – 2014-07-26T04:28:54.103@Sparr I'm just going to go with "use your best judgement" - If you could write the same program with no knowledge of the current bots except their general strategy, go ahead. But don't look through the code here to find the most optimal 3rd move, for example. – Doorknob – 2014-07-26T04:33:27.093
@Lennart_96 No need to comment here; I sort the answers by "active" so I can see when submissions are added/edited. – Doorknob – 2014-07-26T04:34:27.987
3Many of the entries seem to allow for negative sharpness in their calculations. The rules as written say that nothing happens when you poke with zero sharpness. Does that "nothing" also mean your sharpness stays zero, instead of being decremented? – Sparr – 2014-07-26T14:24:37.573
also, the judge seems to treat a zero sharpness poke as a block. clarification, @Doorknob ? – Sparr – 2014-07-26T15:13:22.910
@Sparr In text above: You cannot poke with a sharpness of 0. If you do, nothing will happen. and it is interpreted as block since that is the default behaviour should you bot spit out any other char. Even the history given to the programs reflects that. – Sylwester – 2014-07-26T21:21:15.960
@Doorknob When you start CavemanDuels, do you remove the files made in previous iterations? – Sylwester – 2014-07-26T21:54:48.187
@Sylwester ahh, that last part is what I was missing, the history being altered. That fixes the problem with sharpness calculation that I thought some bots had. – Sparr – 2014-07-27T03:01:04.707
@Sylwester No, because that would require some sort of complex which-files-to-remove algorithm. That's left up to the submissions themselves. – Doorknob – 2014-07-27T11:53:51.570
@Doorknob It's hardly complex since you have used git. I'm doing
git clean -f players
before I run your program. – Sylwester – 2014-07-27T14:07:04.517I'm with Sylwester... Adding logic to my bot to check the file creation time of files and see if they are older than the current contest seems unnecessarily complex. Then again, maybe having access to data about the last few thousand contests is worthwhile... – Sparr – 2014-07-27T19:04:21.443
@Sylwester That requires keeping the Git repo up to date, which is not always possible if you want to test your bot against a specific other one, for example. – Doorknob – 2014-07-27T23:25:59.110
@Sparr Or, you could just check if there are no arguments (i.e. it's the first round) and delete all your files if so. – Doorknob – 2014-07-27T23:26:21.090
@Doorknob I'm talking about the beginning of a new run of the whole tournament. The RPSLV contest specifies that data will be cleared at that time. In this contest, there's no reliable way to do it. On one hand, I'm considering looking at file timestamps to get rid of data more than a few minutes old. On the other hand, the solution I just submitted is going to eventually take advantage of being able to track data between tournaments, which will make it smarter in the long run. – Sparr – 2014-07-28T00:00:40.597
Doorknob: I'm not sure about your answer to @Sparr. I can see in my log that two challenges against mine sometimes are alternating so you cannot be sure if your previous session has ended even if one starts. – Sylwester – 2014-07-28T00:07:56.817
The judge running multiple threads will play havoc with bots that try to track data, it seems? – Sparr – 2014-07-28T00:11:21.200
6
This needs to be here: http://dresdencodak.com/comics/2009-09-22-caveman_science_fiction.jpg
– Evi1M4chine – 2014-07-28T01:10:26.653Maybe it will get the imagination going. :)
just an FYI on the data directories from the RPSLV tourney. Don't have any submissions yet that do data files, but when they come in, I'm just going to auto purge all the /Player/[Name]/Data directories at the beginning of each tourney – Eoin Campbell – 2014-07-28T09:48:17.673
Hello, I was surprised by my score, I know my bash script was not that smart. While I was trying to remove weak spots, I discovered this: If you read the out.txt, BashMagnon didn't win a round against CaveDoctor but if I make a simulation I get SBSBSBSBSP,SBBBBBSBSP each time, which is "sword against stick" and should win. Could you double check? – Emmanuel – 2014-07-30T08:50:46.210
@Emmanuel How did you run this simulation? The way that it works is that on round 1, both programs get no input, then on round two, they both get
S,S
, etc. – Doorknob – 2014-07-30T09:18:14.283@Doorknob
a=./players/BashMagnon/BashMagnon.sh
,b="./players/CaveDoctor/CaveDoctor.lua"
,S=""
then I repeated that command at each step :S=${S%%,*}$($a $S),${S##*,}$(lua $b $S); echo $S
– Emmanuel – 2014-07-30T09:31:01.627@Emmanuel I just tried here a lot of times and CaveDoctor always win against BashMagnon with
SBBBBBP,SBSBSBS
. Are you sure after the5B
CaveDoctor doesnt output aP
? – wendelbsilva – 2014-07-30T16:52:36.323It was my fault I used a wrong command which was not inverting the right and left sequences.
S=${S%%,*}$($a $S),${S##*,}$(lua $b ${S##*,},${S%%,*}); echo $S
is the right command – Emmanuel – 2014-07-30T18:30:40.453