Robot Racing

Introduction

Welcome to the Robot Race guide!

In the first section I teach you some strategies necessary for the code I used! I also have advice for cracking the level.

I recommend looking at the bottom of the tips section, at the major spoiler if you want to solve the level quickly.

In the second section I do a walk through showing the code and including explanation.

I solved the level in 14 moves. I believe it can be done in 13 as well.

Important to note: the game counts the challenge as failed even if the 64-255 bytes are 0 and the code overflows. Thus, your code must include either a jump or a return.

Using Complex Functions, Also Tips.

For this section, you will find how to use techniques. All the way at the bottom of this section is MAJOR spoilers if you don't want to put to much effort in but still want to solve it.

First the AND function.

Manipulate counter sequences using AND!

Code broke? Use AND to fix it!

XOR

MUST USE XOR. SERIOUSLY. WHOLE LEVEL. XOR. XOR. (secret) For XOR, consider XOR with a register rather than an immediate value.

WHAT IS THE AND FUNCTION?

The AND function takes the highest value it can reach using the other input that is below the value. It is easier for me to think of ANDing something as its bits, such as instead of 11, it being (8+2+1).

AND is really good for choosing certain spots in sequences to modify at the same time. For example, if we have a counter giving the sequence:

0123

4567

89ab

cdef

If I AND the counter value with (4+1), it would give me

0101

4545

0101

4545

I could then use a line such as If value=4, set to 2, to make the sequence

0101

2121

0101

2121

USING THE AND FUNCTION: MODIFYING SEQUENCES

First, using a Counter, Constant, and a 8-bit AND together, hook up the Counter and Constant to the And, set the Constant to 2 or 3, watch what happens to the output.

Here is a spoiler if you just want to read what happens:

The output of the And will be the sequence 00220022, repeating 0's and X's by X times each. For numbers with multiple bits like 3, it would be a combination of

01010101

00220022=

01230123

USING THE AND FUNCTION PART 2

Lets say you had your AND function set up to 3 so it output

0123

0123

0123

0123

But you wanted it to output

0022

0022

0022

0022

(HINT: don't these 0022's look familiar?)

How would you turn your sequence into the desired sequence?

Answer: And with 2

USING THE AND FUNCTION PART 3

Here's a harder one. Feel free to just read the solution, this one is really tough and meant to teach you how to transform your data how you want to.

Lets say I again had my AND function set up to 3, but this time, I wanted to flip the 1 bit of some of the bits in the last row. How could you do that in 2 lines of additional code?

0123

0123

0123

0123

0123

0123

0123

1032

(HINT: your counter value would be at

0123

4567

89ab

cdef)

Answer: If value from counter less than 12, jump to skip

XOR value of calc by 1 to calc

label skip

USING THE AND FUNCTION: TESTING YOUR AND

Lets say I again had the AND and counter set to 3,

0123

0123

0123

0123

But I wanted the first 0 in the first 2 rows to be 2s.

2123

2123

0123

0123

How would you do that in 3 lines of code?

Solutions Option 1: AND counter by 8 and 2 and 1

