25
7
sheesh, is this really the 4th? For all you oldcomers, the core challenge is the same, but we are using Java instead of a custom language. Here are the past three CodeBot challenges, in case you are interested.
The goal of CodeBots is to make your bot as viral as possible. Each bot carries a Flag, and you need to make sure that your Flag is everywhere.
API
Bots will follow a standardized "protocol", and bots progress through the following steps synchronously:
IPAddress selectMessageRecipient()
allows a bot to choose who he wants to send a "friendly" message to.Message sendMessage()
allows a bot to choose the contents of the message he will send out.processMessage(IPAddress, Message)
is called for each message a bot receives.FunctionType selectFunctionToBlock()
blocks a function from being overwritten for the current turn. See step 7.IPAddress selectAttackTarget()
allows a bot to choose who he wants to DDOS. A DDOS attack is successful if the bot is targeted by 3 bots at the same time. If an attack is successful, then each of the attackers can perform step 6 and 7.readData(ReadonlyBot)
allows a bot to read data stored on the vulnerable bot.FunctionType selectFunctionToReplace()
is the crux of this challenge. You are allowed to select 1 function (of the 8 listed here) to copy over from your bot to their bot. Then, your function will be called instead of theirs. If multiple bots select the same function, a random one will be successful.String getFlag()
is called at the end of the game, and should return a string unique to your submission. Your function should always return the same string. The submission with the most flags at the end of the game wins.
Storage
You have 3 forms of storage, an AddressBook, a Log, and a Variables. These forms of storage are local to the bot your function is running on (so if your function gets copied, the contents of each of these objects will be different). All of these objects can be manually modified or cleared. To obtain these objects, you have a getter in your class (e.g. getLog()
).
The AddressBook stores a list of IPAddress, each with a AddressType, which allows you to classify the different types of addresses. AddressBook will always contain at least 1 address (if it is cleared, a random one will be added). Clearing your AddressBook to obtain multiple IPAddresses is not allowed.
The Log stores a list of all actions taken, as well as data about the action. It also includes a history of all successful attacks (though you don't know which functions they overwrote)
The Variables object allows you to store string variables attached to a string name. On game start, Variables will contain a single variable, ID
, which contains a randomly generated ID that is unique to your bot type.
You also have other access functions:
int getTurnNumber()
returns an integer with the current turnbool functionsMatch(ReadonlyBot, FunctionType)
tests to see if the ReadonlyBot's function matches yoursIPAddress personalAddress()
returns your IPAddress
How to implement
- You can obtain the code from Github
- Add your bot to the
\bots
folder, and then add a reference to your bot incontroller\CodeBotFactory.java
- Your bot must extend
codebots.bot.CodeBot
orcodebots.bots.DefaultCodeBot
- You need Java 8 if you want to run the controller.
- You can run the code (assuming you are in the
/src
folder) usingjavac codebots\*.java
to compile, thenjava codebots.Main
to run. - You may not have any non-constant member variables in your class
- Reflection is not allowed.
- Forms of communication between bots (of the same or different types) outside of the methods listed above is not allowed.
- Dumb and/or Suicidal bots are allowed, but all bots should be functionally different than existing entries.
- If you want randomness in your bot, use
getRandom()
- Please try to keep your code efficient. I've spent a good deal of time profiling and making the controller fast.
Scores
105.2501 Expelliarmus!
104.5803 I'm Helping!
104.2746 Who Am I?
103.8529 Dumb Bot
103.2028 Replacer
102.7045 Chaos
102.4046 Hermit Bot
102.2849 Swarmer
100.5598 Random bot loves you
99.966 Trust in Trust!
99.0185 codebots.bots.DefaultCodeBot
91.2942 codebots.bots.MarkedBot
91.1423 Just your friendly neighborhood mail delivering robot.
89.4645 null
You should probably make Log.LogEntry final, with it not final I can create logs with any information I want ... that only my bot function would be able to read or create. – TheNumberOne – 2015-12-11T14:09:55.910
Can readData access the IpAddress of the bot it is reading? – TheNumberOne – 2015-12-11T18:13:26.557
@TheNumberOne not currently, but I don't see why not. I don't have the code on me right now, but I'll update the code to change that. – Nathan Merrill – 2015-12-11T19:02:12.120
That would simplify SwarmBot slightly. I have to do a variable-lookup and then address-lookup in order to perform address book modification. – Draco18s no longer trusts SE – 2015-12-11T19:23:42.797
3I find it interesting that Chaos makes DisarmBot and MarkedBot trade places on the leader board. – TheNumberOne – 2015-12-11T20:09:44.453
I think there may be some problems with the AddressBook. You put IPAddress objects in a HashMap but they don't implement hashCode() and equals(). This might work, but only if each IPAddress object exists only once. Apart from that the IPAddress objects are sorted by the hash code in the map. This means that simple bots calling
getAddressBook().getAddress(0)
will get the IPAddress with the smallest hash code, which seems unfair to me, because bots whose IPAddress has a small hash code will be attacked more often than others. – Sleafar – 2015-12-11T23:31:45.710@Sleafar IPAddresses do only exist once, which is very intentional. The Bot with the smallest IPAddress will be randomized each round, so it should even out. I've used other methods for random access, but they all cause code slowdown, so I'm ok with that. – Nathan Merrill – 2015-12-12T00:20:00.903
@NathanMerrill Should probably override hashCode and equals anyway. Its good practice. – Draco18s no longer trusts SE – 2015-12-12T02:38:45.333
Except that the default behavior is the one I want. The IP address isn't defined by the string, it's simply a nice visual representation. – Nathan Merrill – 2015-12-12T04:13:26.503
1Currently on round 7850 out of 10000, getting more accurate scores... – LegionMammal978 – 2015-12-12T22:50:23.710
Sorry, for bugging you ... but when are you going to add the getIPAddress function to ReadOnlyBot ? – TheNumberOne – 2015-12-12T23:20:11.473
I can't do it today, but if you code a bot that uses that function, I'll implement it. – Nathan Merrill – 2015-12-13T01:30:48.960
Ok :) I'm actually working on one right now. btw, you should probably add
hasAttacked
to ReadOnlyLogEntry. – TheNumberOne – 2015-12-13T01:58:52.023Some results after 10000 rounds – LegionMammal978 – 2015-12-13T13:22:28.150
@LegionMammal978 its good to see that all of the high rankings match mine exactly. – Nathan Merrill – 2015-12-13T13:32:45.623
@TheNumberOne done. – Nathan Merrill – 2015-12-13T14:02:09.747
Very interesting challenge, even though I'm quite late to the party. Just an observation: for newcomers, the "Scores" section is rather hard to correlate to the answers at first glance. Having the answer title match or include what
getFlag()
returns would make that easier (since I'm guessing the scores are generated and the code has no way of knowing what the answer's title is), e.g. instead of just "AmnesiaBot", if it could say "AmnesiaBot - Who Am I?", that would help. – Amos M. Carpenter – 2016-04-04T08:07:47.550@AmosM.Carpenter yeah, that was fairly annoying, which is why I ended up linking to the questions. – Nathan Merrill – 2016-04-04T14:03:18.960
I'm sad to see that my last entry was never run officially, despite out-scoring the current leader at the time. It came in only a day after the leaderboard was last updated in the question. Additionally, there is one other entry that was never run, having been posted 10 days later.
– Draco18s no longer trusts SE – 2018-03-13T19:14:57.340Oh, I didn't realize that that happened! I don't have time today, but I'll definitely run it tomorrow! – Nathan Merrill – 2018-03-13T21:26:58.213
@Draco18s ...This is going to take longer than I thought. I'm running 10K rounds: I started 5 hours ago, and I'm on round 3000. I'll have the scores up by tomorrow hopefully :) – Nathan Merrill – 2018-03-14T19:23:31.383
@NathanMerrill Dedication! Rivaled only by trichoplax and Formic Functions. ;) Glad its being done, I'd forgotten about it until I mentioned this challenge and noticed. – Draco18s no longer trusts SE – 2018-03-14T20:01:45.303
@Draco18s well, unfortunately, your bot didn't win. I'm not convinced that this ended up being a good KoTH: there were significant place changes, and I don't know whether it was the two new bots, or simply randomness. – Nathan Merrill – 2018-03-15T14:51:54.937
@NathanMerrill Yeah, a sufficiently long-calculation for KOTHs is always a problem. Formic Functs takes 2+ weeks to resolve first place. And that's after Dave went and made his KOTH framework which makes some speed optimizations (such as caching and webworkers). The official Formic Funct controller implemented the caching, speeding things up from "1-3 months" to "1-3 weeks" (before the addition of a new 500 ant bot, which slowed it down again). Trichoplax made a meta post about it not that long ago.
– Draco18s no longer trusts SE – 2018-03-15T17:24:33.723Per this one and Dumb Bot: I never ran it with Hermit in the mix, so that might've changed things, or it was the randomness, or who knows. But thanks for giving it a bash! – Draco18s no longer trusts SE – 2018-03-15T17:25:02.723