Apa yang salah dengan variabel publik?


33

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 Amelalui E. Adan Buntuk penggunaan pribadi, Cmenyimpan baris berikutnya untuk dieksekusi, Dmenyimpan arah saat ini, dan Emerupakan 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:

  1. Flagtidak melakukan apa-apa. Kecuali bagaimana kamu menang
  2. Movememindahkan bot Anda Dke arah th. Jika bot sudah menempati ruang tersebut, tidak ada gerakan yang akan terjadi
  3. Copy Var1 Var2 menyalin isi Var1 ke Var2
  4. If Condition Line1 Line2 Jika kondisi benar, jalankan Line1, kalau tidak Line2
  5. Block Var1 blok tulisan berikutnya pada variabel

Variabel dapat digunakan sebagai berikut:

#Varakan menggunakan variabel sebagai nomor baris. Jika Aberumur 17, Copy #8 #Aakan menyalin isi baris 8 ke baris 17. *Varakan menggunakan variabel lawan Anda. Copy 5 *Cakan mengatur Cvariabel lawan untuk 5 Var+Varakan menambahkan dua variabel. Copy D+1 Dakan memutar bot ke kanan

Saat Ddigunakan sebagai arah, [North, East, South, West][D%4]akan digunakan

Pengubah ini dapat dirantai: Copy *#*C #9akan menyalin baris berikutnya lawan Anda akan mengeksekusi ke kode Anda sendiri pada baris 9. **D mengacu pada Dvariabel lawan lawan Anda .

Suatu kondisi akan dievaluasi sebagai berikut:

  1. Jika Var :
    1. Jika Var AlewatC , itu akan mengembalikan true jika Var bukan nol, kalau tidak salah.
    2. Jika Var D, itu akan mengembalikan true jika ada bot diD arah th, kalau tidak palsu
    3. Jika Var E , itu akan mengembalikan true jika E aneh, kalau tidak salah
    4. Jika Var adalah garis, itu akan mengembalikan true jika itu adalah garis Bendera
  2. Jika Var1=Var2 :
    1. Mengembalikan nilai true jika keduanya A-E , dan sama dengan nomor yang sama
    2. Mengembalikan nilai true jika keduanya adalah garis, dan jenis garis sama
  3. Jika Var1==Var2 :
    1. Mengembalikan nilai true jika keduanya A-E , dan sama dengan nomor yang sama
    2. Mengembalikan nilai true jika keduanya adalah garis, dan identik (Bendera dari bot yang berbeda tidak akan sama)

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 Ifwasiat 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

Blocking 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:

  1. 6837 $ Salin
  2. 3355 Lockheed
  3. 1695 MindControl
  4. 967 Bizantium
  5. 959 AttackOrElse
  6. 743 Cadmyllion
  7. 367 Influenza
  8. 251 TheCommonCold
  9. 226 Magus
  10. 137 HideBlockAttack
  11. 129 RowBot
  12. 123 FastMoveCloneDodge
  13. 112 FastForwardClone
  14. 96 QuickFreeze
  15. 71 Perbaikan dan Perlindungan
  16. 96 SuperFreeze
  17. 93 RovingVirus
  18. 80 ForwardClone
  19. 77 FreezeTag
  20. 68 Palimpseste
  21. 62 BlockFreezeAttack
  22. 51 RushAttackDodge
  23. 46 Blocker
  24. 40 Pembuat Menara
  25. 37 Copycat
  26. 37 Kamikaze
  27. 35 FlagInjector
  28. 33 RandomCopier
  29. 31 Berbahaya
  30. 29 HappyAsAClam
  31. 25 NanoVirus
  32. 21 Nullifier
  33. 19 Nanoviris
  34. 17 BoringCopybot
  35. 16 Movebot
  36. 14 Flagbot
  37. 13 Penetralisir
  38. 12 Kanker
  39. 9 DNAbot
  40. 9 Parasit
  41. 8 MetaInsidious
  42. 8 Rebranding
  43. 8 AdaptiveBot
  44. 8 ReproducingBot
  45. 8 KungFuBot
  46. 5 QuickFreezerbot
  47. 4 Penyerang

