View Full Version : SE4 Scripting in Python (templatizer again)
Ed Kolis
July 13th, 2004, 06:54 AM
This might not sound very impressive, but I just wrote a program that can negate a number... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
Why'd you do that, you might ask? Well, I'm working on an expression evaluator. OK, you ask again, why are you doing THAT? Well, this expression evaluator is going to be used in a sort of Uber-Tech-Gridder program which combines the flexibility of editing text files (ask Gandalf Parker or any other Linux junkie http://forum.shrapnelgames.com/images/icons/icon12.gif ) with the power of something like Krsqk's Component Generator. OK, it won't generate tech *grids* - it will only work in one dimension - but there will be a lot of flexibility; basically you will be able to do what Aaron's promised for SE5 with the SE4 data files - something like this:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Start Level := 1
End Level := 12
Name := Anti - Proton Beam [level]
Description := Focused energy beam used as a medium range weapon.
Pic Num := 18
Tonnage Space Taken := 30
Tonnage Structure := 30
Cost Minerals := [50 + 25 * level]
Cost Organics := 0
Cost Radioactives := [10 + 10 * level]
Vehicle Type := Ship\Base\Sat\WeapPlat\Drone
Supply Amount Used := 5
Restrictions := None
General Group := Weapons
Family := 2000
Roman Numeral := [level]
Custom Group := 0
Number of Tech Req := 1
Tech Area Req 1 := Energy Stream Weapons
Tech Level Req 1 := [level]
Number of Abilities := 0
Weapon Type := Direct Fire
Weapon Target := Ships\Planets\Ftr\Sat\Drone
Weapon Damage At Rng := [max(15 + level * 5 - range * 10, 0)]
Weapon Damage Type := Normal
Weapon Reload Rate := 1
Weapon Display Type := Beam
Weapon Display := 1
Weapon Modifier := 0
Weapon Sound := apbeam.wav
Weapon Family := 1</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">And the beauty of my approach is that it will apply not only to Components.txt, but also to Facility.txt and anything else you might want to have leveled items! http://forum.shrapnelgames.com/images/smilies/cool.gif" src="images/icons/cool.gif" />
Now I know that I'm not easily motivated to work on something past the first night, but I know that this program is something that the SE4 community would greatly appreciate (at least I'd think you would!) so please keep bugging me to finish it! (Or at least release the code so someone else can http://forum.shrapnelgames.com/images/icons/tongue.gif )
edit: changed topic from "Semi-OT: I just negated a number! (Really, this is interesting! ;-)" to "Math parser ready (not the data file generator - yet!)"
changed topic to "SE4 Templatizer Ready for Download!"
edit: changed topic to "Templatizer 3 is HERE!!!!!"
[ July 25, 2004, 05:52: Message edited by: Ed Kolis ]
Atrocities
July 13th, 2004, 07:30 AM
I just program in basic. I hear binary is easy too, but is owned by Microsoft so that is ruled out.
narf poit chez BOOM
July 13th, 2004, 08:13 AM
Negate a number? As far as I know, a number is an imaginary creation designed to represent Groups or singles of something. ??
Fyron
July 13th, 2004, 08:32 AM
Will it support all sorts of funky math? Exponents, sin, custom user defined functions, etc.?
Ed Kolis
July 13th, 2004, 05:19 PM
I'm hoping to basically put in anything that's in the .NET math library, so exponents and sines should be in. As for user-defined functions, I wasn't planning for them, but if you want to add functions, the program is designed to be extensible so you can code them yourself if you know a .NET language such as C# http://forum.shrapnelgames.com/images/icons/icon10.gif Basically, I have an Expression class with subclasses for all the different types of expressions there can be (unary operations, constants, functions, etc.) and to add a function you'd have to derive a class from one of my base classes and implement its Value property which does the actual computation.
If I ever get this working I'll post it on www.codeproject.com; (http://www.codeproject.com;) my main problem is to get the input string parsed out into an expression tree... but I've read about converting to Reverse Polish Notation and that should prove helpful with everything except the functions... and the (non-user-defined) functions shouldn't be too much after that, it's just a matter of getting them to take multiple parameters...
Fyron
July 13th, 2004, 06:56 PM
User defined functions are necessary to prevent having to put the same formula code in 700 entries... http://forum.shrapnelgames.com/images/icons/icon12.gif
Ed Kolis
July 13th, 2004, 07:14 PM
Hmm, that might be doable if I just had a separate functions.txt listing all the functions and what they evaluate to; they'd just be evaluated Last in the precedence order, I guess...
hobospecialist
July 14th, 2004, 05:37 AM
no offense, but that's kinda like my program, i woulda posted it up, but i couldn't, here's the link to the topic:
http://www.shrapnelgames.com/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=23;t=011057#000000
btw, only works for non-weap components (i got bored making it, so i stopped)
narf poit chez BOOM
July 14th, 2004, 05:47 AM
Originally posted by narf poit chez BOOM:
Negate a number? As far as I know, a number is an imaginary creation designed to represent Groups or singles of something. ?? <font size="2" face="sans-serif, arial, verdana">I wasn't trying to be funny, I want someone to explain the topic name.
Ed Kolis
July 14th, 2004, 06:13 PM
Negating a number means turning 5 into -5, or -3 into 3, or whatever - basically subtracting it from zero.
narf poit chez BOOM
July 14th, 2004, 09:14 PM
Negate: 1. To render ineffective or void; nullify. 2. To deny; contradict; rule out.
Well, I suppose it fits under contradict. http://forum.shrapnelgames.com/images/icons/icon7.gif
Fyron
July 14th, 2004, 10:03 PM
The negative of a number nullifies it. To negate a number, to nullify it. The null number is 0.
[ July 14, 2004, 21:05: Message edited by: Imperator Fyron ]
narf poit chez BOOM
July 15th, 2004, 01:51 AM
True, but the described operation is 0 - n, where n is the number. The operation you describe is n + (0 - n).
Kamog
July 15th, 2004, 02:18 AM
This works too. How about the operation -1*n where n is the number
Ed Kolis
July 17th, 2004, 02:25 AM
Time for a progress report! http://forum.shrapnelgames.com/images/icons/icon10.gif
The calculator part of the application is coming along great; currently, it can negate, add, subtract, multiply, divide, exponentiate, and take modulos, exponents, percentages, and factorials! http://forum.shrapnelgames.com/images/icons/shock.gif
What's left to do:
-Add in variables
-Add in mathematical functions (sin, log, sqrt, and stuff like that)
-Add in user defined functions (if I can - Fyron wants 'em and it shouldn't be TOO hard, just string replacement http://forum.shrapnelgames.com/images/icons/icon12.gif )
-Add in functions that return strings, not just numbers (if I can - would be useful for generating Roman numerals for components)
-Finally, write the application that parses the SE4 data file templates and generates the actual data files! http://forum.shrapnelgames.com/images/icons/shock.gif
Ed Kolis
July 19th, 2004, 03:30 AM
Oops, forgot to mention that I needed to add parentheses... Well, I just finished adding those! http://forum.shrapnelgames.com/images/icons/icon10.gif
BTW, will anyone be needing functions that take multiple parameters? I could easily implement single-parameter functions as unary operators and not write proper functions, and that would save me a bit of time with the parsing of parameters, but if you really want them... http://forum.shrapnelgames.com/images/icons/icon12.gif
Aiken
July 19th, 2004, 04:08 AM
Originally posted by Ed Kolis:
BTW, will anyone be needing functions that take multiple parameters? I could easily implement single-parameter functions as unary operators and not write proper functions, and that would save me a bit of time with the parsing of parameters, but if you really want them... http://forum.shrapnelgames.com/images/icons/icon12.gif <font size="2" face="sans-serif, arial, verdana">Well, why not. The more - the better http://forum.shrapnelgames.com/images/icons/icon12.gif
But if it's too time consiming (multiparam functions)...don't bother with it now. Save it for future Versions http://forum.shrapnelgames.com/images/icons/icon7.gif
Ed Kolis
July 19th, 2004, 04:52 AM
I'll see what I can do then http://forum.shrapnelgames.com/images/icons/icon12.gif
BTW, I just added 4 more operators:
The "to" operator generates random numbers in a specified range, so 1to6 simulates rolling a normal six-sided die.
The "d" operator acts like in many roleplaying games, rolling multiple dice; 3d6 rolls up a number from 3 to 18 with most values in the 8 to 12 range. http://forum.shrapnelgames.com/images/icons/icon6.gif
Note that these random generators will NOT allow you to generate random damage for weapons in SE4; it will just generate random numbers in the data files. Which might at least be good for a surprise game if you can keep yourself from peeking at the tech tree http://forum.shrapnelgames.com/images/icons/icon12.gif
The other two are really statistical operators, but I figured I'd throw them in because I'd already done factorials - the "P" operator calculates permutations while the "C" operator calculates combinations, if you happen to know (or care) what those are... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
Ed Kolis
July 20th, 2004, 01:28 AM
Time for another progress report! http://forum.shrapnelgames.com/images/icons/icon10.gif
I added variables today - actually, they're really just named constants, as the program can't perform symbolic manipulations on them. (Though I wonder how hard that would be given what I've set up so far... http://forum.shrapnelgames.com/images/icons/icon12.gif ) I added 3 built-in variables: pi, e, and c (the speed of light). Any more you might want?
I also added the "E" operator, which does scientific notation, e.g. 3E6 means 3 million.
All that's left now is those pesky functions (and those aren't really even crucial, as long as I can do the single-parameter ones as unary operators) and then I can start incorporating the SE4 files into a client program for this app! http://forum.shrapnelgames.com/images/icons/icon6.gif
Ed Kolis
July 23rd, 2004, 02:11 AM
Almost there... these functions are just getting annoying because I have to basically copy and paste my wrapper classes for one standard math library function to the next... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
Aiken
July 23rd, 2004, 06:58 AM
Ed, what's ETA for release?
Edit: feature requests
1. bit of OOP http://forum.shrapnelgames.com/images/icons/icon7.gif
2. Conditions.
3. Comment sign.
Together it could look like this:
if (Cost Minerals.Antiproton Beam (level-1))>1500
// do something
else
exec format c:
I can't imagine any application of these features, probably they're completely useless here http://forum.shrapnelgames.com/images/icons/icon7.gif (except comments), but nevertheless it's cool http://forum.shrapnelgames.com/images/icons/icon12.gif
[ July 23, 2004, 06:46: Message edited by: aiken ]
Ed Kolis
July 23rd, 2004, 09:16 PM
ETA for release? Probably sometime early next week, or sooner if I feel especially motivated... I've just got two more functions to add to the parser (assuming I don't think up more! http://forum.shrapnelgames.com/images/icons/icon10.gif ) and after that I have to make it integrate with the SE4 files, but I already have some code that loads SE4 files, so that shouldn't be too hard...
OOP, conditionals, and comments? Hmm, that's a bit beyond the scope of what I was planning - all I really was going to do was have something that's basically identical to the SE4 data files (in fact you could pass in an SE4 data file and it would output it right back, not that that would be useful http://forum.shrapnelgames.com/images/icons/tongue.gif ) but with a few extra fields - Min Level, Max Level, Weapon Min Range, and Weapon Max Range come to mind. Then in most of the fields you could put in equations in square brackets and they would be substituted for you and based on the Min Level and Max Level, you'd get multiple SE4 data entries for each entry you supply to my program. I guess conditionals might be possible if I put in boolean operations, but right now I have everything set up as type double, which might have been a mistake - if I ever want to make it more generic (say, so I can add a function to generate the components' Roman numerals instead of having to use Arabic numerals in their place), I'd have to change everything to type object, and I have hundreds of places where I'm referencing type double - not to mention all the type conVersions I'd have to add, and error checking to make sure you don't pass a string to a function that's expecting a number! http://forum.shrapnelgames.com/images/icons/shock.gif
But you will be glad to see the HUGE array of functions, etc. that will be supported:
Prefix operators:
+ (identity)
- (negation)
Infix operators:
+ (addition)
- (subtraction)
* (multiplication)
/ (division)
^ (exponentiation)
\ (integer division)
% (modulo or remainder)
to (random; 3to6 generates a random integer from 3 to 6 inclusive)
d (dice; 3d6 generates a random integer as would be generated by rolling 3 six-sided dice)
P (permutations; 4P2 returns the number of permutations of 4 objects in Groups of 2)
C (combinations; 4C2 returns the number of combinations of 4 objects in Groups of 2)
E (exponential notation; 3E6 returns 3.0*10^6 or 3000000)
Postfix operators:
! (factorial)
% (percentage)
Built-in variables:
pi (ratio of circumference of circle to its diameter)
e (base of the natural logarithms)
c (speed of light, in meters per second)
Functions:
sin (sine)
cos (cosine)
tan (tangent)
asin (arcsine)
acos (arccosine)
atan (arctangent)
sinh (hyperbolic sine)
cosh (hyperbolic cosine)
tanh (hyperbolic tangent)
dtor (degrees to radians)
rtod (radians to degrees)
log (logarithm, base 10, or a specified base as the second parameter)
ln (logarithm, base e)
sqrt (square root)
curt (cube root)
root (returns x^(1/y) where x and y are the 2 arguments. Useful in place of the exponentiation operator if you want to take odd roots of negative numbers.)
abs (absolute value)
floor (largest integer below or equal)
ceiling (smallest integer above or equal)
int (integer part)
dec (decimal part)
round (rounds to nearest integer, or number of significant digits as specified by a second parameter)
fib (Fibonacci series)
poly (evaluates a polynomial in x; takes 2 or more arguments where the first argument is the value of x and later arguments are the coefficients of the polynomial in the order they are normally written, i.e. by descending order of power)
ftoc (Fahrenheit to Celsius)
ctof (Celsius to Fahrenheit)
min (finds minimum of all its arguments)
max (finds maximum of all its arguments)
avg (finds mean of all its arguments)
stdev (finds standard deviation of all its arguments)
median (finds median of all its arguments)
And any more I can think of! http://forum.shrapnelgames.com/images/icons/icon10.gif
Ed Kolis
July 24th, 2004, 02:52 AM
No SE4 data file integration yet, but why not play around with my math parser and let me know what you think?
http://home.fuse.net/koliset/Programming/EEE.rar
Aiken
July 24th, 2004, 02:48 PM
*trying to launch Evil Ed's Exterminator once again*
Do I need .NET Framework? I got errors about missing dlls when tried to work with it.
[ July 24, 2004, 13:52: Message edited by: aiken ]
Ruatha
July 24th, 2004, 02:55 PM
ETA next week.. Darned, you'll beat my eta for the companion http://forum.shrapnelgames.com/images/icons/tongue.gif
(Don't really understand what this does but have nothing to do and wants to post)
Impressive amount of functions though!
To bad it wasn't a zip archive, I dont feel up to download an unrar proggie here at work, only have zip support.
Will have to try it when I get home.
[ July 24, 2004, 14:03: Message edited by: Ruatha ]
Alneyan
July 24th, 2004, 03:24 PM
Hmm. This perfectly sums up my understanding of your program, Ed, and therefore I will unlikely able to provide any kind of feedback. http://forum.shrapnelgames.com/images/icons/icon12.gif
Before you threaten to totemise me: does this program allow modders to plug in various formulas ruling any value in the SEIV files? For example, is the purpose of this program to automatise a geometrical suit ruling the cost of devices? (Such as what SJ seems to have done for his latest mod)
If so, I can indeed see its usefulness for modders (well, as long as they can understand the whole array of mathematical functions better than I do; I flunked maths at kindergarten after all). If I am wholly mistaken, I guess it is simply too complicated for my poor mind. http://forum.shrapnelgames.com/images/icons/icon12.gif
Yimboli
July 24th, 2004, 03:54 PM
Originally posted by Ed Kolis:
The other two are really statistical operators, but I figured I'd throw them in because I'd already done factorials - the "P" operator calculates permutations while the "C" operator calculates combinations, if you happen to know (or care) what those are... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif <font size="2" face="sans-serif, arial, verdana">Ed, I fully understand combinations and permutations... I'm just wondering how you think they would be useful? And how do they work? i.e. if I say P(1234), what happens?
Ed Kolis
July 24th, 2004, 05:06 PM
Do I need .NET Framework? I got errors about missing dlls when tried to work with it.
<font size="2" face="sans-serif, arial, verdana">Yeah, you need the .NET Framework 1.1. You can find it at http://msdn.microsoft.com/netframework/technologyinfo/redist/default.aspx
Before you threaten to totemise me: does this program allow modders to plug in various formulas ruling any value in the SEIV files? For example, is the purpose of this program to automatise a geometrical suit ruling the cost of devices? (Such as what SJ seems to have done for his latest mod)
<font size="2" face="sans-serif, arial, verdana">Yes - at least it will, once I get the part that reads and writes SE4 files working with the expression evaluator. Right now all I've posted is the expression evaluator part http://forum.shrapnelgames.com/images/icons/icon12.gif In addition, I'm planning on making pretty much any of the fields able to get formulas into, not just the cost... even the text fields! So you know how you do [%ShieldPointsGenerated] but you can't do that for any other ability? Well now all you have to do is copy over the formula that you used in the actual ability (maybe I'll put in special variables that act like [%ShieldPointsGenerated] so you can just use those instead of the whole formula), and it will be inserted into the description string! http://forum.shrapnelgames.com/images/icons/icon6.gif
Ed, I fully understand combinations and permutations... I'm just wondering how you think they would be useful? And how do they work? i.e. if I say P(1234), what happens?
<font size="2" face="sans-serif, arial, verdana">That's not how you'd call the function - actually, it's an infix operator, so you'd call something like 4P3, and that would find the number of permutations of 4 objects in Groups of 3. As for how it would be useful, I really don't know in terms of SE4, but I figured I'd include it because I'd be releasing this math parser for general use anyway and someone somewhere might need it http://forum.shrapnelgames.com/images/icons/icon12.gif
Aiken
July 24th, 2004, 08:02 PM
http://forum.shrapnelgames.com/images/icons/shock.gif 25 Mb? Good god! Nice size for a set of libraries.
Burn the .NET!!! http://forum.shrapnelgames.com/images/icons/icon8.gif
Ed Kolis
July 24th, 2004, 09:48 PM
Sorry about that... hope you download them anyway, because you will need them to run the program http://forum.shrapnelgames.com/images/icons/icon9.gif
(Hey, think of it this way - it's about the same size as the Java libraries, and nobody complains about Java, do they? http://forum.shrapnelgames.com/images/icons/icon12.gif )
edit: judging from your sig, you might be interested in this: www.go-mono.com (http://www.go-mono.com)
It's the GNU Version of .NET and allows you to run .NET applications on Linux as well as Windows - as long as they're compiled for Mono and not the regular .NET. Mine isn't but it should be able to be compiled for Mono - I think...
[ July 24, 2004, 20:51: Message edited by: Ed Kolis ]
Ed Kolis
July 25th, 2004, 06:51 AM
The SE4 Templatizer is ready for download, ahead of schedule! http://forum.shrapnelgames.com/images/icons/icon6.gif http://forum.shrapnelgames.com/images/icons/icon6.gif http://forum.shrapnelgames.com/images/icons/icon6.gif
http://home.fuse.net/koliset/SE4/SE4_Templatizer.rar
You'll need the .NET Framework ( http://forum.shrapnelgames.com/images/icons/icon9.gif ), EEE (as mentioned in previous Posts), and a RAR extractor to use this program.
Try it out - it's pretty darn cool! http://forum.shrapnelgames.com/images/icons/icon6.gif
Yimboli
July 25th, 2004, 06:25 PM
Originally posted by Ed Kolis:
</font><blockquote><font size="1" face="sans-serif, arial, verdana">quote:</font><hr /><font size="2" face="sans-serif, arial, verdana">Originally posted by Yimboli:
Ed, I fully understand combinations and permutations... I'm just wondering how you think they would be useful? And how do they work? i.e. if I say P(1234), what happens?
<font size="2" face="sans-serif, arial, verdana">That's not how you'd call the function - actually, it's an infix operator, so you'd call something like 4P3, and that would find the number of permutations of 4 objects in Groups of 3. As for how it would be useful, I really don't know in terms of SE4, but I figured I'd include it because I'd be releasing this math parser for general use anyway and someone somewhere might need it http://forum.shrapnelgames.com/images/icons/icon12.gif </font><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">Ohhhhh, that makes much more sense. so 4C3 would be like "4 choose 3" http://forum.shrapnelgames.com/images/icons/icon10.gif
[ July 25, 2004, 17:26: Message edited by: Yimboli ]
Aiken
July 25th, 2004, 09:13 PM
Now I have a reverse task: I have a numerical values for damage (ex.: 0 5 10 45 120 390 0 0.. or such) and I like to find the approximation function for this sequence. Can someone suggest a tool to do it?
Ed Kolis
July 26th, 2004, 01:02 AM
SE4 Templatizer updated to Version 1.0.1!
What's new:
-Fixed bug where roman numeral IV showed up as IIII http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
-Fixed bug where an extra newline was inserted between entry families
Ed Kolis
July 28th, 2004, 09:49 PM
(bump)
C'mon, this is an interesting tool! Hard to use maybe, but very useful! http://forum.shrapnelgames.com/images/icons/icon12.gif
Aiken
July 28th, 2004, 10:12 PM
Don't panic, where's at least 1 user of your SE4_templatizer - me (going to use it in my own project after I'll figure out how the hell pyScintilla works) http://forum.shrapnelgames.com/images/icons/icon7.gif
*to do: test Templatizer for i18n*
Ed Kolis
July 30th, 2004, 04:52 AM
New Version of the expression evaluator that the Templatizer uses - get it at my website!
What's new: interpolation functions (handy for damage calculations http://forum.shrapnelgames.com/images/icons/icon12.gif ) and bug fixes!
Ed Kolis
July 30th, 2004, 06:06 PM
Templatizer update: you can now use metric suffixes (such as 1K = 1E3), and a bug fixed which required you to add a newline to the generated files before using them in SE4 http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
Ruatha
July 30th, 2004, 06:57 PM
Is it possible for you to write a graphic UI for the templatizer or the EEE?
For us not so fluent in evaluation thingies!
I've tried to start it but it goes Zoooooooooom way past me!! It's finished before I have even the slightest idea what I'm doing, (It's not that it finishes by itself its just that it would propably take several years for me to understand it).
I've tried both the Templatizer and the EEE and I belive I've got some tiny notion as to what it does but that's about it and I might be way wrong!
Ed Kolis
July 30th, 2004, 10:40 PM
Yeah, I could probably put together a GUI for the programs... the real meat of the app is in the expression parser library anyway, so it shouldn't take long to make a GUI for the templatizer, at least... I personally don't see much point in making a GUI for the calculator part, because that would have to be changed every time I added a function or operator, and it would be *quite* cluttered with all the functions I've added - unless all you want is a text box where you type in equations, but then how's that better than a command line anyway? http://forum.shrapnelgames.com/images/icons/tongue.gif
Of course, when you say a GUI for the templatizer, do you just mean something where you can select an input text file and select an output text file and hit "generate"? Or do you want to be able to fully configure the various data files in the GUI? I think there's a PropertyList control which might be of some use, if I can figure out how to manipulate it to add and remove abilities, tech reqs, etc. the way I want...
Oh, and BTW, there's another bugfix release out now - was having some more problems with parentheses, those pesky things http://forum.shrapnelgames.com/images/icons/tongue.gif
Ruatha
July 30th, 2004, 11:02 PM
Hmm, I don't know what I mean, I just thought it'd be easier to see what it does....
Ed Kolis
July 31st, 2004, 03:39 AM
Well, the GUI, whatever that may be, is probably a ways off... I'm still trying to work out the Last of these stupid order-of-operations bugs that ruin any expression with multiple levels of parentheses! http://forum.shrapnelgames.com/images/icons/icon8.gif
(Though with the wide variety of functions I've provided, there will be little need to use multiple levels of parentheses, no? http://forum.shrapnelgames.com/images/icons/icon12.gif )
Ed Kolis
July 31st, 2004, 06:54 AM
Well, I got those parentheses bugs fixed (at least I hope... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif ) - anyone else want to try it out? I've generated a few MOO2 components with the program, but those are pretty trivial compared to what the program can do http://forum.shrapnelgames.com/images/icons/icon12.gif
Ed Kolis
July 31st, 2004, 09:03 PM
Grrr, I found another bug... http://forum.shrapnelgames.com/images/icons/icon8.gif
It seems you can't call a function that takes multiple parameters from inside another function, because the outer function counts all the commas inside its parameter list and spits back an error saying "too many parameters"... so I'll have to tell it to ignore any commas that are inside parentheses in a parameter list, I guess...
Also, the templatizer is rather slow, seeing as it redoes the whole calculation each time it runs an equation, even if all that's changed is the value of a variable... I'll probably have to Cache the results of all my expressions until they fall out of scope, I guess...
Finally, I'd better make it display any errors that are thrown by the various functions and such... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
Ed Kolis
August 1st, 2004, 03:29 AM
Fixed those bugs... still haven't done anything about the slowness; that will probably require adding a property to one of my upper-level classes and overloading it in a lot of lower-level ones... ugh http://forum.shrapnelgames.com/images/icons/tongue.gif
Unless I can figure out this attributes thing that .NET has... then I could just tag the expression type classes I want to be "nonCacheable" with a special attribute tag, and check for that tag when I go to do the caching...
Ed Kolis
August 8th, 2004, 06:58 PM
I've started work on a GUI Version of the Templatizer... here's a general idea of what it will look like (assuming this newfangled file attachment thing works properly http://forum.shrapnelgames.com/images/smilies/wink.gif)
Anyone interested, or should I go back and try to speed up the expression parser by making it Cache known equation results?
Fyron
August 8th, 2004, 07:25 PM
Files can only be attached in the Scenarios/Mods forum Category. You can upload the file there, then use the URL in your post here.
Ed Kolis
August 8th, 2004, 10:42 PM
Well it WORKED... http://forum.shrapnelgames.com/images/smilies/tongue.gif
Is there a rule against it? http://forum.shrapnelgames.com/images/smilies/redface.gif
Fyron
August 9th, 2004, 01:50 AM
Yes. From the message at the top of the forums:
...the least of which is a return of file downloads. Please use the threads in the Scenario Archive to resume putting up mods and the like.
Ruatha
August 10th, 2004, 02:57 AM
Now even I can understand it!
Ed Kolis
August 12th, 2004, 11:19 PM
New Version of the (text-based) Templatizer ready - now with caching, so it's much faster! http://forum.shrapnelgames.com/images/smilies/cool.gif
Hmm, when will I ever get back to work on that graphical modding tool? http://forum.shrapnelgames.com/images/smilies/redface.gif
Ruatha
August 31st, 2004, 01:18 AM
What's happening with the graphical shell?
Ed Kolis
October 18th, 2004, 01:23 PM
Oops, sorry, must have lost track of your post, Ruatha... I haven't done anything on a graphical shell yet, but what I am doing is completely rewriting the program to make it faster and more powerful. See, right now, it's horribly inefficient at parsing the text, because basically if you have 5 + (2 * 3), it searches for the outermost operation (the plus), and splits it up into two expressions, 5 and 2 * 3. Then it takes the 5 and says "oh, that's a number", and stores it away. The 2 * 3 then gets parsed AGAIN (even though it was already searched through to find the plus) and split into the 2 and 3. Then, those numbers are multiplied to get 6, and then 5 is added to get 11. This may not seem to inefficient, but imagine a long expression with many subexpressions, such as sin(pi * (2 + atan(6) * e) - 1? http://forum.shrapnelgames.com/images/smilies/eek.gif
So what I WANT to do is do all the parsing at once, only once, and THEN do the evaluation. This will involve something I've come up with called "functional notation" where every operation, constant, or variable is represented as a function, so for instance 5 + 2 would be represented as +(5,2), and sin(pi / 3) would be represented as sin(/(pi(),3)). Actually functional notation has probably been invented already, but I thought of it independently, so there http://forum.shrapnelgames.com/images/smilies/tongue.gif
Which leads me into the main reason for this post: I noticed that using functional notation, there could only be one function or operator with the same name and "arity" (which is the number of operands). This reminds me a LOT of a programming language called Erlang, because there was the same restriction on Erlang's functions, seeing as Erlang was a weakly-typed language. SO... what I'm thinking of doing is, while I'm already rewriting everything, adding a *scripting language* to my expression evaluator, so that you can define your own functions without having to compile any C# code. Basically, I'd have only the most rudimentary functions and operators predefined, and the rest would be called through script. I know, you say scripting Languages are slow, but C# has this nifty feature which lets you compile and execute code "on the fly", so I could compile the scripts whenever the program is run (don't worry, C# code compiles fast http://forum.shrapnelgames.com/images/smilies/wink.gif), and then execute them as compiled code in memory! http://forum.shrapnelgames.com/images/smilies/cool.gif
SO... what my question is, is what would be the preferred language of the Users of this program to base the scripting language on? The most natural choice for me would be C#, because that's what I use, but VB would work as well, since the on-the-fly compiler can work with either language. But since I'll probably have to write my own language parser (to allow only harmless instructions like "return x+y" and "if p then loop until q" and nothing like "delete c:\windows\*.*" http://forum.shrapnelgames.com/images/smilies/wink.gif), I could just as well base it on some other language, like Python or Erlang... problem is, I don't know much ABOUT Python or Erlang... http://forum.shrapnelgames.com/images/smilies/frown.gif
So, anyone have a preference?
Aiken
October 18th, 2004, 02:39 PM
I'd prefere native c syntax. It'll make your work much easier. Just don't forget to rewrite documentation http://forum.shrapnelgames.com/images/smilies/happy.gif
Fyron
October 18th, 2004, 02:47 PM
VB is not an option... Stick to real Languages. http://forum.shrapnelgames.com/images/smilies/tongue.gif Python would be a very good choice. Python has similar syntax to C/C++.
Gandalf Parker
October 18th, 2004, 03:03 PM
Imperator Fyron said:
VB is not an option... Stick to real Languages. http://forum.shrapnelgames.com/images/smilies/tongue.gif Python would be a very good choice. Python has similar syntax to C/C++.
Really? VB not an option for a scripting language? Of a game that is Windows restricted? You would rather have scripters in C syntax instead of basic?
Aiken
October 18th, 2004, 04:20 PM
The best scripting language is the language you know best of all. http://forum.shrapnelgames.com/images/smilies/happy.gif It really doesn't matter VBS, JScript, python or perl or pseudoC script.
Probably VBS or JScript are more convenient than others, because of WSH.
Personaly, I don't like VBS and VB (in general) too - many inherent flaws and bad design. So my next vote will go to JScript.
Fyron
October 18th, 2004, 04:25 PM
Gandalf Parker said:
Imperator Fyron said:
VB is not an option... Stick to real Languages. http://forum.shrapnelgames.com/images/smilies/tongue.gif Python would be a very good choice. Python has similar syntax to C/C++.
Really? VB not an option for a scripting language? Of a game that is Windows restricted? You would rather have scripters in C syntax instead of basic?
You can easily install other scripting language interpreters on Windows, including other "basic" type Languages... it is just a few clicks away. VB is no good.
Ed Kolis
October 18th, 2004, 06:35 PM
Hmm... a divided opinion... well, I could always have functions loaded as modules, and let the user choose between VB and C#, and screw the security considerations - if you're dumb enough to run a malicious program when the source is sitting right in front of you, it's your fault! http://forum.shrapnelgames.com/images/smilies/laugh.gif
Gandalf Parker
October 18th, 2004, 08:22 PM
Imperator Fyron said:You can easily install other scripting language interpreters on Windows, including other "basic" type Languages... it is just a few clicks away. VB is no good.
That wasnt what I meant. Not that Im big on "run this, but of course you will have to go get this first" type of programs. I was just totally disagreeing with a blanket sheep statement like "VB is no good". Everything has its pros and cons. VB doesnt have many but as a beginners scripting language in fairly english usage that would seem to be what its for.
But dont mind me, I wouldnt prefer VB either. I prefer to do all my coding on linux then run it in windows
Ed Kolis
October 18th, 2004, 11:51 PM
Hmmm... looks like the scripting language might have to wait... I just remembered that the on-the-fly code compilation that I was going to use uses something called "reflection", which is VERY slow, and is what was slowing down my program so much in the first place! http://forum.shrapnelgames.com/images/smilies/eek.gif
I don't suppose throwing together my own interpreter would run code any faster than Microsoft's reflection, would it? http://forum.shrapnelgames.com/images/smilies/rolleyes.gif Even though I'd be limiting the instruction set, hopefully speeding up the parsing, I don't think I'm that good that I could compete with the likes of them http://forum.shrapnelgames.com/images/smilies/wink.gif
On the other hand......
The compilation feature of .NET also has the ability to actually compile code into a DLL *on disk*, so maybe what I could do is provide a very basic language that is easy to use, write a compiler for it, which of course would run as quickly as anything I hardcode...
So, what features would you like to be in such a language? Basic math and logical operations are obvious, as are conditional and looping statements (though loops can be created by conditionals and gotos, should I choose to include gotos http://forum.shrapnelgames.com/images/smilies/tongue.gif) Variable declarations might also help...
Now since we're only going to be defining functions and no fancy data structures in this language, I suppose it might make sense to cut down on the typing and use something similar to Erlang's function definition style, which looks a LOT like the formal mathematical style (forgive my poor syntax; I've never actually written anything in Erlang before http://forum.shrapnelgames.com/images/smilies/tongue.gif)
Recursive algorithm for finding factorials:
<font class="small">Code:</font><hr /><pre>
fact(0) -> 1.
fact(1) -> 1.
fact(n) -> if n < 0 error() else n * fact(n - 1).
</pre><hr />
How does that look? Readable? Maybe I'll get the hang of Erlang after all... then maybe I can even work on writing PLUGINS and stuff for Wings! http://forum.shrapnelgames.com/images/smilies/eek.gif (Nah, I won't have the time, and besides, I've barely scratched the surface of the language http://forum.shrapnelgames.com/images/smilies/tongue.gif)
(Wow, I never thought I'd be developing my own .NET language, but really, I might be!)
Or maybe I SHOULD start over in Python... I'm already pretty much starting over as it is http://forum.shrapnelgames.com/images/smilies/frown.gif
Ed Kolis
December 6th, 2004, 06:19 PM
Looks like templatizer v2.0.0 might be coming out soon... pretty much all I need to do is implement parentheses and fix up a few bugs, then plug in the new Version of the expression evaluator into the templatizer! http://forum.shrapnelgames.com/images/smilies/laugh.gif
New features in 2.0.0:
-You can now script your own functions and operators without writing a single line of C# code! Just define them in functions.txt like these:
Quadratic solver:
#Function quadfirstroot = (-arg2+sqrt(4*arg1*arg3
This is almost turning into a programming language, isn't it? http://forum.shrapnelgames.com/images/smilies/wink.gif
Of course, I just HAD to use the latest 2.0 beta release of the .NET framework, just because I wanted to try out the nifty new generic classes and such... sorry about the huge download again http://forum.shrapnelgames.com/images/smilies/frown.gif
Atrocities
December 6th, 2004, 07:27 PM
Sounds like your enjoying yourself Ed. http://forum.shrapnelgames.com/images/smilies/happy.gif What do you have planned for SE V?
Ed Kolis
December 6th, 2004, 09:51 PM
SE5? Not much, seeing as SE5 will have its own built-in formula parser, making the templatizer pretty much obsolete (unless of course Aaron decides NOT to throw in custom formulas like I did http://forum.shrapnelgames.com/images/smilies/frown.gif)
... that was odd, I did NOT post that at 4:30 this afternoon, I was on my way home from work at 4:30... did someone at work see the message I left without posting and post it after I left??? Yes, I believe they did, because I hadn't finished typing in the quadratic formula yet! http://forum.shrapnelgames.com/images/smilies/tongue.gif
edit: oh, so I might as well finish that feature list... in addition to defining your own functions, you can define your own operators, like this:
#Postfix ! := product(factorialNum, 1, arg1, factorialNum)
which calculates a factorial by looping through the integers until you get to the number specified and multiplying them.
For infix operators, you have to specify a precedence (high, medium, low, or very low level).
(Yes, you will now be able to compute the products and sums of series... once I implement those functions, which will involve actually creating new named constants on the fly http://forum.shrapnelgames.com/images/smilies/laugh.gif)
I hope to eventually get symbolic variables in there so you could put in 3 * x + 4 * x and get 7 * x, (but I don't know how well that would work; how would I tell the program how to, say, recognize polynomials and multiply them out? not TOO hard, but then how would it know which form is the "simplest"? the one with the least number of characters? least number of parentheses? largest or smallest powers? and what if you throw in trig functions and user defined functions??? http://forum.shrapnelgames.com/images/smilies/eek.gif)
Actually, the templatizer itself is very simple; pretty much all it does is read in files and if it sees anything in brackets after a := symbol, it calls the expression evaluator to do all the dirty work, so the templatizer should (mostly) work with SE5 data files, or even SF or DO data files; the only hardcoded change I had to make was to define the "range" variable and run it through a loop from 1 to 20 (or 21) whenever the "Weapon Damage At Rng" field is found, so I suppose similar things would have to be done for other array fields in the other games as well...
Fyron
December 7th, 2004, 01:21 AM
Ed Kolis said:
I hope to eventually get symbolic variables in there so you could put in 3 * x + 4 * x and get 7 * x, (but I don't know how well that would work; how would I tell the program how to, say, recognize polynomials and multiply them out? not TOO hard, but then how would it know which form is the "simplest"? the one with the least number of characters? least number of parentheses? largest or smallest powers? and what if you throw in trig functions and user defined functions??? http://forum.shrapnelgames.com/images/smilies/eek.gif)
Just pick with the form that is easiest to use calculationally, and convert all functions to it. For example, the "simplest form" could be the standard form of a polynomial, a(n) * x ^ n + a(n-1) * x (n-1) + ... + a(0). You would probably want to convert the equations to matrix form and use linear algebra anyways, as it is really the only sane way to deal with polynomials http://forum.shrapnelgames.com/images/smilies/wink.gif. This uses the standard form of the functions.
Ed Kolis
December 25th, 2004, 03:57 PM
No, no templatizer 2.0 yet... but I have a question - what would be a good name for a function which performs a specified function on every character in a string and returns the concatenation of all the results? E.g. a hexadecimal to binary converter: you'd call it something like this
functionname(htob, "DEADBEEF")
where functionname is my function I'm trying to find a name for and htob is the hex-to-binary function which converts a single hex digit to binary... I thought of concat and foreach, but concat is already taken and foreach I want to reserve for an even more general case that's kind of nebulous in my mind right now...
Ed Kolis
January 6th, 2005, 06:06 PM
Progress report time...
Almost there - just one more bug to fix in the expression evaluator and a few things to add to the templatizer itself! Apparently now when I type in something like 0 * (1 + 2) + 3 I get 0 because the multiplication gets spread across everything, not just the next term (the 1+2). Lots of new features, and yes, I did manage to get the templatizer to use the latest Version of the expression evaluator, and it's MUCH faster now - a data file which used to take several minutes to process now runs in seconds! http://forum.shrapnelgames.com/images/smilies/eek.gif The new features I wanted to add to the templatizer are to be able to define local functions inside the data files themselves, and to allow more than three tech grid areas (previously the three were hardcoded; now I'm going to define them on the fly! http://forum.shrapnelgames.com/images/smilies/laugh.gif) So, instead of something like this...
<font class="small">Code:</font><hr /><pre>
*BEGIN*
Min LevelA := 1 // primary tech area increases damage
Max LevelA := 12
Min LevelB := 1 // secondary tech area increases range
Max LevelB := 5
Weapon Min Range := 1
Weapon Max Range := [3 + levelb]
Name := Anti - Proton Beam <romana>-<letterb>
Description := Focused energy beam used as a medium range weapon.
Pic Num := 18
Tonnage Space Taken := 30
Tonnage Structure := 30
Cost Minerals := [25 + 25 * levela]
Cost Organics := [100 * (levelb - 1)]
Cost Radioactives := [10 * levela]
Vehicle Type := Ship\Base\Sat\WeapPlat\Drone
Supply Amount Used := 5
Restrictions := None
General Group := Weapons
Family := [2000 + levelb]
Roman Numeral := 1
Custom Group := 0
Number of Tech Req := 2
Tech Area Req 1 := Energy Stream Weapons
Tech Level Req 1 := [levela]
Tech Area Req 2 := Range Enhancement
Tech Level Req 2 := [levelb]
Number of Abilities := 0
Weapon Type := Direct Fire
Weapon Target := Ships\Planets\Ftr\Sat\Drone
Weapon Damage At Rng := [30 + levela * 5 - range * 2]
Weapon Damage Type := Normal
Weapon Reload Rate := 1
Weapon Display Type := Beam
Weapon Display := 1
Weapon Modifier := 0
Weapon Sound := apbeam.wav
Weapon Family := 1
*END*
</pre><hr />
you could have this:
<font class="small">Code:</font><hr /><pre>
*BEGIN*
#TechGrid damagelevel := [1] to [5]
#TechGrid rangelevel := [1] to [5]
#TechGrid minilevel := [1] to [5]
#TechGrid efficlevel := [1] to [5]
Weapon Min Range := 1
Weapon Max Range := [3 + levelb]
Name := Anti - Proton Beam [roman(damagelevel)]-[letter(rangelevel)]-[minilevel]
// nifty switch statement!
Description := Focused energy beam used as a [switch(rangelevel, 1, "point blank", 2, "short", 3, "medium", 4, "long", 5, "siege", "")] range weapon.
Pic Num := 18
#LocalFunction tonnage := [32 - minilevel * 2]
Tonnage Space Taken := [tonnage]
Tonnage Structure := [tonnage] // to save on typing formulas ;-)
Cost Minerals := [25 + 25 * damagelevellevel]
Cost Organics := [100 * (rangelevel - 1)]
Cost Radioactives := [10 * damagelevel]
Vehicle Type := Ship\Base\Sat\WeapPlat\Drone
Supply Amount Used := [6 - efficlevel]
Restrictions := None
General Group := Weapons
Family := [2000 + rangelevel]
Roman Numeral := 1
Custom Group := 0
Number of Tech Req := 4
Tech Area Req 1 := Energy Stream Weapons
Tech Level Req 1 := [damagelevel]
Tech Area Req 2 := Range Enhancement
Tech Level Req 2 := [rangelevel]
Tech Area Req 3 := Miniaturization
Tech Level Req 3 := [minilevel]
Tech Area Req 4 := Supply Efficiency
Tech Level Req 4 := [efficlevel]
Number of Abilities := 0
Weapon Type := Direct Fire
Weapon Target := Ships\Planets\Ftr\Sat\Drone
Weapon Damage At Rng := [30 + damagelevel * 5 - range * 2]
Weapon Damage Type := Normal
Weapon Reload Rate := 1
Weapon Display Type := Beam
Weapon Display := 1
Weapon Modifier := 0
Weapon Sound := apbeam.wav
Weapon Family := 1
*END*
</pre><hr />
NarfsCompIsBack
January 6th, 2005, 10:31 PM
Woot! Not that I can do anything with it right now.
Nodachi
January 23rd, 2005, 09:52 AM
How's this coming along, Ed?
BTW, the link for this is incorrect on your site. http://forum.shrapnelgames.com/images/smilies/redface.gif
Ed Kolis
January 23rd, 2005, 11:51 AM
Oh, I've fallen into one of those lulls again... I've tried working on it a few times, and I think I have one thing figured out but then another problem crops up... and given that I don't get around to working on it every day that can take a while http://forum.shrapnelgames.com/images/smilies/frown.gif
Right now I have the linear interpolation function working (I think) but something's wrong with the geometric and logarithmic functions and I want to make sure that it's not something in the code (as opposed to just a bad formula definition in formulas.txt) before I release anything... and right now the prospects aren't looking too good http://forum.shrapnelgames.com/images/smilies/tongue.gif
Plus then I still have to add those new features to the templatizer itself - the usage of more than 3 level variables, the definition of user-defined functions, etc. That all shouldn't be too hard because it's primarily just calling methods I already have defined (or copying and pasting http://forum.shrapnelgames.com/images/smilies/wink.gif), rather than writing a lot of new code.
Ed Kolis
February 20th, 2005, 06:46 PM
All right, the bad news is I gave up on the .NET-powered templatizer... the good news is I moved to Java! http://forum.shrapnelgames.com/images/smilies/laugh.gif
This was actually prompted by my switch to Linux; Mono's IDE isn't very developed at this point, whereas with Java you can use NetBeans.
Well, over the past 3 days I completely rewrote the templatizer part of the program, and gave up on the expression evaluator - because I finally found one that does exactly what I want, only it's even better than the one I wrote! http://forum.shrapnelgames.com/images/smilies/laugh.gif
Have a look at this:
http://directory.fsf.org/science/math/calc.html
One problem I foresee is that it's called "calc" which is the name of the standard Windows calculator... well I could put in a dialog to locate the "real" calc, but for now - hey, who uses the crappy Windows calculator anyway? Just rename it! http://forum.shrapnelgames.com/images/smilies/tongue.gif
The templatizer is almost working again, and it even has a GUI, but the thing I'm stuck on right now is trying to get the thing to not skip tech grids! http://forum.shrapnelgames.com/images/smilies/mad.gif It would be much easier if I weren't trying to support an unlimited number of tech grids... the very first templatizer supported 3; would 16 do? I say this because if I have a set number of grids, I can use nested for loops, but with an unlimited number, I have to use recursion and that gets messy! http://forum.shrapnelgames.com/images/smilies/eek.gif
Unless SJ wants to help me out, seeing as he's solved this problem already, even though I'm trying to make something that will compete with his Tech Gridder... hey, I did give up on .NET http://forum.shrapnelgames.com/images/smilies/tongue.gif
Ed Kolis
February 21st, 2005, 11:34 PM
Templatizer 3 is here!!!!!
http://home.fuse.net/koliset/SE4/templatizer-3.0.0.tar.bz2
You'll need the aforementioned calc program, as well as the latest Java (not .NET) runtime.
Questions? Comments? http://forum.shrapnelgames.com/images/smilies/wink.gif
Ed Kolis
February 22nd, 2005, 02:57 AM
I just fixed up some bugs... c'mon, somebody download this thing & try it out! Get calc and see if it works on Windows - it's a pretty nifty tool http://forum.shrapnelgames.com/images/smilies/wink.gif
http://home.fuse.net/koliset/SE4/templatizer-3.0.1.tar.bz2
Ed Kolis
February 22nd, 2005, 04:19 AM
Fixed another bug, or maybe broke something else, who knows/cares, I'm tired... http://forum.shrapnelgames.com/images/smilies/tongue.gif
http://home.fuse.net/koliset/SE4/templatizer-3.0.2.tar.bz2
leo1434
February 22nd, 2005, 09:31 PM
Isn't it possible to distribute an .exe file, or give more complete intructions on how to use this tool?
Ed Kolis
February 22nd, 2005, 10:45 PM
Hmm, an .exe... might be tricky to do on my Linux system... I could make a zip version though... oh, and just put this into a file called templatizer.bat and then you can double click the batch file to run it (assuming you have Java 1.5 and calc installed):
java -jar templatizer.jar
What kinds of more complete instructions are you looking for?
Oh, and congratulations & thanks for being the first to respond here - for a while I thought I was going to do this for nothing! http://forum.shrapnelgames.com/images/smilies/frown.gif
BTW, I still have another bug to fix up - functions defined out of alphabetical order don't work properly http://forum.shrapnelgames.com/images/smilies/rolleyes.gif I hope to get to it tonight or at least sometime in the next few days...
Ed Kolis
February 23rd, 2005, 01:38 AM
OK, version 3.0.3 is out...
http://home.fuse.net/koliset/Programming/templatizer-3.0.3.zip
I've fixed lots of bugs... though I still haven't tried actually loading any of the generated files into SE4... I wonder if SE4 will choke on the UNIX formatted files, since I forgot to tell it to place the carriage return after each newline like Windows prefers... http://forum.shrapnelgames.com/images/smilies/rolleyes.gif
Aiken
February 23rd, 2005, 05:26 AM
Do I still need a EEE part to get it to work?
I can't find calc's binaries, do I need them actually? And where to get them?
Spoo
February 23rd, 2005, 11:22 AM
It looks like calc is only available as source files. Most windows users don't have a compiler handy, you know.
Ed Kolis
February 23rd, 2005, 11:43 AM
No, you don't need EEE; you do need calc binaries though.
Hmm, let me go see where the binaries are... I can't find them either; if you want you can compile it with cygwin (http://www.cygwin.com/) though... sorry, I only noted that calc runs on Windows; I didn't check for Windows binaries... I really need to plan better... http://forum.shrapnelgames.com/images/smilies/frown.gif
But basically what I gather from the Windows build instructions (http://www.isthe.com/chongo/src/calc/README.WINDOWS) is that you need to set up Cygwin (make sure you get the gcc package, it's the C compiler!), put the source in your Cygwin directory, run cygwin, go to your source directory in cygwin (cd /usr/src/calc or whatever your source is under), copy the Windows-specific files to the source directory (cp win32/*.c win32/*.h .) and build the executable (make win32_hsrc)
I have cygwin on the old laptop; maybe I can do all that for you, assuming distributing binaries of someone else's software is OK under the LGPL (I think it is, as long as I include the source or at least say where to get it...)
Alternatively, you could use the DJGPP (http://www.delorie.com/djgpp/) compiler... that runs natively under Windows... see the above readme for instructions on how to compile it with DJGPP...
Hmm, this all needs to go in the documentation for the templatizer... http://forum.shrapnelgames.com/images/smilies/tongue.gif
Aiken
February 23rd, 2005, 12:44 PM
1) I have a debian install in colinux (gcc 3.3.3) at hand now, would you wrote some instructions how to build win32 binaries in linux? I see one need to mess with a makefile, but where?
2) se4 is unable to load text files in unix format (lf). Please add conversion to dos format (crlf).
3) Do I strictly need jre 1.5 or 1.4.x will be sufficient?
4) Thanks for getting rid of dotnet and all the work http://forum.shrapnelgames.com/images/smilies/happy.gif
edit: about #1 - just have realized that compilation in cygwin and native *nix will be identical http://forum.shrapnelgames.com/images/smilies/happy.gif So ignore #1.
leo1434
February 23rd, 2005, 09:40 PM
Ed:
I have read the instructions in the calc and I think you have to be a PC-Wizard to follow them. Why such pain? Why not "click on the install file". I think this will be better for the average player (er..., modder) assuming modders are a bit more "PC Skilled" than players. It is noticeable that people who make calc is a bit "Win-hater" but I think that we have to cope with the fact that windows systems are majority. Linux systems are said to run very well, but not all of us have the time and will to become computer technicians in order to learn how to use/install such systems.
On the other hand, I wish to thank you for your work in making such a program.Ithink it fills an important place in my SE4 Toolbox!!
Ed Kolis
February 23rd, 2005, 10:02 PM
@Aiken:
2. Oops! I will do that! http://forum.shrapnelgames.com/images/smilies/redface.gifops:
3. Yes, you need 1.5 because I was lazy and used generic classes. http://forum.shrapnelgames.com/images/smilies/tongue.gif Java is pretty insistent about pushing updates at you so you might already have it.
4. What's so bad about .NET compared to Java? The runtimes are about the same size to install... http://forum.shrapnelgames.com/images/smilies/confused.gif
@leo1434:
Yeah, sorry about all the trouble... I've just been wanting to get something out there. Calc is licensed under the LGPL, though, so I'm pretty sure I'd be allowed to include a Windows binary with my distribution of the templatizer, as long as I provided a link to the source code as well. (Anyone want to back me up on that? I don't feel like perusing the whole license again! http://forum.shrapnelgames.com/images/smilies/eek.gif)
As for an installer, I'd have to see... I've never found a really decent installer generator, and the program doesn't require a whole lot of files to run. But I could whip up a little batch file or Java program which would copy the files to convenient locations, and maybe even put them in your PATH environment variable so you can call them from anywhere...
Aiken
February 24th, 2005, 01:29 AM
Ed Kolis said:
4. What's so bad about .NET compared to Java? The runtimes are about the same size to install... http://forum.shrapnelgames.com/images/smilies/confused.gif
It will be #5:
5) Send Java there dotnet is already buried http://forum.shrapnelgames.com/images/smilies/tongue.gif
5.1) Don't take it seriously, I'm just nitpicking http://forum.shrapnelgames.com/images/smilies/happy.gif
I bet that lgpl allow you to redistribute compiled libraries if you put a license and credits files into your package. But you better ask about it in the calc mailing list, I think.
Ed Kolis
February 24th, 2005, 01:57 AM
All right, I've asked the primary author of calc for permission to include a Windows binary with the templatizer... we'll see how that goes! http://forum.shrapnelgames.com/images/smilies/happy.gif
Ed Kolis
February 24th, 2005, 02:21 AM
OK, I fixed the bug with the file format, and also fixed the Linux/UNIX shell script so it can actually pass command line arguments to the templatizer.
Ed Kolis
June 18th, 2005, 06:12 PM
Fixed a bug in the templatizer - it didn't like when I divided an array item by something; it treated the slash as a comment! http://forum.shrapnelgames.com/images/smilies/tongue.gif New version attached.
Ed Kolis
July 28th, 2005, 07:22 PM
Hey, I found out about this Java library called JEP which can do pretty much everything that calc does, so hopefully we'll soon have a fully Java-based templatizer - no more compiling C code to run it on windows http://forum.shrapnelgames.com/images/smilies/tongue.gif
Atrocities
July 29th, 2005, 12:44 AM
pme eptf. Dedp,r@
narf poit chez BOOM
July 29th, 2005, 01:24 AM
Uh??
Ed Kolis
August 1st, 2005, 03:55 PM
The templatizer is now Java-only!
Download latest version here:
http://kolis.dyndns.org/ed/prog/templatizer.zip
You'll need:
Java 5.0 runtime environment (www.java.com)
JEP parser plus the XJep and VectorJep packages (http://www.singsurf.org/djep/index.html) - or just grab the "Full Class Library"
Run the Java installer, extract templatizer.zip somewhere, and put the JEP stuff somewhere handy where Java can get to it (your templatizer directory is pretty much guaranteed to work; can't recall where else java might find it)! http://forum.shrapnelgames.com/images/smilies/laugh.gif
Look at the engine-template.txt for instructions (you can see its output in engine.txt)... the format has changed a bit since v3; hopefully it will be easier to use now (no more cryptic "#" symbols for a tech grid http://forum.shrapnelgames.com/images/smilies/tongue.gif)
Ed Kolis
September 10th, 2005, 06:29 PM
I was thinking of rewriting the templatizer *yet again*, this time to give it a graphical user interface. Anyone think this would be a good idea, or would I just be wasting my time?
Basically the way this GUI would work is like the Art of Illusion texture editor. You'd have a bunch of "blocks" each representing some elementary function or variable, and by plugging the blocks into each other you could create complex equations, with the added ability to save a set of blocks as a new block for future use. Of course, I'd hope to still support typing in equations (don't want to have to add 3 separate blocks just for 3 + TechLevel! http://forum.shrapnelgames.com/images/smilies/eek.gif), but I'm hoping making the program more "visual" will increase its usability... do you agree, disagree, not really care, whatever? http://forum.shrapnelgames.com/images/smilies/wink.gif
Kana
September 11th, 2005, 04:19 AM
Yeah that would be great...just make it for SEV instead...
http://forum.shrapnelgames.com/images/smilies/biggrin.gif
Kana
Ed Kolis
September 11th, 2005, 05:39 PM
Eh, shouldn't be hard to modify for SE5, if I ever get it done http://forum.shrapnelgames.com/images/smilies/wink.gif
Besides, a templatizer for SE5 would be of slightly less use, as in SE5 you're supposed to be able to type in formulas directly into the data fields...
Ed Kolis
October 17th, 2005, 08:22 PM
Well, maybe I won't do a graphical templatizer... but I could always redo it so it just uses XML transforms to create the SE4 data files - I'm taking a course in XML right now, so this would be a good application http://forum.shrapnelgames.com/images/smilies/wink.gif
Anyway, does this file I've attached look readable/writable to anyone? It's not quite the same as the SE4 data files, but it uses the same fields, and once I write the XSLT (the hard part http://forum.shrapnelgames.com/images/smilies/wink.gif) it should be translatable into SE4 data just by viewing it in your browser! http://forum.shrapnelgames.com/images/smilies/eek.gif
Ed Kolis
October 26th, 2005, 02:57 AM
OK, I've got a basic XML-based templatizer here...
http://kolis.dyndns.org/ed/prog/templatizer-xslt/Templatizer-XSLT.zip
Ed Kolis
November 24th, 2005, 12:34 AM
I have rewritten the templatizer (yet again http://forum.shrapnelgames.com/images/smilies/rolleyes.gif) - this time in Python!
http://kolis.dyndns.org/ed/prog/templatizer-py/templatizer-py.zip
And this time I won't make the mistake of not uploading it here just in case my computer fails http://forum.shrapnelgames.com/images/smilies/tongue.gif
Atrocities
November 24th, 2005, 05:01 AM
Cool, what does it do?
Ed Kolis
November 24th, 2005, 08:25 PM
Same thing it's always done - let you plug in formulas and it churns out components, facilities, mounts, vehicle sizes, or whatever you want in copious quantities! http://forum.shrapnelgames.com/images/smilies/laugh.gif
narf poit chez BOOM
November 25th, 2005, 01:02 AM
The cure for the common allergies?
Q
November 25th, 2005, 04:13 PM
Python = snake that strangles its prey before it devours it.
I don't think I want this in my computer http://forum.shrapnelgames.com/images/smilies/biggrin.gif
Fyron
November 26th, 2005, 07:49 PM
Python = hilarious British comedian. Why don't you want your computer filled with sketches about silly walks and dead parrots?
narf poit chez BOOM
November 26th, 2005, 09:41 PM
Isn't it also a gun?
Ed Kolis
September 13th, 2006, 12:10 PM
Thread necromancy strikes again! :twisted:
I was thinking of returning the templatizer to Java, and making it more user-friendly, more along the lines of DavidG's SE4Modder. Version 6 (which is still in beta) of Java allows you to mix Java and Javascript (http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/index.html for details), which means that I could have it so the user interface is in Java, but all the template code (the code that the user actually writes) is in Javascript. So you might have some field, say, Tonnage Structure, with a text box where you can type in a formula, or hit buttons to insert variables. Since Javascript in Java 6 can manipulate real Java objects, I might even make it so you can type field names (such as Tonnage) into other fields (such as Tonnage Structure) - or drag fields around - to make "references" between them. I'd have to prevent circular references, of course, but that shouldn't be too hard - just give each field a reference tree and make sure no object appears in its own reference tree!
Of course, this might all be rather irrelevant with SE5 coming out in the next month or so... any thoughts?
Dizzy
September 13th, 2006, 02:12 PM
Wow, that'd be a nice tool! I hope you do it. I'm sure there will still be a lot of SE4 still going on for a long while...
Captain Kwok
September 13th, 2006, 02:24 PM
I would suggest that you duplicate the entry from the data file, with editable fields that can take either hard text or a formula. I would just supply the user with the allowable formula elements in the help file etc. and a few variables like "level" or "range". The user would then select from a drop box the number of levels to make for the item and then the program exports the entries to a .txt file that can be copy/pasted into the appropriate data file.
Fyron
September 13th, 2006, 04:00 PM
Drag and drop for everything seems like wasted effort for something like this. If you are savvy enough to use exotic formulas for generating data files, you don't need no stinkin' drag and drop in a cluttered interface. http://forum.shrapnelgames.com/images/smilies/wink.gif Something like Kwok's suggestion would IMO be better; even "hard text" is still technically a formula.
Why not just keep the template code in Python? You can have the templatizer write out python scripts, then execute them. In fact, this would be preferable, basically building a front-end to the current python templatizer. This way, advanced users can just make/edit the python scripts directly. In also has the advantage of not wasting time duplicating all of your previous efforts. http://forum.shrapnelgames.com/images/smilies/happy.gif
Ed Kolis
September 13th, 2006, 04:43 PM
What do you mean "duplicate the entry from the data file"?
Captain Kwok
September 13th, 2006, 04:57 PM
Basically your interface consists of a replica of the data file entry, with the exception of textboxes or lists for data entry.
<font class="small">Code:</font><hr /><pre>
Name := *************
Description := *************
Pic Num := *************
Tonnage Space Taken := *************
Tonnage Structure := *************
Cost Minerals := 450 + ([%Level%] * 50) <--- Example Formula
Cost Organics := *************
Cost Radioactives := *************
Vehicle Type := *************
Supply Amount Used := *************
Restrictions := *************
General Group := *************
Family := *************
Roman Numeral := Auto
Custom Group := *************
Number of Tech Req := [Droplist of numbers?]
Tech Area Req 1 := *************
Tech Level Req 1 := *************
Number of Abilities := [Droplist of numbers]
Ability 1 Type := [Droplist of Abilites?]
Ability 1 Descr := ********************************
Ability 1 Val 1 := *************
Ability 1 Val 2 := *************
Weapon Type := [Droplist]
</pre><hr />
narf poit chez BOOM
September 13th, 2006, 05:04 PM
I like the idea of not changing the templatizer, just making a front-end to generate scripts.
Ed Kolis
September 13th, 2006, 05:05 PM
Eh, I was hoping to pretty it up a bit... make it a bit more intuitive somehow than just a big long laundry list of fields...
Suicide Junkie
September 13th, 2006, 08:16 PM
As far as CK's sample there, "number of abilities" should be automatic.
Just let the user add or delete abilities and track the total.
Ed Kolis
September 13th, 2006, 10:23 PM
Yeah, that was one thing I had in mind... another was display of the relevant images...
Captain Kwok
September 13th, 2006, 10:25 PM
You could have a box with the current image displayed. You could have arrows under the pic that allow the user to flip through the stack of pics available. Of course, it would also respond to the number the user type in for pic number.
Ed Kolis
September 13th, 2006, 10:36 PM
I was thinking maybe even a button you click to popup the Components.bmp or whatever and then you can click a mini http://forum.shrapnelgames.com/images/smilies/wink.gif
Black_Knyght
September 14th, 2006, 02:46 AM
Just from a novice's point of view, maybe make it both graphically functional ( and aesthetic? ) and beginner level user-friendly. I'm not a programmer, or a computer-whiz, and to be honest as appealing as it is it's dauntlingly complicated for a complete beginner.
Gandalf Parker
September 14th, 2006, 01:39 PM
I like the part about duplicating the data files and inserting choice boxes. It would make the program a jumping off point to doing more personalization. Semi-tutorial as you use it. You can see exactly what is not being modified, or what is and where it is in the file. It would make the user braver about diving in manually to try one of the items still left on default.
Id also love to see it offer pop-up explanations of each entry. Maybe calling a seperate outside file for that like a comma-dilimted file. That would make it easy for other people to expand on the help text
Gandalf Parker
Ed Kolis
September 15th, 2006, 03:31 PM
OK, I've got an editor for racial traits (they were among the simplest of the data files and do not have references to other files); you can add parameters (for tech grids, though the parameters are currently ignored) and (most importantly) Javascript code - see a number get squared, ooh ahh! http://forum.shrapnelgames.com/images/smilies/wink.gif As you can see in the attached screenshot, the "useless" fields that SE4 requires but ignores are filled in automatically http://forum.shrapnelgames.com/images/smilies/wink.gif
Ed Kolis
September 15th, 2006, 05:49 PM
Just thought I'd mention that I just now added a "quick-parser" which detects any errors in your data fields and highlights them red! Very simple to do given that I was already running the data through the script engine all at once - this time I just run some of it through! http://forum.shrapnelgames.com/images/smilies/wink.gif The quick-parser also lets you hover over a field and view its value; haven't tested it with actual templatized items, mainly because I haven't implemented those yet, but I imagine it would look something like this: [10, 20, 30, 40, 50] for a simple 5-level progression http://forum.shrapnelgames.com/images/smilies/laugh.gif
Black_Knyght
September 15th, 2006, 07:19 PM
Looks like you're on the right track to me !!!
vBulletin® v3.8.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.