Set Core Parameters via CRPL

Started by thepenguin, April 20, 2013, 08:07:09 AM

Previous topic - Next topic

thepenguin

are the parameters in the double-click menu on the core changeable via CRPL?

For example:
Creates Power Zone
Supports Digitalis
Counts for victory
Nullifier damages
We have become the creeper...

Grauniad

A goodnight to all and to all a good night - Goodnight Moon

thepenguin

#2
Never mind, just found the commands that work to do this. (setunitattribute)

Although there is no command to take XY? I would have expected exponents to be included in CRPL...

I'll just have to write my own power script...
We have become the creeper...

J

#3
Unit attributes can do all those things, but not everything works all types of units (createpz doesn't work on player units, maxammo doesn't work on cores).
X^Y, use 'dup mul' for X^2, 'dup dup mul mul' = X^3, 'dup mul dup mul' = X^4... Just need an interesting way to do the in a do- or while-loop (remember there's a command 'rotate' which changes the order of three items on the stack (took a look at the docs and it's not listed))

knucracker

I'll add a pow command. It is just an oversight that I didn't add that.  Basically any math command available in .NET I can likely easily expose.  So if you see something else, just let me know.

thepenguin

#5
Quote from: virgilw on April 21, 2013, 09:40:17 AM
I'll add a pow command. It is just an oversight that I didn't add that.  Basically any math command available in .NET I can likely easily expose.  So if you see something else, just let me know.
1. square root
2. logarithms (particularly natural log, but if you could implement "(number) (base) log" as a command, that would be even better (although everyone who knows enough to be able to use logarithms will also know how to use change of base and so it's not a big deal))
3. you already have PI, but not euler's number (e), or the exponential function ex (which with the power command are interchangeable)

P.S. Can someone fix those redlinks on the CRPL reference on the wiki
We have become the creeper...

knucracker

Quote from: thepenguin on April 21, 2013, 12:57:17 PM
Quote from: virgilw on April 21, 2013, 09:40:17 AM
I'll add a pow command. It is just an oversight that I didn't add that.  Basically any math command available in .NET I can likely easily expose.  So if you see something else, just let me know.
1. square root
2. logarithms (particularly natural log, but if you could implement "(number) (base) log" as a command, that would be even better (although everyone who knows enough to be able to use logarithms will also know how to use change of base and so it's not a big deal))
3. you already have PI, but not euler's number (e), or the exponential function ex (which with the power command are interchangeable)

P.S. Can someone fix those redlinks on the CRPL reference on the wiki

Those red links are because I've not written help pages for those links yet.  I'll fill them in shortly (when I return to story missions and star sweeping over CRPL getting it ready for release).

thepenguin

Quote from: virgilw on April 21, 2013, 08:34:23 PM
Quote from: thepenguin on April 21, 2013, 12:57:17 PM
Quote from: virgilw on April 21, 2013, 09:40:17 AM
I'll add a pow command. It is just an oversight that I didn't add that.  Basically any math command available in .NET I can likely easily expose.  So if you see something else, just let me know.
1. square root
2. logarithms (particularly natural log, but if you could implement "(number) (base) log" as a command, that would be even better (although everyone who knows enough to be able to use logarithms will also know how to use change of base and so it's not a big deal))
3. you already have PI, but not euler's number (e), or the exponential function ex (which with the power command are interchangeable)

P.S. Can someone fix those redlinks on the CRPL reference on the wiki

Those red links are because I've not written help pages for those links yet.  I'll fill them in shortly (when I return to story missions and star sweeping over CRPL getting it ready for release).
okay, I figured out what most of them do (arguments and results) just by trial and error.
We have become the creeper...

knucracker

You could also save off the first story mission, then create a project and put the save it in.  That would extract out the scripts I wrote for that first story world.  It uses those new CRPL commands to show the tutorial messages (that mission is why I had to add them).

thepenguin

Quote from: virgilw on April 22, 2013, 10:41:01 AM
You could also save off the first story mission, then create a project and put the save it in.  That would extract out the scripts I wrote for that first story world.  It uses those new CRPL commands to show the tutorial messages (that mission is why I had to add them).
I never knew that you could just extract scripts from maps like that...  If I knew I probably would have grabbed a bunch of scripts from Aether instead of writing my own to do similar things. (although needing to do this for a map has introduced me to a lot of advanced CRPL that I needed a reason to learn)
We have become the creeper...

thepenguin

#10
also max, min, floor, and ceiling

and I have previously seen a random function that has a distribution based on a normal (bell-shaped) curve (given center and standard deviation) that could be used to create "realistic populations" of objects.
We have become the creeper...

knucracker

For a normal random distribution you can cheap out and simply add three uniform random values in the range of -1 to 1.  You can also add 12 uniform random values in the range of 0 to 1, then subtract 6.  There are fancier named things you can do, but here is a link to the most pragmatic site I could find:
http://www.protonfish.com/random.shtml

thepenguin

#12
Quote from: virgilw on April 22, 2013, 07:31:53 PM
For a normal random distribution you can cheap out and simply add three uniform random values in the range of -1 to 1.  You can also add 12 uniform random values in the range of 0 to 1, then subtract 6.  There are fancier named things you can do, but here is a link to the most pragmatic site I could find:
http://www.protonfish.com/random.shtml
I heard about the adding of 3 numbers to make it work out, but never understood why it works (or how, for that matter), and so dismissed it as internet mythology...

also max, min, floor, and ceiling can be added in as custom software functions, so I guess there is little need for them builtin (though it would be nice and save some time...)
We have become the creeper...

Kithros

Quote from: thepenguin on April 22, 2013, 10:08:30 PM
Quote from: virgilw on April 22, 2013, 07:31:53 PM
For a normal random distribution you can cheap out and simply add three uniform random values in the range of -1 to 1.  You can also add 12 uniform random values in the range of 0 to 1, then subtract 6.  There are fancier named things you can do, but here is a link to the most pragmatic site I could find:
http://www.protonfish.com/random.shtml
I heard about the adding of 3 numbers to make it work out, but never understood why it works (or how, for that matter), and so dismissed it as internet mythology...

also max, min, floor, and ceiling can be added in as custom software functions, so I guess there is little need for them builtin (though it would be nice and save some time...)

I think things like adding the random numbers together would probably give a decent approximation of a normal distribution - but I don't see it as being possible to actually be equal to the normal distribution except  *maybe* in a limit of adding infinite random numbers together (which is still completely impractical to actually use anyway).

The obvious way to disprove the adding 3 numbers between -1 and 1: A normal distribution would have some probability (albeit fairly small) of giving a value greater than 3, and it's impossible when adding those 3 numbers to get anything greater than 3.


Honestly, I'm not really sure why you would ever need to approximate the normal distribution in code anyway for CW3.

knucracker

I'd only every used the "add 12 numbers then substract 6" method.  The add 3 (in the range of -1 to 1) sounds like a hatchet job approximation.

http://dualibra.com/wp-content/uploads/2011/10/Numerical_Methods_of_Statistics__Cambridge_Series_in_Statistical_and_Probabilistic_Mathematics_.pdf

Bottom of page 309.  This describes the other better techniques, with  Box-Muller being the one you find on most web sites.

But, like you say, there aren't too many times you would need to do this in a custom map (unless you are making a function or histogram plotter using walls on a flat map :) )