Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Alternative Civs > Clash of Civilizations > Modified macro language description
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
04.Sep: `FC` 2.0.5 COMPLETED AND RELEASED
27.Jul: `FC` 2.0.4 COMPLETED AND RELEASED
16.Jul: `FC` 2.0.3 COMPLETED AND RELEASED

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
Blade Runner is offline Blade Runner
Prince
Belgium
Jan 1970
time: 06:13
Exclamation  Old Post 07-09-1999 12:35
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
Modified macro language description Lose 30 kilos (of popups)

C - - language description (version 2)

Please read it (and criticize it)

Rules:
1. Basic types: Number (no distinction between real and integers)
String
Boolean (true and false)

(I steal the idea from BASIC)
Numbervariable
Stringvariable$
Booleanvariable%
Users neednt declare the variables. Enough just define them.

2. Non case sensitive.
3. Two different kind of code module: Library
Trigger
4. Library: only functions and local variables in functions, but no constants and global variables.
Trigger: functions, variables, constants and the main function which has the same name like the trigger source code and will start when the system call that trigger.
5. Functions can contain variable declaration, but no constant declaration. Those variables are local in the function.
6. Comments with // (double slash).

Syntax:

Library source file:

// here start the library source code
Library;

Function1([Name1, Name2, ...]) {
[Var
Name1 := Value;
Name2 := Value;
Array Name1[Index1, Index2, ...];
Array Name2[Index1, Index2, ...];
EndVar]
Statements;
Return [NameX];
}

Function2([Name1, Name2, ...]) {
[Var
Name1 = Value;
Name2 = Value;
EndVar]
Statements;
Return [NameX];
}

// Here is the end of the library source code. The file name must have a .cli extension.

// Here starts the trigger source code.

Trigger;

[Library Library1Name;
Library Library2Name;]

[Const
Name1 = Value;
Name2 = Value;
EndConst

Var
Name1 = Value;
Name2 = Value;
Array Name1[Index1, Index2, ...];
Array Name2[Index1, Index2, ...];
EndVar;]


Function1([Name1, Name2, ...]) {
[Variable
Name1 = Value;
Name2 = Value;
EndVariable]
Statements;
Return [NameX];
}

Function2([Name1, Name2, ...]) {
[Variable
Name1 = Value;
Name2 = Value;
EndVariable]
Statements;
Return [NameX];
}

Trigger([Name1, Name2, ...]) {
[Var
Name1 = Value;
Name2 = Value;
EndVar]
Statements;
Return;
}
// Here is the end of the trigger source code. The file name must have a .ctr extension.

Everything between [ and ] is optional, except the array declaration. I.E.: Array Name$[ Index1, Index2, ... ], this is the part of the syntax.
The Trigger function ALWAYS Void. The Trigger Function name the same like the trigger source code name and the same like the built in trigger name:
Let say we have a trigger in the game: EndOfTurn
In this case the trigger source code name is: EndOfTurn.ctr
The trigger main function:
Void EndOfTurn() {
[Var
Name1 = Value;
Name2 = Value;
Endvar]
Statements;
Return;
}


Instructions:

Statements:

Simple Statements:

Assignment:
variable = expression;
expression: must be type compatible with the variable

Function calls:
i.e.:
MyFunction();

Structured statements:

1. Compound statement:
All the simple statements between the { and } brackets.
i.e.:
{
a = 158;
b = MyFunc(125,25);
}

2. If statement:

If (Boolean expression)
Simple or compound statement1
//optional
else
Simple or compound statement2

If the Boolean expression is true then statement1 is executed, otherwise the statement2 is executed.

3. While statement:

While (Boolean expression)
Simple or compound statement

The while statement executes as long as the Boolean expression returns true.

4. Do While statement:

Do
Simple or compound statement
While (Boolean expression)

The while statement executes as long as the Boolean expression returns true.

5. For statement:

For(Initial value, final value, counter)
Simple or compound statement

The for statement executes as long as the final value is true.


Expression:
The order of the execution can be determined by brackets ( and )
1. Numeric:

Constant (i.e. 16)
Variable (i.e. N)
Function Sum(A, B, C);
Addition + Op1 + Op2 (i.e. 16+12)
Subtraction - Op1 - Op2 (i.e. 16-N)
Multiplication * Op1 * Op2 (i.e. 12*N)
Division / Op1 / Op2 (i.e. 12/2)
Negation - -Op (i.e. -N)
Increment ++ Op++ (i.e. ++N) Op must be a number variable!
Decrement -- Op-- (i.e. N--) Op must be a number variable!


2. String

Constant (i.e. 'AbcD')
Variable (i.e. S)
Function Uppercase('abc');
Concatenation + Op1 + Op2 (i.e. S+'cd')

3. Boolean

Constant (i.e. true)
Variable (i.e. T)
Function Good();
And & Op1 & Op2
Or | Op1 | Op2
Not ! ! Op

