EXAPUNKS

EXAPUNKS

View Stats:
Um... Clamping?
I must be misunderstanding something or have missed something, because apparently clamping is a big part of this, but I have no idea what clamping means. It's mentioned in the first zine once, and I can't figure out exactly what it means or how to work it into my code. Help?
< >
Showing 1-10 of 10 comments
You use SEEK to move your cursor around in a file. If you want to move ahead 1, you type SEEK 1. If you want to move back 3, you type SEEK -3. In other words, SEEK is relative to your cursor's current position.

Note that there is no built-in way to set your cursor to the beginning of the file or the end of the file. There's no SEEK BEGINNING or SEEK END. As you play more, you will notice that you really want to be able to do both of these things from time to time. When you want to go to the beginning of your file, SEEK -9999. When you want to go to the end of your file SEEK 9999.

You might expect doing this to cause the EXA to halt because there isn't enough room in the file to go back -9999 or go forward 9999 (e.g. throwing something like a "no such file location" error). Clamping means that, instead of the EXA halting, it knows to stop at the first value or the last value.

EDIT: Clamping also comes into play with registers. If you ADDI two numbers and the sum is greater than 9999, the sum clamps at 9999 instead of overflowing or throwing an error and halting. Same for the reverse direction with SUBI.
I'm stuck on the first bio-hacking mission. My understanding is that SEEK only clamps if numbers range outside of the -9999 or 9999 range, but I need to clamp the values within a specific range. And I am absolutely lost. Show Goal doesn't help in the slightest.
I just looked at that one (Mitsuzen HDI-10, Left Arm) and I see they refer to clamping in the instructions. I recall being stuck on that wording before.

To clarify, clamping basically means "don't allow any values beyond a certain point." Extending my SEEK example above, when you tell the EXA to SEEK -9999, you are asking it to move the cursor from position X to position (X minus 9999). Unless X is 9999, you are telling the EXA to go to a position before position 0 which is impossible. This will cause the EXA to clamp your position to 0.

In other words, if the position result of your SEEK is less than 0, throw that value out and call it 0 instead.

To translate this to the mission: make sure the output is always between -120 and 50, inclusive. If the input is ever less than -120, the output should be -120. If the input is ever greater than 50, the output should be 50. Otherwise, the output should be the same as the input.

Hint in math terms:

If X < -120, output 120
If X > 50, output 50
Else, output X.


Hope that helps.
Lord de Seis explained it pretty well. In this context, it just means 'level out' at these values.

Now, the easy way to 'level out' a value is with a TEST.

The efficient way to do it, makes use of the fact that the registers themselves 'clamp' (i.e. level out) at -9999 and 9999.
I've got it now, thank you for the help!

My confusion was mostly due to the fact that the term "clamping" is never actually explained in the zine, and the only mention of it is in the SEEK description. Therefore, I assumed that I was supposed to be using SEEK, but couldn't for the life of me figure out a viable option with that.

I ended up looking up a guide, but I lost a couple days of playing with that. xD
Originally posted by moribund:
I just looked at that one (Mitsuzen HDI-10, Left Arm) and I see they refer to clamping in the instructions. I recall being stuck on that wording before.

To clarify, clamping basically means "don't allow any values beyond a certain point." Extending my SEEK example above, when you tell the EXA to SEEK -9999, you are asking it to move the cursor from position X to position (X minus 9999). Unless X is 9999, you are telling the EXA to go to a position before position 0 which is impossible. This will cause the EXA to clamp your position to 0.

In other words, if the position result of your SEEK is less than 0, throw that value out and call it 0 instead.

To translate this to the mission: make sure the output is always between -120 and 50, inclusive. If the input is ever less than -120, the output should be -120. If the input is ever greater than 50, the output should be 50. Otherwise, the output should be the same as the input.

Hint in math terms:

If X < -120, output 120
If X > 50, output 50
Else, output X.


Hope that helps.
in your maths hint is the first equation ouput suppose to be positive or negative?
Originally posted by evil bob:
in your maths hint is the first equation ouput suppose to be positive or negative?
It's supposed to be compliant with negative requirements.
another way to clamp numbers, that doesn't rely on condition, is to find the difference between highest available number & clamp, then add & subtract it from your value.

example, highest available number is 9999, high clamp is 50, difference is 9949.
if your value is 1:
1 + 9949 - 9949 = 1
but if your value is 82:
82 + 9949 - 9949 = 50
because 82 + 9949 = 9999 capped

same goes for the low clamp, but you have to use lowest number and subtract first.
lowest num -9999, clamp -120, difference 9879
-5 - 9879 + 9879 = -5
-144 - 9879 + 9879 = -120

so if you go:
your_val + 9949 - 9949 - 9879 + 9879 = your_val clamped -120 +50
Originally posted by mala:
another way to clamp numbers, that doesn't rely on condition, is to find the difference between highest available number & clamp, then add & subtract it from your value.

example, highest available number is 9999, high clamp is 50, difference is 9949.
if your value is 1:
1 + 9949 - 9949 = 1
but if your value is 82:
82 + 9949 - 9949 = 50
because 82 + 9949 = 9999 capped

same goes for the low clamp, but you have to use lowest number and subtract first.
lowest num -9999, clamp -120, difference 9879
-5 - 9879 + 9879 = -5
-144 - 9879 + 9879 = -120

so if you go:
your_val + 9949 - 9949 - 9879 + 9879 = your_val clamped -120 +50

This is an elegant solution.
Originally posted by mala:
another way to clamp numbers, that doesn't rely on condition, is to find the difference between highest available number & clamp, then add & subtract it from your value.

example, highest available number is 9999, high clamp is 50, difference is 9949.
if your value is 1:
1 + 9949 - 9949 = 1
but if your value is 82:
82 + 9949 - 9949 = 50
because 82 + 9949 = 9999 capped

same goes for the low clamp, but you have to use lowest number and subtract first.
lowest num -9999, clamp -120, difference 9879
-5 - 9879 + 9879 = -5
-144 - 9879 + 9879 = -120

so if you go:
your_val + 9949 - 9949 - 9879 + 9879 = your_val clamped -120 +50

PERFECT, i never understood how to do it without conditionals. this is amazing
< >
Showing 1-10 of 10 comments
Per page: 1530 50