Staredit Network

Staredit Network -> UMS Assistance -> Mathematical functions
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-28 at 15:29:21
QUOTE
would you mind explaing how using the higher binary values is better than using the lower orginal values? mind giving an example?


Um okay.

For example look at this binary countoff that starts at 2^5

32
16
8
4
2
1

That covers a range from 1 to 63 in 6 triggers.

The range grows exponentially the bigger your countoff is.
Report, edit, etc...Posted by Kookster on 2006-07-28 at 16:55:38
Dang this stuff is complicated, i get what your trying to do, but how you do it, you GOT ME!!!!
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 18:49:41
QUOTE(MoonlighTurtle @ Jul 28 2006, 01:28 PM)
Um okay.

For example look at this binary countoff that starts at 2^5

32
16
8
4
2
1

That covers a range from 1 to 63 in 6 triggers.

The range grows exponentially the bigger your countoff is.
[right][snapback]533543[/snapback][/right]


so, you're saying 1, 2, 4, 8, 16, 32 = 1,2,3,4,5,6,7,8,9,10,11,12,13,14... 61,62,63?

i thought it was more like:

1 = 1
2 = 2
3 = 4
4 = 8
5 = 16
6 = 32

is there some written material i can read about this?
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-28 at 19:04:34
You should take a look at Tuxedo-Templar's Binary calculator map to see exactly how a binary countoff looks.

QUOTE
so, you're saying 1, 2, 4, 8, 16, 32 = 1,2,3,4,5,6,7,8,9,10,11,12,13,14... 61,62,63?

i thought it was more like:

1 = 1
2 = 2
3 = 4
4 = 8
5 = 16
6 = 32


No, you can make any number from 1 to 63 by adding one of those powers of 2. The binary countoff tries to subtract powers of two.

Ill expand upon my example

Pretend x represents a death counter with a value from 1 to 63
The binary countoff works like this

Can I subract 32? If yes, do it
Can I subract 16? If yes, do it
Can I subract 8? If yes, do it
Can I subract 4? If yes, do it
Can I subract 2? If yes, do it
Can I subract 1? If yes, do it

And after that, x will be 0.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 19:10:02
so, all binary cutoffs are trying to do is be more efficient?
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-28 at 19:12:50
QUOTE
so, all binary cutoffs are trying to do is be more efficient?


Yes, they are MUCH more efficient. Just take a look at Tuxedo-Templar's binary calculator map, and tell me how else you can do mathematical functions like adding, subtracting, multiplying, and dividing with user input. Binary countoffs are the core of working with death counters that act as variables.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 20:38:43
QUOTE(kookster @ Jul 28 2006, 02:55 PM)
Dang this stuff is complicated, i get what your trying to do, but how you do it, you GOT ME!!!!
[right][snapback]533604[/snapback][/right]


haven't done anything yet, lol

QUOTE(MoonlighTurtle @ Jul 28 2006, 05:12 PM)
Yes, they are MUCH more efficient. Just take a look at Tuxedo-Templar's binary calculator map, and tell me how else you can do mathematical functions like adding, subtracting, multiplying, and dividing with user input. Binary countoffs are the core of working with death counters that act as variables.
[right][snapback]533708[/snapback][/right]


ya... i really hate looking at others people's maps lol, especially tux's tongue.gif


the maximum value in my grid is 29. doing some math:

apparently, 29 = 268,435,456. is that even a valid input number for starcraft?


ADDITION:
ps, is the math right?
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-28 at 20:42:12
QUOTE
ya... i really hate looking at others people's maps lol, especially tux's tongue.gif


Binary countoffs are characterized by long sets of blank commented triggers, because if you have seen what a binary countoff is you would notice that they are all essentially the same trigger except for the difference in the power of 2. Blank comments are the easiest way to organize them and keep them as small as possible. Giving each a unique comment is a waste of time.

Also grid systems such as triggers dealing with finding x and y also can be characterized by blank comments for the same reasons as binary countoffs.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 21:23:45
QUOTE
Anyway, lets start off easy: Addition. If you wanted to, say, add Minerals and Gas and store the result in the Custom score, all you need to do is use two Binary Countoffs for minerals and gas, seperately, and append each countoff amount to the custom score until both gas and minerals equal 0, and you're done! It should be instantaneous if you set your Binary Countoff powers of 2 large enough.


3+2

4m 2g

if mins = 4
set mins to 0
custom + 3

custom = 3

0m 2g

if gas = 2
set gas to 0
custom + 2

custom = 5


is this how it works, for addition? sorry for taking so long to learn this, but thanks for your time anyways.