1
Saya akan membahas semua ini begitu Java tersedia untuk saya coba.
Wasmoo

2
I'm assuming you have never played Core war. en.wikipedia.org/wiki/Core_War
matt_black

Saya belum memainkannya, tetapi saya membaca sedikit tentangnya saat menulis tantangan ini.
Nathan Merrill

Saya punya patch untuk kontroler Python dan mencoba mendorongnya kembali ke Anda di github ... tapi saya tidak punya izin / tidak terlalu tahu git. Patch mengganti semua "16" dengan "num_lines" untuk memungkinkan akses tulis / lompat ke 8 instruksi terakhir; juga menghapus "max_flag_count = 0" dari kondisi tie di declare_flags (), yang kadang-kadang diberikan dasi dua arah ke bot ketiga.
adipy

1
Any ETA on when the next battle round is going to be run? No rush at all. I'm just curious. Thanks.
COTO

Jawaban:


13

Flagbot

Flag

Why bother doing anything when other bots are going to be nice enough to give me their code?


8

Freeze Tag

Move
If D #3 #2
Copy 23 C
Copy 3 C
Copy #23 *#*C
Copy #21 *#*C+1
Copy #22 *#*C+2
Copy #21 *#*C+3
Copy #22 *#*C+4
Copy #21 *#*C+5
Copy #22 *#*C+6
Copy #21 *#*C+7
Copy #22 *#*C+8
Copy #21 *#*C+9
Copy #22 *#*C+10
Copy #21 *#*C+11
Copy #22 *#*C+12
Copy #21 *#*C+13
Copy #22 *#*C+14
Copy D+1 D
Copy 0 C
Flag
Flag
Copy C+23 C

Trap opponent in a loop, fill him with flags, move on to next opponent.


Copy C+23 C This has to be the most malicious line of code xD.
Cruncher

I'm interested. This may be improvable. Rather than fill them with flags, can you put a loop in them that fills themselves with flags? Or would that not count as your flags?
Cruncher

That's a neat and viable idea, but more complicated. You should write a bot that uses it :)
Sparr

2
Do you know the answer to the last question? Or would that not count as your flags?. Because if they don't count as your own flags, it's definitely not a good solution
Cruncher

@Cruncher you could give them one of your flags and make them copy it, which would count as one of yours.
Sparr

8

Parasite

Why kill other bots? This bot looks through opponent's code and replaces only the flags.

Copy 1 A
Copy E D
Block #A
If *#A #C+3 #C
Copy A+A+A+A+A A
Copy C+19 C
Copy #C+4 *#A
Flag
Copy 1 A
Copy E D
Block #A
If *#A #C+3 #C
Copy A+A+A+A+A A
Copy C+19 C
Copy #C+4 *#A
Flag
Copy 1 A
Copy E D
Block #A
If *#A #C+3 #C
Copy A+A+A+A+A A
Copy C+19 C
Copy #C+4 *#A
Flag

8

$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 the C 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.

Block #C+A 
If D #7 #13        //If [enemy] Copy 0 ELSE block
If D #8 #0         //If [enemy] Freeze 0 ELSE block
If D #9 #6         //If [enemy] FreezeCheck ELSE Inc
Move
Copy 0 C
Copy A+5 A          //Inc
Copy 23 *C          //Copy 0
Copy #10 *#*C+23    //FreezeAttack
If *#*C==#10 #11 #5 //FreezeCheck: If [frozen] GOTO Copy Attack ELSE GOTO [1]
Copy C+23 C         //FREEZE
Copy 13 C           //GOTO Copy Attack
Copy 15 C           //Loop Copy Attack
Block #C+A
Copy D+3 *D             //Copy Attack: Spin Enemy
Copy 0 *B               //Set enemy counter (a la COTO)
Copy #*B+0 *#*C+*B+1    //Copy my lines
Copy #*B+1 *#*C+*B+2    //Copy my lines
Copy #*B+2 *#*C+*B+3    //Copy my lines
Copy *B+3 *B            //Inc counter
If *B==0 #19 #12        //Loop check
Copy D+1 D              //Turn myself