Relational operators (Result ALWAYS Boolean)
Numeric: (Op1 and Op2 are numeric expressions)
Equality == Op1 == Op2
Inequality != Op1 != Op2
Less-than < Op1 < Op2
Greater-than > Op1 > Op2
Less-than or equal to <= Op1 <= Op2
Greater-than or equal to >= Op1 >= Op2

String: (Op1 and Op2 are string expressions)
Equality == Op1 == Op2
Inequality <> Op1 <> Op2

Calling Order:
Let say we wold like to play with the "myscenario" scenario. The system first start to load all the triggers and libraries from the default directory After looking for triggers and libraries in the "myscenario" scenario directory:
i.e.:
first ...\default\mod\*.ctr (triggers)
...\default\mod\*.clb (libraries)
after
...\myscenario\mod\*.ctr (triggers)
...\myscenario\mod\*.clb (libraries)
If the system find triggers in the "myscenario" library with the same names like the defaults, then the system will use those "myscenario" triggers to control the game.

I will wait this weekend (Sunday evening). If nobody wants any changes, I start to write the interpreter from next Monday.

// 1. 09-07-1999 I chnage from := to = and = to ==.
// 2. 09-08-1999 Users neednt declare the variables. It is only an option. Enough just define them.


Blade Runner

[This message has been edited by Blade Runner (edited September 07, 1999).]
[This message has been edited by Blade Runner (edited September 07, 1999).]
[This message has been edited by Blade Runner (edited September 07, 1999).]
[This message has been edited by Blade Runner (edited September 08, 1999).]

Mark_Everson is offline Mark_Everson
Clash of Civilizations Project Lead
Canton, MI
Jan 1970
time: 00:13
Thumbs up  Old Post 07-09-1999 20:20 Visit Mark_Everson's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Lose 30 kilos (of popups)

Blade Runner:

I Still don't like the := operator...
I think younger people that have not been subjected to Pascal will wonder what planet we flew in from

I think everything looks good. Could you work up an example with pretend function names in it using both functions and triggers? It would be easier for me and many others to evaltuate with a concrete example, I think. How about re-doing mca's XML trial using your language?

Blade Runner is offline Blade Runner
Prince
Belgium
Jan 1970
time: 06:13
Post  Old Post 08-09-1999 02:19
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton, buy Civilization: The Boardgame

Mca's examples with the new syntax.


//This event will create the Angry Mothers civ in 20,30 and give the
//Nasty Evil Buggers 1000 monetary units and the Evil Empire tech
//if the Nasty Evil Buggers conquer the Really Important Province
//before 1230 OR if the Annoyingly Good Guys are destroyed before that same year

Trigger;

var
REP$ = "Realy Important Province";
NEB$ = "Nasty Evil Buggers";
AGG$ = "Annoyingly Good Gays";
AM$ = "Angry Mothers";
Tech$ = "Evile Empire";
endvar

Turnbeginnig(BeginYear)
{
If (BeginYear < 1230)
{
If (Owner(REP$)) == Civ(NEB$) | Destroyed(AGG$))
{
CreateCiv(20,30,AM$);
NewTech(NEB$) = Tech$;
Treasure(NEB$) = Treasure(NEB$) + 1000;
}
}
}

// The name of this trigger file will be Turnbeginnig.ctr.

The another example:

//This procedure will show a "You are really poor" message to all players of
//civilizations that have less than 100 monetary units or less than 2 cities and
//the turn is year 1900.

Trigger;

Var
Message$ = "You are really poor";
I;
Treasury;
Cities;
Name$ = "";
Dummy1;
Dummy2;
Dummy3;
EndVar