ADDITION:
looking at tux's map, it looks more like this.

3+2

4m 2g

subtract min, add to custom

custom = 4

0m 2g

subtract gas, add to custom

custom = 6


i can't actually find where it converts the cutoff value into the proper values. nor can i find where it converts the original min amount into cutoff values.
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-28 at 23:10:19
In a basic count off process, the modifier Set to isn't used. It's mostly subtract, and then adding if you want to store the values.

I'll expand upon my example even more.

x is a death counter again, and this time we will add a y death counter.

The question is being asked for x.

Can I subract 32? If yes, then subtract that from x and add to y
Can I subract 16? If yes, then subtract that from x and add to y
Can I subract 8? If yes, then subtract that from x and add to y
Can I subract 4? If yes, then subtract that from x and add to y
Can I subract 2? If yes, then subtract that from x and add to y
Can I subract 1? If yes, then subtract that from x and add to y

And after that, x will be 0, with any value of x from 1 to 63 being added to y.

That's basic addition using a binary count off.

> Removed double post
Report, edit, etc...Posted by Zeratul_101 on 2006-07-28 at 23:52:59
can you give me a step by step explanation of what happens with addition?

ADDITION:
QUOTE(MoonlighTurtle @ Jul 28 2006, 09:09 PM)
The question is being asked for x.

Can I subract 32? If yes, then subtract that from x and add to y
Can I subract 16? If yes, then subtract that from x and add to y
Can I subract 8? If yes, then subtract that from x and add to y
Can I subract 4? If yes, then subtract that from x and add to y
Can I subract 2? If yes, then subtract that from x and add to y
Can I subract 1? If yes, then subtract that from x and add to y
[right][snapback]533900[/snapback][/right]


after that phase, there'd be?:

asking Y:

Can I subract 32? If yes, then subtract that from y and add to 6 to 'answer' DC
Can I subract 16? If yes, then subtract that from y and add to 5 to 'answer' DC
Can I subract 8? If yes, then subtract that from y and add to 4 to 'answer' DC
Can I subract 4? If yes, then subtract that from y and add to 3 to 'answer' DC
Can I subract 2? If yes, then subtract that from y and add to 2 to 'answer' DC
Can I subract 1? If yes, then subtract that from y and add to 1 to 'answer' DC

is that what would happen?
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-29 at 00:13:07
- Previous explanation replaced by the following paint story -


I have made a little story in Paint to illustrate the binary countoff.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-29 at 00:53:20
okay, thanks alot, i get it now. it works cause instead of counting off by 1s, it counts off in much larger numbers.

last question is in my post above yours. a simply yes or no will do. once again, thanks for all the help.

ADDITION:
lmfao, awesome comic
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-29 at 00:53:47
No.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-29 at 01:06:00
well, i was hoping for a yes, lol, since you said no, how does it get converted back into a normal number/value
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-29 at 02:04:31
Through another binary countoff. What you posted:

QUOTE
asking Y:

Can I subract 32? If yes, then subtract that from y and add to 6 to 'answer' DC
Can I subract 16? If yes, then subtract that from y and add to 5 to 'answer' DC
Can I subract 8? If yes, then subtract that from y and add to 4 to 'answer' DC
Can I subract 4? If yes, then subtract that from y and add to 3 to 'answer' DC
Can I subract 2? If yes, then subtract that from y and add to 2 to 'answer' DC
Can I subract 1? If yes, then subtract that from y and add to 1 to 'answer' DC

is that what would happen?


If you are subtracting 32 from y and only adding 6 to the answer death counter you are missing 26. Then if you are subtracting 16 and adding 5 you are losing another 11. Then if you are subtracting 8 and then only adding 4 you are losing another 4. If you are subtracting 4 and only adding three you are losing 1.

What you subtract has to be added to another value, or else you won't end up with a correctly transferred value.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-29 at 02:14:35
nvm now, i get how the triggers and stuff work now. i was under the impression that numbers were converted up into binary cutoff format after they were inputted and converted down, after finishing all the calculations.

for example, when i put in 10 in the calculator map, i thought the value(10) was converted into 512. i know better now blushing.gif .

explains why i couldn't find the 'raise up' and 'lower down' triggers. wallbash.gif

i understand how addition works, i'll ask for help with divide, multiply if really need it.

ADDITION:
ps thanks for putting up with my incompetence

ADDITION:
i noticed tux put in a maximum death count for his binary countoff trigs. is it necessary or beneficial?
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-29 at 02:18:42
QUOTE
i noticed tux put in a maximum death count for his binary countoff trigs. is it necessary or beneficial?


