Discuss Scratch

MegaApuTurkUltra
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

MegaApuTurkUltra wrote:

1st place: MartinBraendli's Spamela & HugoTheHedgehog
He tells me he has a challenge idea already!

2nd place: CodeLegend's STINGerla

3rd place: TheMonsterOfTheDeep's Snipar

(Thanks TheMonsterOfTheDeep for the medals)

Full results here: https://docs.google.com/spreadsheets/d/1v6Ju2EOpOMio7FpGXbxEPvtHGt3_d9izopxMFg_2VIs/edit?usp=sharing

Regardless of which bots won, I hope everybody had some fun making these, despite all the controller bugs. Congrats on learning a new language and doing some “l33t hax”

We'll be waiting for Martin's ATC#4!


Welcome to the second third Advanced Topics Challenge! The winner of the challenge, as per (recently begun) tradition, will be allowed to place this beautiful Round 3 medal in their signature:



The winner of the challenge will then be able to either create the next challenge or select someone else to do it for them.
Previous ATCs: #1 | #2

This is inspired by a PPCG challenge I can't find anymore.

Link to the controller for this challenge: http://aputurk.tk/ATC-3-Controller/
GitHub repo: https://github.com/MegaApuTurkUltra/ATC-3-Controller

The Goal
Get as many points as possible by hacking bots!

Quick Facts
  • Challenge type: King-of-the-hill (see the codegolf.stackexchange.com tag for examples)
  • Language: MATU's custom bot language
  • Time frame: ~1 week (final submissions due Monday July 18, 11:59:59 PM)
  • Winner: Whoever's bots have the most combined tags after final submissions are run
  • Submission modifications allowed: yes (see constraints)
  • Multiple submissions allowed: yes (see constraints)

The Field
Bots play on a 100x100 grid. Only one bot may occupy a space at a time. Bots move 1 step at a time, either North, South, East, or West. If a bot tries to move into another bot's space, nothing happens. If a bot moves off the edges of the field, they are wrapped onto the other side.

Playing The Game
On start, 10 bots for each submission are placed randomly on the field. (Number may change in the future)

Bot programs have the following variables available (separate for each bot instance)
  • DATA1: Custom use
  • DATA2: Custom use
  • EXECUTION_POINTER: Which line of the code to execute next. Defaults to the next line mod 32. 1-indexed
  • DIRECTION: Which direction the bot is facing. 0: N, 1: E, 2: S, 3: W. Always taken mod 4
  • RANDOM: A random integer from 1 to 32 inclusive
Additionally, data may be stored on program lines as invalid instructions are ignored.
Programs are limited to 32 lines

On each turn, bots will run their next line of code (the execution order of bots each turn is randomized). This can be one of:
  • MOVE. This moves the bot in DIRECTION. Use SET DIRECTION RANDOM before to move in a random direction.
  • SET <VAR|LINE> VALUE. This sets a variable or line of code
  • IF <VAR|LINE|VALUE> <EQUALS|LESSTHAN|GREATERTHAN> <VAR|LINE|VALUE> <LINENUMBER1> <LINENUMBER2>. Executes the line numbered LINENUMBER1 if the condition is met, otherwise executes LINENUMBER2. Does not affect EXECUTION_POINTER by itself. Example: IF DATA1 LESSTHAN 5 10 11 if data1 is less than 5, run line 10, otherwise run line 11
  • PROTECT <VAR|LINE>. Protects the specified variable or line from the next attempt to set it. Protects do stack, and do not prevent the bot itself from writing. Example: PROTECT @DATA1 protects the line specified by DATA1. PROTECT EXECUTION_POINTER protects the execution pointer.
  • TAG. Gets you points.