1
I shall bow to your improved design and face you again in the Bots v. 3 competition. ;)
COTO

I honestly believe this was a group effort on everyone's part. This wouldn't exist if it weren't for several bots out there to model off of. Interestingly, the addition of this bot completely reorganized the scoreboard as bots that depended on blocking were broken while others that depended on flag-replacement ascended.
Wasmoo

Can someone summarize, somewhere, the actual behavior of Block and how this bot and Lockheed take advantage of it?
Sparr

Each line can accrue blocks, as described by HappyAsAClam. Most importantly, it does not stack for blocks called with the same C values. Thus, a block can be stacked when called from an If statement, which is the exploit being used here. $Copy breaks blocks (like the clam) by executing Copy on the same line over and over until successful, which gives it an advantage over Lockheed.
Wasmoo

7

Lockheed

My third (and likely final) submission to this particular bot war: the Lockheed Reactor, or "Lockheed" for short.

Block #C+A
If D #C+7 #C+1
Block #C+A
Move
Copy A+5 A
If A==0 #C+12 #C+21
Copy C+17 C
Copy D+3 *D
Copy C+9 C
Copy C+21 C
Copy C+23 C
Copy #C+23 *#*C+2
Copy #C+22 *#*C+1
Copy 0 *A
Copy #*A+C+9 *#*C+*A+1
Copy *A+1 *A
If *A==0 #C+15 #C+17
Copy D+1 D
Copy C+5 C

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.


Blocking a variable multiple times does fail. However, it only fails to block if: You are executing the same line (an 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)
Nathan Merrill

I contest the statement in the OP because the block instruction is keyed to the IP, not the block statement. Thus a single block statement can institute as many as 24 separate blocks on all instructions. I submit that the clause in the OP stating "as long as the second block statement is on a different line of code than your first" should be amended to "as long as a block for pair (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.
COTO

1
This bot is amazing! It combines all of the best concepts into one. It protects itself until it finds an enemy, then it double-freezes the enemy and uploads a copy of itself onto the target before setting it free in the opposite direction. In simulations, I saw one of its copies repair an original that had been damaged. WOW! Great job, COTO!
Wasmoo

6

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.

  • If the enemy is not present, it blocks its lines for 3 turns and then moves.
  • If 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 flag
  • At the end of the loop, it changes to a random direction and continues
  • Most aspects of its code is duplicated

More testing showed a few important concepts:

  • "Turn random" performed dramatically better than "Turn right" (+2700 over alternative)
  • Block increment of A+7 shown to be more effective than any other increment (+200 over next best)
  • "Direct attack" shown to be better than "Weak replicator" (+900 over alternative)
  • Defense of "3-1-2-1" better than other combinations (+200 over next best)
  • Duplicated attack, block, and loop code improves its score (+300 over non-duplicated)
  • Duplicated block increment does not improve its score (+400 over duplicated)

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.

Block #C+A          //Dynamic block for If statements
If D #20 #0
If D #19 #8
If D #20 #23
If D #19 #0
If D #20 #8
If D #19 #23
Copy A+7 A          //Increment dynamic block
Block #C+A          //Dynamic block for If statements
If D #19 #8
If D #20 #0
If D #19 #8
If D #20 #23
If D #19 #8
If D #20 #0
If D #19 #23
Copy E D            //Turn Random
Copy 23 C           //Loop to beginning
Copy 23 C           //Loop to beginning
Copy #22 *#*C+1     //Copy my flag to the enemy's next
Copy #21 *#*C+1     //Copy my flag to the enemy's next
Flag
Flag
Move

This bot did seriously awesome. And you are welcome for the GUI.
Nathan Merrill

