Kode Bot
Saya benci variabel pribadi dan dilindungi. Saya hanya ingin mengakses apa saja!
Jika Anda seperti saya, maka tantangan ini adalah untuk Anda!
Menulis bot yang bekerja bersama secara harmonis dengan bot lain membuat bot lain melakukan apa yang Anda inginkan. Anda adalah seorang programmer, dan Anda tahu bagaimana segala sesuatu seharusnya bekerja. Tugas Anda adalah mengonversi bot sebanyak mungkin sesuai keinginan Anda.
Kode
Anda akan memiliki 24 baris kode untuk menulis bot Anda. Setiap belokan, setiap bot akan menjalankan 1 baris secara berurutan.
Setiap bot menyimpan 5 variabel A
melalui E
. A
dan B
untuk penggunaan pribadi, C
menyimpan baris berikutnya untuk dieksekusi, D
menyimpan arah saat ini, dan E
merupakan angka acak. Variabel mulai dari 0, kecuali untuk D
, yang akan mulai pada nilai acak. Semua variabel hanya menyimpan 0-23. Angka yang lebih besar atau lebih kecil akan dimodulasi oleh 24.
Dalam posting ini, saya akan menggunakan lawan untuk menjadi bot yang berdekatan yang Anda hadapi
Setiap baris harus mengandung salah satu dari 5 perintah berikut:
Flag
tidak melakukan apa-apa. Kecuali bagaimana kamu menangMove
memindahkan bot AndaD
ke arah th. Jika bot sudah menempati ruang tersebut, tidak ada gerakan yang akan terjadiCopy Var1 Var2
menyalin isi Var1 ke Var2If Condition Line1 Line2
Jika kondisi benar, jalankan Line1, kalau tidak Line2Block Var1
blok tulisan berikutnya pada variabel
Variabel dapat digunakan sebagai berikut:
#Var
akan menggunakan variabel sebagai nomor baris. Jika A
berumur 17, Copy #8 #A
akan menyalin isi baris 8 ke baris 17.
*Var
akan menggunakan variabel lawan Anda. Copy 5 *C
akan mengatur C
variabel lawan untuk 5
Var+Var
akan menambahkan dua variabel. Copy D+1 D
akan memutar bot ke kanan
Saat D
digunakan sebagai arah, [North, East, South, West][D%4]
akan digunakan
Pengubah ini dapat dirantai: Copy *#*C #9
akan menyalin baris berikutnya lawan Anda akan mengeksekusi ke kode Anda sendiri pada baris 9. **D
mengacu pada D
variabel lawan lawan Anda .
Suatu kondisi akan dievaluasi sebagai berikut:
- Jika
Var
:- Jika Var
A
lewatC
, itu akan mengembalikan true jika Var bukan nol, kalau tidak salah. - Jika Var
D
, itu akan mengembalikan true jika ada bot diD
arah th, kalau tidak palsu - Jika Var
E
, itu akan mengembalikan true jika E aneh, kalau tidak salah - Jika Var adalah garis, itu akan mengembalikan true jika itu adalah garis Bendera
- Jika Var
- Jika
Var1=Var2
:- Mengembalikan nilai true jika keduanya
A-E
, dan sama dengan nomor yang sama - Mengembalikan nilai true jika keduanya adalah garis, dan jenis garis sama
- Mengembalikan nilai true jika keduanya
- Jika
Var1==Var2
:- Mengembalikan nilai true jika keduanya
A-E
, dan sama dengan nomor yang sama - Mengembalikan nilai true jika keduanya adalah garis, dan identik (Bendera dari bot yang berbeda tidak akan sama)
- Mengembalikan nilai true jika keduanya
50 bot dari setiap jenis akan ditempatkan di dunia toroidal dalam pola berikut:
B...B...B...B...
..B...B...B...B.
B...B...B...B...
..B...B...B...B.
Setelah setiap pertandingan 5.000 putaran, bendera pada setiap bot akan dihitung. Anda mendapatkan poin jika bot memiliki lebih banyak bendera Anda daripada jenis bendera lainnya. Jika terjadi ikatan antaraN
bot, tidak ada poin yang diberikan.
Akan ada 10 pertandingan, dan skor akan diakumulasikan di akhir.
Catatan Samping
Komentar akhir baris diizinkan, dan dilambangkan dengan //
Mencoba melakukan sesuatu yang tidak masuk akal, seperti menambah garis tidak akan menghasilkan apa-apa
Mencoba melakukan sesuatu pada bot yang tidak ada tidak akan melakukan apa-apa
Rekursi tak terbatas pada If
wasiat akan berakhir tanpa garis yang dieksekusi
If
tidak mengubah nilai C
SEBUAH Block
tidak kedaluwarsa hingga seseorang mencoba menulisnya
Berbagai variabel dan garis dapat diblokir sekaligus
Block
ing variabel berulang kali akan memblokir beberapa kali selama pernyataan blok kedua berada pada baris kode yang berbeda dari yang pertama
Spasi hanya diperbolehkan di antara argumen (dan setelah perintah)
Jika bot lebih pendek dari 24 baris, Bendera akan menjadi sisa baris.
Program Sampel
Copy 2 C //Skip to the If line
Flag //Where I'm storing my flag
Move //Move in the D'th direction
If D #5 #2 //If there's a bot, copy code, otherwise, move!
Copy #1 *#E //Copy my flag onto a random spot in my bot's code
Copy 2 C //Skip back to the If line
Program ini akan dijalankan oleh pengontrol Python saya di sini .
The Java controller di sini Hal ini cepat dan terlihat jauh lebih baik daripada python.
Papan angka:
- 6837 $ Salin
- 3355 Lockheed
- 1695 MindControl
- 967 Bizantium
- 959 AttackOrElse
- 743 Cadmyllion
- 367 Influenza
- 251 TheCommonCold
- 226 Magus
- 137 HideBlockAttack
- 129 RowBot
- 123 FastMoveCloneDodge
- 112 FastForwardClone
- 96 QuickFreeze
- 71 Perbaikan dan Perlindungan
- 96 SuperFreeze
- 93 RovingVirus
- 80 ForwardClone
- 77 FreezeTag
- 68 Palimpseste
- 62 BlockFreezeAttack
- 51 RushAttackDodge
- 46 Blocker
- 40 Pembuat Menara
- 37 Copycat
- 37 Kamikaze
- 35 FlagInjector
- 33 RandomCopier
- 31 Berbahaya
- 29 HappyAsAClam
- 25 NanoVirus
- 21 Nullifier
- 19 Nanoviris
- 17 BoringCopybot
- 16 Movebot
- 14 Flagbot
- 13 Penetralisir
- 12 Kanker
- 9 DNAbot
- 9 Parasit
- 8 MetaInsidious
- 8 Rebranding
- 8 AdaptiveBot
- 8 ReproducingBot
- 8 KungFuBot
- 5 QuickFreezerbot
- 4 Penyerang
sumber
Jawaban:
Flagbot
Why bother doing anything when other bots are going to be nice enough to give me their code?
sumber
Freeze Tag
Trap opponent in a loop, fill him with flags, move on to next opponent.
sumber
Copy C+23 C
This has to be the most malicious line of code xD.Or would that not count as your flags?
. Because if they don't count as your own flags, it's definitely not a good solutionParasite
Why kill other bots? This bot looks through opponent's code and replaces only the flags.
sumber
$Copy
This bot uses much of the same techniques as COTO's Lockheed, so I will shamelessly borrow and enhance.
This exploits a
C
vulnerability to break blocks and even reverses the neutralizer. It is also written in absolutes because of this. I think this might break if theC
shift is reinstated, but as long as the shift is constant, it can be rewritten to combat it.For whatever reason, the lack of loop at the end made this bot super good.
sumber
C
values. Thus, a block can be stacked when called from anIf
statement, which is the exploit being used here. $Copy breaks blocks (like the clam) by executingCopy
on the same line over and over until successful, which gives it an advantage over Lockheed.Lockheed
My third (and likely final) submission to this particular bot war: the Lockheed Reactor, or "Lockheed" for short.
Special thanks goes to @Wasmoo, who shared his discovery of the "'Blocking a variable multiple times will block multiple times as long as the second block statement is on a different line of code than your first.' simply isn't true" exploit. I make extensive use of it.
Also, thanks goes to Nathan Merill for administrating the competition and for publishing the simulator. The simulator is utterly invaluable in tuning bots. I wouldn't have believed it if I hadn't simulated it with my own eyes, but the addition or removal of the most conceptually minor bot feature can mean the difference between great success and abject failure. I'm torn as to whether that's a good thing or not.
sumber
If
pointing to that line will not fail), You are blocking the same value (A single line can block lines 1-24 with an incrementing variable), and the block hasn't already been released (somebody tried to modify that variable)C
,<block target>
) is not already in effect". That is, the line the block statement is on has no relevance to stacking, except that if the block is executed directly,C
= block instruction address.Attack Or Else
Seeing as defensive robots like Byzantine were doing so well, I decided to make a defensive robot as well.
This has two sets of patterns, depending on whether or not the enemy is present.
it alternates between copying its flag and copying code that will cause the enemy to copy that flag (a weak replicator)it copies its flagMore testing showed a few important concepts:
A+7
shown to be more effective than any other increment (+200 over next best)Observing the simulation graphically via the Java UI helped a lot. Thank you! Below is the new and improved code. I don't think I can do anything more.
sumber
C
that blocked it. Because this bot has a revolving Block based onC
, it will accrue multiple blocks on each of its commands. That makes this bot extra defensive.If
line to a list, keying on theC
variable that called it. So with the 1 Block and 9 If's that execute the Block statement, the bot can get up to 10 Blocks for each line, (taking at least 24*10*10 turns) Perhaps the OP did not convey the simulation correctly.Row Bot
Will move until it finds a robot.
Will set that robot in the same direction as itself.
Will then copy its code into the robot.
This should make a row of "Row Bot" Robots. :)
sumber
If
statements must be capitalized. Second, there should not be spaces on either side of the=
, likeD=*D
.Super Freeze
This bot keeps trying to freeze the bot in front of it until it works, then writes a bunch of flags to random lines, and after 8 turns of that it rotates and moves on to another opponent.
sumber
Byzantine
A highly defensive bot that institutes multiple blocks on its flags and most sensitive instructions, including meta-blocks (i.e. blocks on critical block instructions).
It also moves constantly in unpredictable ways, and plants flags in numerous locations on opponents on a best-effort basis.
Not sure how it will perform, since I can't simulate. But we'll give it a shot. ;)
Disclaimer
I wrote this before being kindly informed by PhiNotPi that conditional logic is cost-free. However, I've decided to leave it in since one can never have too many bots.
sumber
Cadmyllion
"I just entered a bot in the battle royale," I say. "It moves every few turns to prevent attacks by slower bots."
"What do you mean by slower bots?" PhiNotPi asks.
"Bots that are stuck evaluating long chains of conditional logic," I reply.
"'If' statements that redirect to other statements---including other 'if' statements---are all executed on the same turn," says PhiNotPi.
"Sweet massacred rules of assembly code!" I cry. "Who came up with that idea?"
...and thus is the story of how Cadmyllion came about.
Cadmyllion: the bot that happily exploits the surreal ability to evaluate infinitely many conditional expressions in a single instruction... by making pretty much every thing it does conditional.
Code
sumber
Meta Insidious
This bot freezes and then converts opponents into less efficient versions of Sparr's Insidious, which in their turn, will turn opponents into bots that spam flags for me. This is likely the most complex bot I've written and I thus expect it to do terrible, there was no space for blocking and only one flag fitted in the code. Turning a bot into an insidious clone also takes too long.
The biggest challenge was writing the code for the insidious clones in such a way that it works regardless of its position in the bot. The freeze gets removed when I paste the second to last code exactly where the freeze is located, this starts up the opponent just in time.
sumber
Repair and Protect
This bot repairs its own code, while protecting the newly repaired lines.
Explanation:
The initial value of
A
is0
, and the lines are numbered 0-23. If theIf
statement is executed and is false, it does attempt the execute the same line again. The controller does not allow a bot to execute the same line twice, so the turn is ended andC
is incremented to1
.The next line,
Copy #A #A+8
is actually performed regardless of the value of theIf
statement. The difference is that it is executed twice if true and once if false. If the line#A+8
is blocked (which happens eventually), then performing it twice with actually copy, while performing it once will only unblock it. Then, the newly copied line is blocked to preserve it.sumber
A
? Isn't it0
? If so then your first line compare line 0 to line 16, but as I understood from the OP example bot, the first line is line 1, isn't it? Additionaly, still in your first line,#C
refers to this very line, so does it mean that if theIf
statement return false you're stuck in an endless loop?Neutralizer
This bot makes its victim rewrite its entire program, making it worth 0 points. Once the virus is in place, it moves on. This is a scorched earth approach to victory.
The comparison
*#*C==#7
doesn't seems to adjust for the opponent's shift correctly, but the bot does eventually move on.sumber
Copy C+1 C
is all that is needed to skip a single line.Copy 23 C
there instead, to jump back to the first line.Insidious
Inspired by @Cruncher, this bot infects other bots with a small block of code, filling the other bot with this bot's flags. Those bots are then sitting ducks for further attack, but they will be mostly full of my flags when they get re-infected by someone else.
Edit: thanks to @PhiNotPi for golf assistance, @overactor for efficiency advice
sumber
Happy As A Clam
This is an exercise in blocking. It performed remarkably well until
$Copy
came around.The clam has 22 block commands. Because
A
is shifted every loop, they will reference different lines each time through the loop. This allows each command to stack blocks on every other line, maxing out at 22 blocks per line. Thus, to break the fully armored clam, one would need to write to a line 22 times.For example,
#10
will be protected each time through the loop by the following lines:#10
protected by line 7 (7+0+3
=10)#10
protected by line 0 (0+7+3
=10)#10
protected by line 17 (17+14+3
=34=10)#10
protected by line 10 (10+21+3
=34=10)So after Line 10 of Loop 3,
#10
has been blocked 4 times, requiring 4 writes to#10
to break the blocks, with a 5th one to actually overwrite the line.Note that blocks are keyed by their
C
value and will not stack if the protected line was already blocked by the sameC
value. So after 22 blocks are established for each line, the blocks will no longer stack.sumber
MindControl
I guess it's never too late?
MindControl comes from my idea that it would take some considerable time to copy my whole program to the opponent, during which my bot is vulnerable to attacks from other directions. So why not make the opponent copy my program while I scan for enemies?
Once it finds an enemy, MindControl immediately freezes the enemy to prevent escape. Then it uploads the downloader to the opponent and let the victim download MindControl's program itself. The downloader exploit the fact that few bots uses
B
and will loop until it downloads all 24 lines. When the downloader rewrites#19
fromCopy 16 C
toCopy 23 C
, it signifies the victim have downloaded all lines and will go on to reboot itself.The first versions of my bot does not include Blocks. And it was so vulnerable that almost any change is crippling. So I decided to add Blocks based on Wasmoo's $Copy (which is based on COTO's Lockheed). The downside I found is that it is difficult for the original to correct mistakes in the copies. But this is far from crippling and the score increased significantly so I kept the Blocks.
UPDATES
I improved the downloader to keep trying to download until a successful rewrite to circumvent blocks. It does mean it takes one more turn to upload the downloader but my score doubled after this change!! Can't argue with numbers.
Another update. As you may have noticed, MindControl decides whether to attack target by comparing a random line between itself and its target. If they match, MindControl just assumes the target is already infected and leave it alone. (Side note: I used to use a static line for comparison but that gives lots of false positives and negatives) Turns out that gives a lot of false negatives. So I decided to exploit
==
and make some trivial changes likeC+23
to23+C
. The program is functionally identical but different in the eyes of==
. Now that MindControl has no line that is identical to any line in any other bot, it will 100% hit any untouched bot. Again, score increased significantly.Improved the Downloader again. It now runs on a shorter loop. (which seems to have a large correlation with my score)
Improved Downloader yet again. Uses original bot's code so it uploads faster. Also added 2 random blocks which seems to improve score
sumber
Attacker
sumber
Movebot
Like Flagbot, but move around while accepting gifts of code to go with all of our flags.
sumber
Reproducing bot
This bot tries to freeze his opponent and then copy his entire code into that bot before restarting the other bot. This should also work (mostly) if the opponent uses blocking, though that does make it all even slower than it already is.
sumber
Magus
Magus is a simple attempt at a self-propagating virus. It attempts to copy itself into the programs of other bots. (Edited to remove negative numbers, fix condition, trim lines.)
sumber
for (int i = 1; i < 25; i++)
...DNAbot
This bot repairs its own code while moving and attacking.
sumber
Blocker
sumber
Copycat
sumber
Quick freezerbot
Tries to copy flags in the line that will get executed next of his opponent, moves if there is no enemy to attack.
sumber
Block, Freeze, Attack
Blocks all 24 lines, then loops 24 times either moving or attacking, then repeats. An attack involves attempting to freeze the opponent, then copying four flags to random locations, then turning.
sumber
Hide, Block, Attack
This bot is based off of Block Freeze Attack. I changed the placement of some
If
statements to make it more compact allowing me to plant more flags. I also have it run away at the start of a game to buy some time to block.sumber
Roving Virus
This bot wanders until it finds an enemy, then freezes them, replaces all of their code with its own, unfreezes them, then wanders again.
sumber
The common cold
It infects you virtually immediately and you'll spread it around. based on PhiNotPi's Parasite, the common cold checks almost immediately if it can copy its flag over yours. Blocks a random value if it can't. Moves around a bit if there's no opponent.
sumber
Influenza
This is closely based off of the Common Cold (which was based off my Parasite) with slightly increased speed.
sumber
Rebranding
This bot tries to randomly locate flags in enemy bots and replace them with friendly flags, turning away after detecting success. Inspired by Cancer bot.
sumber