.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #61  
Old October 18th, 2004, 11:51 PM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

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!

I don't suppose throwing together my own interpreter would run code any faster than Microsoft's reflection, would it? 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

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 ) 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 )

Recursive algorithm for finding factorials:
Code:

fact(0) -> 1.
fact(1) -> 1.
fact(n) -> if n < 0 error() else n * fact(n - 1).



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! (Nah, I won't have the time, and besides, I've barely scratched the surface of the language )

(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
__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
  #62  
Old December 6th, 2004, 06:19 PM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

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!

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?

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
__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
  #63  
Old December 6th, 2004, 07:27 PM
Atrocities's Avatar

Atrocities Atrocities is offline
Shrapnel Fanatic
 
Join Date: Dec 2000
Location: USA
Posts: 15,630
Thanks: 0
Thanked 30 Times in 18 Posts
Atrocities is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

Sounds like your enjoying yourself Ed. What do you have planned for SE V?
__________________
Creator of the Star Trek Mod - AST Mod - 78 Ship Sets - Conquest Mod - Atrocities Star Wars Mod - Galaxy Reborn Mod - and Subterfuge Mod.
Reply With Quote
  #64  
Old December 6th, 2004, 09:51 PM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

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 )

... 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!

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 )

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??? )

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...
__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
  #65  
Old December 7th, 2004, 01:21 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: SE4 Templatizer Ready for Download!

Quote:
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??? )
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 . This uses the standard form of the functions.
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #66  
Old December 25th, 2004, 03:57 PM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

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...
__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
  #67  
Old January 6th, 2005, 06:06 PM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

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! 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! ) So, instead of something like this...

Code:

*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*



you could have this:

Code:

*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*

__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
  #68  
Old January 6th, 2005, 10:31 PM
NarfsCompIsBack's Avatar

NarfsCompIsBack NarfsCompIsBack is offline
Corporal
 
Join Date: Jan 2005
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
NarfsCompIsBack is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

Woot! Not that I can do anything with it right now.
Reply With Quote
  #69  
Old January 23rd, 2005, 09:52 AM
Nodachi's Avatar

Nodachi Nodachi is offline
First Lieutenant
 
Join Date: Mar 2002
Location: North Carolina
Posts: 720
Thanks: 0
Thanked 0 Times in 0 Posts
Nodachi is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

How's this coming along, Ed?
BTW, the link for this is incorrect on your site.
__________________
This is the 21st century, right? Then where the hell is my flying car?
Reply With Quote
  #70  
Old January 23rd, 2005, 11:51 AM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: SE4 Templatizer Ready for Download!

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

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

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 ), rather than writing a lot of new code.
__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:22 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.