I've updated it to include a second loop, which dramatically improved its performance. I also noticed that blocking in Java is based on the C that blocked it. Because this bot has a revolving Block based on C, it will accrue multiple blocks on each of its commands. That makes this bot extra defensive.
Wasmoo

My understanding is that only one block per originating instruction could be established, hence your code above could only establish a single block on any instruction (and it would take a full 24*17 turns to establish a single block on every instruction). If my understanding is wrong, then the language "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." in the OP needs to be amended, because this statement is (frankly) false if Wasmoo's code is able to establish multiple blocks on any instruction.
COTO

@COTO: The Java simulator adds one block per If line to a list, keying on the C 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.
Wasmoo

I've updated the code again to reflect further improving iterations while keeping the core concept. I thought this would be better than flooding the forum with each iteration, such as the switch from Weak Replication to Direct Attack, and Non-Duplicated to Duplicated. If you'd like me to repost my original, I can do so.
Wasmoo

5

Row Bot

Move
If D #7 #0
If D #7 #0
If D #7 #0
If D #7 #0
If D #7 #0
Copy 0 C
If D=*D #9 #8     //If they point in a different direction
Copy *D D           //fix that
If #A==*#A #10 #11  //Did we copy line A already?
Copy A+1 A          //If so, A++
Copy #A *#A         //else, copy it!

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. :)


There are two (easily fixable) problems. First, the If statements must be capitalized. Second, there should not be spaces on either side of the =, like D=*D.
PhiNotPi

This is an awesome idea.
Sparr

Without a flag you aren't going to win.
Paŭlo Ebermann

3
@PaŭloEbermann bots are filled with flags up to 24 lines, so this bot has 12 implicit flags at the end.
Sparr

5

Super Freeze

Move                    // start moving!
Block #E
If D #12 #0             // 8 turns of attack or move
If D #12 #0
If D #12 #0
If D #12 #0
If D #12 #0
If D #12 #0
If D #12 #0
If D #12 #0
Copy D+1 D              // change direction
Copy 0 C                // start over
If *#*C==#23 #13 #14    // if opponent is frozen, give them a flag, otherwise freeze them
Copy #C+13 *#E          // give a flag to opponent
Copy #23 *#*C           // copy freeze line to opponent
Flag                    // 8 flags, one per If above
Flag
Flag
Flag
Flag
Flag
Flag
Flag                    
Copy C+23 C             // this line freezes any bot that executes it

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.


5

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.

Block #A
Block #A+1
Block #A+2
Copy E D
Move
Block #A+3
Block #A+4
Move
Copy #22 *#*C+1
Copy E D
Move
Block #A+5
Block #A+6
Block #A+7
Move
Copy #22 *#23
Block #A+8
Block #A+9
Block #A+10
Copy #22 *#2
Copy A+14 A
Move
Flag
Copy #22 *#*C+12

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.


this bot is winning!
justhalf

4

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

If D #15 #19
Move
If D #16 #20
Copy D+3 D
Block #A
If D #15 #20
Copy A+1 A
If D #16 #1
Move
If D #15 #19
If D #16 #4
Copy E D
Block #A+12
Copy C+10 C
Flag
If *#0==#14 #17 #21
If *#0==#14 #18 #21
If *#*C+1==#14 #18 #22
Copy *C+11 *C
Block #A+6
Block #A+18
Copy #14 *#0
Copy #23 *#*C+1
Flag

4

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.

If D #2 #1
Copy 23 C
Copy #8 *#*C // freeze the opponent
Copy 9 A
Copy #A *#A+*C // copy the next line at the appropriate  line
Copy A+1 A
If A==0 #7 #23
Copy 23 C
Copy C+23 C
If D #C+2 #C+23 // the code for the Insidious clone starts here
Copy C+21 C
Copy C+2 C
If D #C+6 #C+22
If D #C+5 #C+22
If D #C+4 #C+20
If D #C+3 #C+19
If D #C+2 #C+18
Copy E D
Copy #C+7 *#*C
Flag
Copy C+3 A
Copy #C+22 #A
Copy A+1 A
Copy C+21 C // And ends here