Notes:
- Parameters are space-separated.
- Once an instruction has all of its parameters, anything afterwards will be ignored (it's a comment)
- Any lines that don't start with a valid instruction name are ignored

The game will be played for 5,000 turns. Then, the total points for each bot type are added up, and the submission with the most combined points wins! (I may potentially decide to average over multiple matches, or play noncompetitive rounds with a few bots I've developed )

Accessing Data
Number literals are accepted in lines. String literals are not (use lines instead).
Putting the name of a variable somewhere where the syntax accepts it will retrieve the value of that variable for the bot. Thus
SET EXECUTION_POINTER 1
is an infinite loop.

Using @ before a value of some sort will retrieve the line specified by the value (lines are 1-indexed).
@10        line 10
@RANDOM a random line
@@10 line specified by the number on line 10

Three arithmetic operators are parsed before anything else in a value specification (precedence is %-+)
SET EXECUTION_POINTER 2+2        go to line 4
SET EXECUTION_POINTER 10-6 same
SET EXECUTION_POINTER RANDOM%4 mod random number
Operators may not have spaces before or after them, otherwise the parser will count it as 2 different tokens.
Parentheses are also supported
SET EXECUTION_POINTER (RANDOM+2)%3+1    exactly what it looks like :P

Here's the key part. You'll want to pay attention
The operator * switches the scope of access to an adjacent bot. Adjacent is defined as any bot not of your type in the DIRECTION your bot is facing. If the closest bot in that direction is of your type, it is as if there is no bot in that direction. If there is no bot found, any operation with the * operator does nothing.
SET *EXECUTION_POINTER 10    set opponent's execution pointer to 10
SET *@10 @10 copy my line 10 to opponent's line 10
SET **EXECUTION_POINTER 10 set the opponent's opponent's execution pointer to 10 (it may be you!)
IF *@12 EQUALS @12 5 6 if opponent's line 12 matches mine, run line 5, otherwise run line 6
Note: Accessing other bot variables will return -1 if there is no bot there. You can use this in an IF to test for bots to hack.

Using TAG
When your code has the TAG instruction in it, the instruction is implicitly associated with your bot type. (So every submission that wants to win should have a tag ). You can have multiple TAG instructions if you want.

When you copy your TAG instruction to another bot (not of your type, since you won't find any of those), your bot type gets a point. Also, that bot now has your tag. That means if you manage to nab the line where it stores its own tag, you can get it to spread your tag instead! Whenever any bot copies your tag, your bot type gets a point.
For clarity I'll be using line numbers in the following code
bot1:
1  SET *@3 @2
2 TAG
bot2:
1  MOVE
2 SET *@RANDOM @3
3 TAG
If bot1 successfully “hacks” bot2, bot2 will now be spreading bot1's tags and increasing bot1's points.

However, when your tag is removed from another bot's code, you lose a point. That is, points are counted by the total number of tags you have on other bot types.

Using PROTECT
PROTECT can either protect a variable or a line specified by @. You can only protect your own variables and lines. Protects do stack, but do note that if you spend too much time stacking protects you're not going to have enough time to move!
PROTECT EXECUTION_POINTER     protect exec ptr
PROTECT @2 protect line 2
PROTECT @EXECUTION_POINTER protect next line to execute
PROTECT @*DATA1 protect line specified by enemy DATA1

Guidelines for Submitting
Usually on PPCG king-of-the-hill challenges, bots have unique strategies and fun names. Make your best effort to do both
For examples, you can browse king-of-the-hill tagged posts.

Making changes to your submission: Changes are allowed before the deadline with the following constraints:
- The overall strategy should not be overly different. For example, a bot that has a primary strategy of protecting all of its lines and variables should retain that overall strategy in modifications.
- You should add your modification to a new code block in the post containing the original submission. Keep all revisions. (This is just for my ease of browsing).

Multiple submissions: If you see a bot that you think you could improve, or think of a new strategy, you can make another submission with the following constraints:
- If it's a derivative or uses pieces of code from somebody else, give credit
- If it's specifically designed to interact with somebody else's bot, give credit
- Separate submissions should each be in their own post and have their own unique name

Submit in the following format:
[big]Submission: <Name>[/big]
[code]
Bot code goes here
[/code]

Revision 1
[code]
If you have a revision, it goes here
[/code]

etc

Example
Submission: BasicBot
SET DIRECTION RANDOM
MOVE
SET EXECUTION_POINTER 1 repeat
TAG maybe this will magically get somewhere :P

Loopholes and Control Program Exploits
This is a challenge for programmers, not lawyers. If you find a loophole or an exploit in the control program (very likely), let me know. Nobody will have fun if you exploit it.
Additionally, if there's something that you think may be unintended behavior of the control program, and it's hindering your ability to make a submission, let me know too

Good luck and may the best l33t haxx0r win! :D

Last edited by MegaApuTurkUltra (July 20, 2016 02:15:40)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
TheMonsterOfTheDeep
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

Oh man - this is awesome! I've always thought koth things are really cool

Sadly I don't think I'm going to have time to do it - I'm really busy this summer with work and stuff.

But I think this challenge is really well put together - it has the right amount of limitations to really foster creativity.

my latest extension: 2d vector math
joefarebrother
Scratcher
500+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

Wow, interesting!

Will different tag instructions compare the same way? For example, if bot 1 was facing bot 2, and bot 1's code was something like

IF @2 EQUALS *@1 3 4
TAG
MOVE
SET DIRECTION RANDOM

and bot2 was just

TAG

then would bot 1 run line 3, or line 4? That is, would the two tags be treated the same, or different as they are from different bots?





And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
joefarebrother
Scratcher
500+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

OK, a few problems in the controller code:

- On line 34, there's a ReferenceError: i is not defined, this is encountered when replacing a bot
- I was TypeError: document.querySelector(…) is null; turned out it was because there were spaces in my bot name so selecting “#” + bot.name + “ .tags” wasn't working properly, you should probably escape the strings
- It appears that in the parseValue() function, lines starting with TAG are stripped of their actual tag. Wouldn't this make it impossible to actually copy tour tag to an opponent?
- If an IF statement calls itself, a stack overflow occours


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
kvackkvack
Scratcher
500+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

We're allowed to test our bots multiple times with the controller without submitting them here, right?
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

-ignore-

Last edited by jokebookservice1 (July 12, 2016 12:16:28)

jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

Just to check, if a bot is not found, then the command will be ignored, right?

Last edited by jokebookservice1 (July 12, 2016 12:15:32)

CodeLegend
Scratcher
500+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

jokebookservice1 wrote:

Just to check, if a bot is not found, then the command will be ignored, right?
“If the closest bot in that direction is of your type, it is as if there is no bot in that direction. If there is no bot found, any operation with the * operator does nothing.”

I have a question - is your tag command equal to an opponent's tag command?
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

Question: What order do the bots run their scripts each tick?
IcyCoder
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

I am really confused what do we do?
edit: Wait now I get it! Maybe this is one I can win!

Last edited by IcyCoder (July 12, 2016 12:41:55)


Because JS is the future (echos) future future futur futu fut fu f
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

IcyCoder wrote:

I am really confused what do we do?
MATU linked to a site, http://aputurk.tk/ATC-3-Controller/ , there you write a script in a language MATU made up, which will play against other contestants, the script has the power to “hack” other bots.

I'm making a virus!
joefarebrother
Scratcher
500+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

jokebookservice1 wrote:

Question: What order do the bots run their scripts each tick?
In a random order


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

joefarebrother wrote:

jokebookservice1 wrote:

Question: What order do the bots run their scripts each tick?
In a random order
Ok, thanks!

I am making a virus!
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

It alternates between the bots, so an infinite loop doesn't stop other bots, right?
IcyCoder
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

OK now I am ready after I fully figure out the syntax

Because JS is the future (echos) future future futur futu fut fu f
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

What happens if it has two tags of different types?
iamunknown2
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

So it's basically a challenge which allows you to rewrite your opponent's bot? That sounds pretty cool to me.

I have a strategy. I call it the Zemo strategy.

Guess why… :P


Edit: It won't work…

Last edited by iamunknown2 (July 12, 2016 13:01:41)


| My website | Using Geany | A Christian | Running Ubuntu MATE 14.04 with Flash 18.0 (release 0) | Search this with quotation marks on Google to view my posts: “ellipsepostpianolizard” (some posts may not show up) |

Moving on from Scratch? Learn Python/a scripting language (e.g Perl, JavaScript), then move on to a C derivative
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

iamunknown2 wrote:

So it's basically a challenge which allows you to rewrite your opponent's bot? That sounds pretty cool to me.

I have a strategy. I call it the Zemo strategy.

Guess why…
I googled it, is that bad…

Anyway, mine overwrites the entire code of another bot!
jokebookservice1
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

How do I test if mine works?
iamunknown2
Scratcher
1000+ posts

[ATC#3] So you say you're a "hacker"? Prove it!

jokebookservice1 wrote:

iamunknown2 wrote:

So it's basically a challenge which allows you to rewrite your opponent's bot? That sounds pretty cool to me.

I have a strategy. I call it the Zemo strategy.

Guess why…
I googled it, is that bad…
Explanation:
SPOILERS FOR CIVIL WAR BELOW - HIGHLIGHT TO READ

At the end of the movie, Zemo leads Tony Stark (Iron Man) into fighting with Steve Rogers (Captain America), tearing the Avengers apart

I thought that you wouldn't be able to attack someone with your tag, and that others would be lead into fighting your opponent instead of you.

Last edited by iamunknown2 (July 12, 2016 13:05:35)


| My website | Using Geany | A Christian | Running Ubuntu MATE 14.04 with Flash 18.0 (release 0) | Search this with quotation marks on Google to view my posts: “ellipsepostpianolizard” (some posts may not show up) |

Moving on from Scratch? Learn Python/a scripting language (e.g Perl, JavaScript), then move on to a C derivative

Powered by DjangoBB