Personally, I don't and I haven't had any problems. There really isn't any need because of the order of the triggers. I'm assuming you're talking about in each of the trigger's conditions in the binary countoff, as in the condition with "at most".

I do recommend however, that you have some sort of check before hand, or make your binary countoff large enough to cover the range of numbers you are going to use. For example a binary countoff starting with 2^5 (32), can only account for any value between 1 and 63. Anything higher than 63 will result in there being leftover in the death counter after it has gone through the binary countoff.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-29 at 02:41:58
well, my maximum value is 29, so i don't think i'm gonna have a problem with that. for future reference for the remainder problem, if i loop it, then that'll fix the problem right?

someone really needs to write a tutorial about this

ADDITION:
lol, damn, now i have to redo my whole map...

ADDITION:

two Q:

whats a good trigger importer/exporter?

and

whats the maximum death count you can input?
Report, edit, etc...Posted by MoonlighTurtle on 2006-07-29 at 03:01:54
QUOTE
well, my maximum value is 29, so i don't think i'm gonna have a problem with that. for future reference for the remainder problem, if i loop it, then that'll fix the problem right?


Well, the point of the binary countoff is so that it finishes in one trigger cycle, and thats why it's based on powers of 2. It shouldn't need to go through more than one trigger cycle as long as the death counter is within the range accounted for by the countoff. And in some systems it's important that it does finish in one trigger cycle.

There is only a remainder if the death counter is, for example, 64 in a binary countoff that only goes up to 2^5. Making the binary countoff start at 2^6 would instantly solve that, increasing the range exponentially.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-29 at 03:02:52
QUOTE(MoonlighTurtle @ Jul 29 2006, 01:01 AM)
Well, the point of the binary countoff is so that it finishes in one trigger cycle, and thats why it's based on powers of 2. It shouldn't need to go through more than one trigger cycle as long as the death counter is within the range accounted for by the countoff. And in some systems it's important that it does finish in one trigger cycle.

There is only a remainder if the death counter is, for example, 64 in a binary countoff that only goes up to 2^5. Making the binary countoff start at 2^6 would instantly solve that, increasing the range exponentially.
[right][snapback]534061[/snapback][/right]


k, good point. now, to put it to use for reducing slopes.
Report, edit, etc...Posted by Kenoli on 2006-07-29 at 06:32:17
QUOTE(Zeratul_101)
whats the maximum death count you can input?
Death counts range from -2147483648 to 2147483647. (2^32)
Report, edit, etc...Posted by Zeratul_101 on 2006-07-29 at 11:28:35
what editor can you input that in? scmd2 classic trigedit only allows me to input 9 digits
Report, edit, etc...Posted by Kenoli on 2006-07-29 at 12:36:04
That's just the range a death count can hold.

If for some reason you needed to use add/subtract more than 999999999 you can just use multiple set deaths actions.
Report, edit, etc...Posted by Zeratul_101 on 2006-07-30 at 00:07:36
QUOTE(in_a_biskit @ Jul 28 2006, 04:01 AM)
Hm.  Just a quick comment about reflecting off "easy angles"...

Suppose you're moving initially with slope y/x (to the top right in the following example):
CODE
Example
         * }
      o  x } y = 1
   o     x }
oxxxxxxxxx }
~~~~~~~~~~
   x = 3
              (slope = 1/3)


If you now reflect off a horizontal surface, the new slope will be (-1)/3 - that is, y goes to -y.

If you reflect off a vertical surface, the new slope will be 1/(-3) - that is, x goes to -x.

If you reflect off a surface at 45 degrees (sloping up to the right):
CODE

            *
           ox
               - (slope line should be 45deg)
              -
          o x- } y2 = 3
            -
           -
         *-xx  } x2 = 1  (new slope = 3/1)
      o  -
   o    -x
oxxxxxx-xx (original slope = 1/3)
      -
     -

The new slope is 3/1 - that is, x goes to y, and y goes to x.

Hopefully you can see that if the slope were at 135 degrees (sloping upwards to the left), the new slope would be (-3)/(-1) - that is, x goes to -y and y goes to -x.

Any other angle is really very tricky to reflect off.
[right][snapback]533230[/snapback][/right]


well, i did some work and found out that everytime a slope hits a vertical surface, it switches its X integer and the same goes for the Y integer when it hits a horizontal surface. i'm not sure if this was what you were trying to tell me or not. my system keeps track of the X and Y values independently, so 'difficult' slopes shouldn't be so difficult.
Next Page (2)