That is a clever idea. However, I don't see any Move commands. Does that mean neither your bot nor your spam bot will move?
Wasmoo

The Insidious clones might move depending on what's in the bots original code, due to limited space quite q bit of functionality had to be thrown away to make this even possible with 24 lines. It was more of a mental excercise than anything else really.
overactor

3

Repair and Protect

This bot repairs its own code, while protecting the newly repaired lines.

If #A==#A+16 #C+1 #C
Copy #A #A+8
Block #A+8
Copy A+1 A
Copy E D
Move
Copy #C+1 *#*C
Flag
If #A==#A+16 #C+1 #C
Copy #A #A+8
Block #A+8
Copy A+1 A
Copy E D
Move
Copy #C+1 *#*C
Flag
If #A==#A+16 #C+1 #C
Copy #A #A+8
Block #A+8
Copy A+1 A
Copy E D
Move
Copy #C+1 *#*C
Flag

Explanation:

The initial value of A is 0, and the lines are numbered 0-23. If the If 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 and C is incremented to 1.

The next line, Copy #A #A+8 is actually performed regardless of the value of the If 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.


I'm trying to understand all of you guys bots but I'm stuck. What are the initial value of A? Isn't it 0? 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 the If statement return false you're stuck in an endless loop?
plannapus

@plannapus I added some explanation.
PhiNotPi

3

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.

If D #C+2 #C+3          // A: If [enemy exists] B else C
Copy C+22 C             // GOTO A
If *#*C==#7 #C+4 #C+5   // B: If [enemy was neutralized] D else E
Move                    // C: Move
Copy E D                // D: Turn Randomly
Copy #7 *#*C            // E: Neutralize enemy
Copy C+1 C              // Skip the next line
Copy #C #C+1            // Neutralizing Code [Copy this line to next line]

The comparison *#*C==#7 doesn't seems to adjust for the opponent's shift correctly, but the bot does eventually move on.


Copy C+1 C is all that is needed to skip a single line.
Nathan Merrill

2
'Skip the next line' means your bot is going to spend 16 turns executing flag instructions before continue. You might want to Copy 23 C there instead, to jump back to the first line.
Sparr

'Skip the next line' will only happen if 'GOTO A' was overwritten. There are other ways I can make this bot more offensive and defensive, such as repeating 'A', duplicating the code, and blocking 'GOTO A'. However, if this bot is hit at all, it's pretty much dead anyway.
Wasmoo

3

Insidious

Move
If D #4 #0
If D #4 #0
Copy 0 C
Copy 4 C
If D #12 #11
If D #12 #11
If D #12 #11
If D #12 #11
If D #12 #11
Copy D+1 D
If D #4 #3
Copy #C+8 *#*C
Flag
Copy C A
Copy #C+22 #A
Copy A+23 A
Copy C+21 C

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


Congrats on hitting 2k!
bjb568

3

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:

  • Loop 0, A=0 #10 protected by line 7 (7+0+3=10)
  • Loop 1, A=7 #10 protected by line 0 (0+7+3=10)
  • Loop 2, A=14 #10 protected by line 17 (17+14+3=34=10)
  • Loop 3, A=21 #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 same C value. So after 22 blocks are established for each line, the blocks will no longer stack.

Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Block #C+A+3
Copy A+7 A
Flag

3

MindControl

I guess it's never too late?

Block #C+D
If D #2 #0        // Scan for enemy
If *#E==#E #0 #5  // Attack if necessary
Copy D+5 D        // Turn
Copy 22+1 C       // Repeat
Copy 4+1 C        // ATTACK:
Copy #22+1 *#*C   //   Freeze
Copy #17 *#17     //   Upload the DOWNLOADER
Copy #18 *#18     //
Copy #21 *#19     //
Copy D+2 *D       //   FACE ME!!
Copy 17 *C        //   Start download
If E #0 #13
If E #0 #13
Copy 22+1 C
Flag
Flag
Copy *#B+20 #B+20         // DOWNLOADER
If *#B+20==#B+20 *#20 #19 //
Copy 22+1 C               //
Copy 1+B B                //
Copy 16 C                 //
Flag
Copy 23+C C        // FREEZE

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 from Copy 16 C to Copy 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 like C+23 to 23+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