(counter original:

0123

4567

89ab

cdef

After AND:

0123

0123

89ab

89ab

If calc not equal to 0, jump to skip

XOR value with 2

skip

Option 2:

If counter=0, go to true

If counter=4, go to true

true

XOR value with 2

Did you get through all that? This 'chieve is a big jump from the previous ones. Good job if you managed to solve them without clicking the spoilers.

XOR:

This is major spoilers, but this is something the game doesn't really talk about and the whole level revolves around this idea. You may skip this spoiler, but you will have a very hard time if you do.

https://steamuserimages-a.akamaihd.net/ugc/2423571107071734902/90E309F6D916DE10715FD1967FBF81328A19DBA6/?imw=256&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false

This diagonal cross represents XOR something by 3, and XOR something by 1.

When you XOR something by 1, you change the 3 into a 2 and a 2 into a 3, or a 1 into a 0 and 0 into a 1. This makes it alternate between up/left, and down/right, creating the up/left-down/right diagonal.

Reciprocally, when you XOR something by 3, you change the 3 into a 0 and 0 into a 3, or a 1 into a 2 and 2 into a 1. This makes it alternate between up and right, or down and left, forming the down/left-up/right diagonal.

Instead of looking at the level in straight lines, it might reveal something if you looked at the path diagonally.

I will give you time to think about what I write, and after reading, you should click the next spoiler. These spoilers are very light spoilers, that are more for a back-and-forth, rather than major information.

The map:

To start, you will want to just look at the level layout.

https://steamuserimages-a.akamaihd.net/ugc/2423571107071612764/F6D7408BB2AD28E2AC8A7FDD03990DB5CEA42745/?imw=256&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false

When done viewing, click this:

Notice the four big squares in each quadrant? Look in those squares, notice anything else?

Same as before:

You will also notice in each big square, there is a 4 smaller squares in each of them.

These small squares hold a secret that you will learn shortly, and are what your entire code will likely be built upon.

What part of the square do you start in? Do you notice a pattern? Recall the XOR tip from earlier, this is where it comes in handy.

Final spoils: the first 2 moves of each square are either diagonal up-right, or diagonal down-left, since the beginning of each square is either the top right or bottom left corner. What XOR do you use for moving to the top right and bottom left?

FINAL FINAL HINT:

(If you only used XOR for movement from the previous move, you would need this map for XORs. Create this sequence from a counter that counts every output!)

3311

0311

3311

3310

3311

0311

3311

3310

0311

0311

3311

3311

0311

0311

3310

3310

My Code + Explanation

These are the preset codes

#Arg/Results

const aR0 0

const aR1 1

const aR2 2

const aR3 3

const aR4 4

const aRam 5

const aPAdd 6

const aIn 7

const aOut 7

#Opcodes

#Immediates

const i2 64

const i1 128

const i12 192

#Functions

const qJump 32

const fAdd 0

const fSub 1

const fAnd 2

const fOr 3

const fNot 4

const fXor 5

const fMult 6

const fDiv 7

#Functions2

const fCall 16

const fReturn 17

#Ramcodes

const rArg1 8

const rCall 9

const rInc 10

const rSaveInc 11

const rSetInc 12

const rOutRes 13

const rAutoSet 14

const rAutoTog 15

#Conditionals

const cE 32

const cIE 33

const cL 34

const cLE 35

const cG 36

const cGE 37

#[counter]: counts which output we are on

#[other]: other values used in calc

#[calc]: where we calc our output

const counter aR0

const other aR1

const calc aR2

const output aOut

label start

qJump+i2

counter

(47)

true

qJump+i2

counter

(16)

true

qJump+i2

counter

(0)

true

fAnd+i2

counter

(8+2+1)

other

qJump+i2

other

(11)

false

qJump+i2

other

(0)

false

label true

fAnd+i2

counter

2

other

fXor+i2

other

3

other

qJump+i1+i2

0

0

true2

label false

fXor

calc

other

calc

label true2

fXor

calc

other

calc

fAdd+i2

calc

0

output

fAdd+i2

counter

1

counter

qJump+i1+i2

0

0

start

Explanation:

This is a chart of XORs to the previous movement value you need to do to solve the level.

3311

0311

3310

3310

3311

0311

3310

3310

0311

0311

3310

3311

0311

0311

3310

3310

The goal of my code, is to

A: Repeatedly XOR 3311 with the calc as a sequence

B: XOR 0's with 0 immediately (I do this by XOR by the same value twice)

However this is written more efficiently by moving B before A, and Skipping B if it make grouping easier.

True represent 3's or 1's that kind of ruin the pattern of the 0's, so I jump past the skip function.

False represents the 0's that disrupt the pattern, they effectively XOR the output by 0, by XORing the output by the same value twice.

The sequence 3311, was made by first ANDing the counter by 2, turning 01234567 into 00220022

I then XOR the sequence by 3, turning 00220022 into 33113311.

I then skip the sequence when the address is 0.

I believe this code could be made more efficient, mostly by utilizing the jumps differently, but for the most part this code is extremely efficient.

That's the end of the guide, happy coding.

Source: https://steamcommunity.com/sharedfiles/filedetails/?id=3174578385					

More Turing Complete guilds