Turnbeginning(BeginYear)
{
If (BeginYear == 1900)
{
For(0,MaxCivs-1,I++)
{ GetCiv(I,Name$,Treasury,Cities,Dummy1,Dummy2,Dummy
3);
If(Treasury < 100 | Cities <= 2)
MessageBox(Message$);
}
}

// The name of this trigger file will be Turnbeginnig.ctr too.

Looks better than the XML.

Blade Runner
[This message has been edited by Blade Runner (edited September 08, 1999).]
[This message has been edited by Blade Runner (edited September 08, 1999).]

Mark_Everson is offline Mark_Everson
Clash of Civilizations Project Lead
Canton, MI
Jan 1970
time: 00:13
Thumbs up  Old Post 08-09-1999 05:43 Visit Mark_Everson's homepage!
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Get a bigger avatar today!

Blade Runner:

Thanks. Yes it looks much better than the XML IMO. I am not sure about all of it, but since its a made-up example it doesn't matter too much. The one that has me really confused is near the bottom of the post:

Civ(I,Treasury,Cities);

I don't understand what it does... I was expecting something like:

If( Civ(I,Treasury) < 100 | Civ(I,numCities) <= 2)...

Anyway I'm sure we can make the little details work!

Osiris is offline Osiris
Settler

Sep 1999
time: 05:13
Post  Old Post 08-09-1999 08:20
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton buy from Amazon

errrr, I really dont want to have a Pascal style language, The reason I learned C++ is because I hated the structuring of variables, ESPECIALLY not being able to create them within the code.
The only reason I learned and used Pascal is to get an A in a programming class, and I swore to myself I would never touch that language or language type again.

Blade Runner is offline Blade Runner
Prince
Belgium
Jan 1970
time: 06:13
Post  Old Post 08-09-1999 11:06
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton, buy Civilization 2

Mark,

My idea was: You can get all the important variables from a civ just one function calling.
I.E.: Civ(Number, Name, Treasury, Territory, RelativeStrength, BlaBla, ...);
(When you call the Civ function you can use the Number or the Name, and you will get back the informations in the rest of the variables.)

Osiris,

To use the variable declaration part are only an option. I used in my example because I write Pascal programs 15 years ago. Here is an another example without variable declaration:


//This event will create the Angry Mothers civ in 20,30 and give the
//Nasty Evil Buggers 1000 monetary units and the Evil Empire tech
//if the Nasty Evil Buggers conquer the Really Important Province
//before 1230 OR if the Annoyingly Good Guys are destroyed before that same year

Trigger;


Turnbeginnig(BeginYear)
{
REP$ = "Realy Important Province";
NEB$ = "Nasty Evil Buggers";
AGG$ = "Annoyingly Good Gays";
AM$ = "Angry Mothers";
Tech$ = "Evile Empire";
If (BeginYear < 1230)
{
If (Owner(REP$)) == Civ(NEB$) | Destroyed(AGG$))
{
CreateCiv(20,30,AM$);
NewTech(NEB$) = Tech$;
Treasure(NEB$) = Treasure(NEB$) + 1000;
}
}
}

// The name of this trigger file will be Turnbeginnig.ctr.


Blade Runner


[This message has been edited by Blade Runner (edited September 08, 1999).]
[This message has been edited by Blade Runner (edited September 08, 1999).]

Blade Runner is offline Blade Runner
Prince
Belgium
Jan 1970
time: 06:13
Question  Old Post 08-09-1999 11:36
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Enter the AD-FREE zone

Another thing:

I imagine a few complex function calling to get and set important variables. These need to organized in logic way.

1. GetGame(Players, CivNum, MapMeasureX, MapMeasureY, ...
2. GetCiv(CivNumber, Name, Computer, Treasury, Cities, Teritory, MilitaryStrength, Government, ...
3. GetMap(X, Y, City, SurfaceType, SurfaceSubType, IsProvince, MMilitaryTF, ...
4. GetProvinces(ProvNumber, ProvCivNumber, ProvCivname, Population, PMilitaryTF, ...

If we organize the game system this way, the users neednt remember 100 or more built-in function. They can call the right function, and they get all the information. The built-in function calling has Built-in variables. If you want to keep the value you need to store own variable or array. On the other side if we syncronized all the built-in variables that consume a lot of valuable processor time. IMHO enough to syncronize the value when the macro call the built-in getter function. The setter functions are the same.

Blade Runner
[This message has been edited by Blade Runner (edited September 08, 1999).]

Mark_Everson is offline Mark_Everson
Clash of Civilizations Project Lead
Canton, MI
Jan 1970
time: 00:13
Post  Old Post 09-09-1999 06:25 Visit Mark_Everson's homepage!
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Suffering from ads?

Blade Runner:

Well, I have some scepticism about the GetGame(Players, CivNum, MapMeasureX, MapMeasureY, ... type functions. But you're the one coding it so try whatever you think will work best. I admit I don't think in terms of scenario design much. You're probably right that to have some functions that access all the most common things to tweak is the most important.

Thanks for losing the :=

Blade Runner is offline Blade Runner
Prince
Belgium
Jan 1970
time: 06:13
Post  Old Post 09-09-1999 12:32
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

Mark,

I'm not really convinced by my new idea either. At later stages I need to investigate what the quickest solution is: whether this means changing the built-in variables synchron in the java code, or synchronizing the variables when the user calls a function. I seems to me that he function calling is quicker, but I will experiment when we have the alfa version of the game and the macro interpreter.

Blade Runner

TheLimey is offline TheLimey
Prince

May 2000
time: 05:13
Post  Old Post 26-06-2000 01:29
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Full PM-box? Change here!

I would hope you've considered implementing events rather than simple triggers.

E.G. Combat is an event. You could abort it based on a condition, or make changes to data entities, before it happens much like overloading in C++.

Mark_Everson is offline Mark_Everson
Clash of Civilizations Project Lead
Canton, MI
Jan 1970
time: 00:13
Thumbs up  Old Post 06-07-2000 22:42 Visit Mark_Everson's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Help yourself to an AD-FREE life

TheLimey:

I agree, events are something we should have. I will leave it to Blade Runner for a spec (assuming he agrees also) when he returns.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:13.
Apolyton Time is 00:13.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0454 seconds (90.98% PHP - 9.02% MySQL) with 30 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net