It's never too late!
Nathan Merrill

I am considering renaming to BrainWash...
TwiNight

Or BunkerBuster after watching the downloader bust through HappyAsAClam the bunker
TwiNight

I had thought of trying this idea of uploading a downloader first, but I couldn't get it as small as you did. Great job! I also love your use of D as the roving block delta; it saves a command and speeds up your design. I'm amazed that a bot without a 'Move' command would work so well. Simulations show bots tend to clump, but I didn't know that would be a winning strategy. And I agree, there is something uniquely satisfying about breaking the clam.
Wasmoo

@Wasmoo Obviously the downloader design requires the bot to stay stationary and it does make bots clump. I like to think of it as roots of a tree that reach out and assimilate other bots in order to grow. But I guess agility is why $Copy and Lockheed beat me.
TwiNight

2

Attacker

Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Copy #E *#*C
Flag

2

Movebot

Move
Copy 23 C
Flag

Like Flagbot, but move around while accepting gifts of code to go with all of our flags.


2

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.

If D #23 #22
Copy 23 C
Copy #18 *#*C
Copy #18 *#*C+1
Copy #18 *#*C
Copy #18 *#0
Copy #18 *#0
Copy 0 *C
Copy 0 *C
Copy 1 A
Copy #A *#*A
If D #12 #14
Copy A+1 A
Copy 9 C
Copy 23 C
Flag
Flag
Flag
Copy C+23 C
Copy D+1 D
Flag
If *#*C==#*C #19 #13
Move
If *#*C+1==#*C+1 #21 #13

No spaces in the condition
Nathan Merrill

@NathanMerrill gotcha
overactor

2

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.)

Block #A
Copy #A *#A
Copy A+1 A
If A #0 #4
Copy 0 *C
Flag
Move
Copy 0 C

Negative values are not allowed. Please use 23 for B
Nathan Merrill

Please use 23, not 25.
Nathan Merrill

Unless I'm misunderstanding, that would cause it to not block or copy lines 23 or 24 (note: it's changed slightly from the first revision, A is incremented by 1, not B)
Isaac

+0 = 24 +1 = 25, -1 = 23. If you want it to be -1, it should be 23.
Nathan Merrill

That's how it was before, because I thought you could only compare with 0 (missed the '=' part somehow, I blame skimming), but it's changed now so A starts at 1 and ends at 25. Just imagine line 3 as for (int i = 1; i < 25; i++)...
Isaac

1

DNAbot

Flag
Copy 8 D
Copy 16 B
If #D==#B #C+2 #C+3
Block #A
Copy #D #A
If D #7 #15
Copy #23 *#*C
Copy A+1 A
Copy B+1 B
Copy D+1 D
If #D==#B #C+2 #C+3
Block #A
Copy #D #A
If D #7 #15
Move
Copy A+1 A
Copy B+1 B
Copy D+1 D
If #D==#B #C+2 #C+3
Block #A
Copy #D #A
If D #7 #15
Flag

This bot repairs its own code while moving and attacking.




1

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.

Block #13
Block #14
If D #13 #14
If D #13 #14
If D #13 #14
If D #13 #14   
If D #13 #14
If D #13 #14
If D #13 #14
If D #13 #14
If D #13 #14
If D #13 #14   
Copy 23 C
If E #15 #16
Move
Copy #23 *#*C
Copy D+1 D

The first two lines are invalid. They need #13 and #14
Nathan Merrill

1

Block, Freeze, Attack

