Funtion Functionality in Staredit

Post Reply
Tojso09
Terran Academy Student (50k mineral debt)
Terran Academy Student (50k mineral debt)
Posts: 5
Joined: Sat Feb 10, 2007 8:34 pm

Funtion Functionality in Staredit

Post by Tojso09 »

I don't know if this will be helpful to anybody, but I believe I have
found a way to execute functions using Starcraft trigger logic.
This includes multiplication, division, and exponents where all
inputs and results are integer.

For example, in my arena map that I am creating, I plan to use
the equation 3(3x/4)2/2+6 as the enemy group spawn
count.

The only problem I see with this set of triggers is the amount of time
it takes for the game to execute the number of commands I plan to
use in the triggers. However, I read on another forum for Staredit and read of
hypertriggers that allow the processes to read much faster than normal,
so I think that these triggers will work realistically in a map.
User avatar
Lingerance
Terran Refinery Attendant
Terran Refinery Attendant
Posts: 20
Joined: Fri Aug 24, 2007 7:46 am
Location: St. Albert

Re: Funtion Functionality in Staredit

Post by Lingerance »

Somehow I believe the functionality to be dependent on the state of a large amount of switches followed by an even greater amount of triggers to implement each arithmetical operation.  I hope the required code (provided my assumptions are correct) is at the very least generated by a script of some sort.  Although I must admit if somehow you designed it to mimic the way a CPU handles words (32-bit CPU have 4 byte words, 64-bit have 8 byte words afaik) I would be very impressed, even if the result is unmaintainable.

Alternatively; for addition spawn one marine in location 0 subtract one from custom if custom >= 1, to add a second number set custom again.  Then to find the total do the opposite, remove one marine add one custom if marine count at location 0 >= 1.  Multiplication is basically an addition of one number by counts of a second (8x3 == 8+8+8).
Subtraction: for the second number create zerglings, if (count of marines >= 1 AND count of zerglings >= 1) then remove one zergling and one marine add 1 custom.  The difference if whatever is left of the single type.
Division: No clue.
Exponent: Multiplication of Multiplication, see addition and multiplication.

Out of curiosity, how did you do it?
Last edited by Lingerance on Mon Mar 31, 2008 7:40 pm, edited 1 time in total.
Penguin?
The asterisk pony plays poker every Tuesday except after Mondays and only if the moon is pink.  His tell is he will always bluff while wearing a plaid tutu, the clouds are never monochromatic, catch them while white and fluffy, the black ones taste like robots.
Tojso09
Terran Academy Student (50k mineral debt)
Terran Academy Student (50k mineral debt)
Posts: 5
Joined: Sat Feb 10, 2007 8:34 pm

Re: Funtion Functionality in Staredit

Post by Tojso09 »

Finally, a response! I had almost given up hope.

I actually have not tested this at all in Staredit, but I am 80% sure it might work. I've tried stuff like this before and had it blow up in my face.

I believe it is possible to do the function I described in roughly 10-12 switches, 12-15 triggers, and 5 placeholder values (variables don't really exist in Staredit, just values. That's what makes it so tricky!) The five placeholders are wave (x term), countdown, temp1, temp2, and total.
This is for quite complex equations like the one I posted, one that uses each function multiple times (except square/exponent). I'm not sure if adding another countdown placeholder value will allow for exponents to come into play (I won't explain in this post, I need to look into it further).

Addition of an unknown and a known is simple, just add the value desired.
Addition of two unknowns is done by decreasing one value at the same rate that another increases, inverse for subtraction.

Multiplication of an unknown value and a known value would be decreasing at a different rate than other increases.
Multiplication of two unknowns (x and z), assuming you bring in another value not mentioned (not temp, countdown or total), this could be done by starting off with both unknowns at their original value.
1.) Subtract 1 from one of the unknowns and add one to one of the temp variables and the total.
2.) Subtract one from the other unknown and add it to the other temp value
3.) Repeat step 1, except add to the unknown and subtract from the temp
4.) Repeat steps 1-3 until the second unknown is 1 or 0
5.) Reset the unknowns if they need to be.

Division is integer division only. For example, 8/4=2,  9/4=2, 10/4=2, 11/4=2, 12/4=3. The remainder is held on one of the temp placeholders and can be used, otherwise you can erase it with a single trigger.
Division of an unknown and a known is done the opposite way of multiplication. In multiplication, you could subtract 1 from a value and add three to the total, thus multiplying by 3, dividing works in the opposite, subtract 3 from the value and add 1 to the total. Repeat until value is less than divisor.
Division of two unknowns, I have yet to figure out, but I will work on it.

I actually wrote out the 15 triggers that go through the function and it may be possible to shorten either the number of triggers, or the number of switches. Unless I get another inquiring response, I probably won't post them since they still need to be tested for validity.

sorry it's so long, but I wanted to explain as thoroughly as I could, feel free to ask any questions.
Last edited by Tojso09 on Sun Apr 13, 2008 10:01 am, edited 1 time in total.
Post Reply