Block #A        // start block loop
Copy A+1 A      // loop A from 0 to 23
If A #3 #4      
Copy 23 C       // repeat block loop
Copy 5 C        // exit block loop to attack/move loop
Move
If D #11 #5     // attack or move
Copy A+1 A      // loop A from 0 to 23
If A #9 #10
Copy 5 C        // repeat attack/move loop
Copy 23 C       // exit attack/move loop to block loop
Copy 11 C       // start of attack routine
Copy #23 *#*C   // freeze opponent
Copy #19 *#E    // copy flag to opponent
Copy #20 *#E    // copy flag to opponent
Copy #21 *#E    // copy flag to opponent
Copy #22 *#E    // copy flag to opponent
Copy D+1 D      // change direction
Copy 5 C        // repeat attack/move loop
Flag
Flag
Flag
Flag
Copy C+23 C     // freeze instruction, for copying

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.


1

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.

Copy D+1 D
Move           //buy some time by moving to a more secure location
Block #A+2
Copy A+1 A
If A #11 #17
Copy #23 *#E
Copy #22 *#E
Copy #21 *#E
Copy #20 *#E
Copy #19 *#E
Copy D+1 D
Copy 1 C
Move
If D #14 #15
Copy 3 C
Copy 11 C
Copy #18 *#*C
If D #16 #15
Copy C+23 C
Flag
Flag
Flag
Flag
Flag

1

Roving Virus

If D #6 #16
Move
Copy 23 C
Flag
Flag
Flag
Copy 6 C
Copy A+23 A
Copy #A *#A                     //clone previous line to enemy
Copy 23 *C                      //freeze enemy
If A #6 #16                     //loop or turn then continue
Copy 0 *C                       //reboot enemy
Copy 23 C                       //start moving again
Flag
Flag
Flag
Copy D+1 D                      //turn
Flag
Flag
Flag
Flag
Flag
Flag
Copy 22 C                       //freeze instruction

This bot wanders until it finds an enemy, then freezes them, replaces all of their code with its own, unfreezes them, then wanders again.


1

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.

Block #22
If D #8 #5
If D #8 #5
If D #8 #5
Copy 23 C
If E #6 #7
Copy D+1 D
Move
If *#E=#22 #15 #9
If *#E+1=#22 #16 #10
If *#E+2=#22 #17 #11
If *#E+3=#22 #18 #12
If *#E+4=#22 #19 #13
If *#E+5=#22 #20 #14
If *#E+6=#22 #21 #23
Copy #22 *#E
Copy #22 *#E+1
Copy #22 *#E+2
Copy #22 *#E+3
Copy #22 *#E+4
Copy #22 *#E+5
Copy #22 *#E+6
Flag
Block #E

1

Influenza

This is closely based off of the Common Cold (which was based off my Parasite) with slightly increased speed.

Move
Block #23
If D #8 #0
If D #8 #0
If D #8 #0
If D #8 #7
Copy 0 C
Copy D+1 D
If *#E #9 #10
Copy #23 *#E
If *#E+1 #11 #12
Copy #23 *#E+1
If *#E+2 #13 #14
Copy #23 *#E+2
If *#E+3 #15 #16
Copy #23 *#E+3
If *#E+4 #17 #18
Copy #23 *#E+4
If *#E+5 #19 #20
Copy #23 *#E+5
If *#E+6 #21 #22
Copy #23 *#E+6
Block #E
Flag

I look forward to seeing the sort of difference this will make. The #5 on line 5 will provoke an infinite loop though, and those #7's are also unlikely to be what you intended.
overactor

@overactor Thanks, those were errors created by adding in an extra line.
PhiNotPi

Do I ever know the pain.
overactor

1

Rebranding

Move
If D #10 #0
If D #10 #0
If D #10 #0
If D #10 #0
If D #10 #0
If D #10 #0
If D #10 #0
If D #10 #0
Copy 0 C
If *#E=#14 #11 #9
If *#E==#14 #13 #12
Copy D+1 D
Copy #14 *#E
Flag

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.

Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.