 |
|  |
 |
|
Gedrin
|
|
Hi all;
Well I think I have settled on a formula for terrorism that I am happy with. I was basing the eqns on a players score vs the average but then as the average score climbed climbed I found the gap between the leader (invariable me) and the average needed to get stupid large before terrorism took place.
So the eqn I settled on has nothing to do with actual score but with ratios of scores.
For example if the scores are:
1x 2x 3x 4x 5x 6x 7x 8x then the number of terror strikes will be the same no matter how big x might be.
In addition I have included a factor of how popular the target is. If everyone in the world (or at least those with lower scores) love you then you will not suffer any strikes. The number of strikes in my spreadsheets can climb as high as 12 if your score is 60% of the total and everyone is at war with you.
The code follows but I have NOT TESTED this yet. I am particularly leary about the RegardLevel function and how things will pan out in the early game when scores are very low, but I'll let everyone know how the testing goes. If any are adventurous then feel free:
//Trigger Setup
trigger 'Setup' when ((g.player == 0) && (g.year == 0)) {
// This is the value from userprofile.txt that details the number of players that STARTED the game.
// This may of course be very different from the number currently in the game.
numberOfPlayers = Preference("NumPlayers");
// note the 196 is the map bonus for the gigantic map and I have not figured out the right values for other sized maps.
// If smalled map sizes are used without updating this value it will cause fewer strikes and cause funny stuff as the scores rise.
scoreBonus = g.maxscore - 3600 + (75 * numberOfPlayers) + 196;
}
messagebox 'PopTerrorized' {
// POP_TERRORIZED defined in info_str.txt reads like:
// POP_TERRORIZED "Foreign backed terrorists strike in [city.1.name]. Casualties are high."
Text(ID_POP_TERRORIZED);
MessageType("WARNING");
}
trigger 'AveScoreEff' when (g.player >= 0) {
// Player = 0 is the Barbarian who does not suffer from terrorist attacks
// but we still need the total score
if (g.player == 0) {
totalScore = 0;
index = 1;
while (index < Preference("NumPlayers")) {
if (IsPlayerAlive(index) == 1) {
SetPlayer(1,index);
totalScore = totalScore + player.1.score - scoreBonus;
}
index = index + 1;
}
totalScoreSqd = totalScore * totalScore;
} else {
SetPlayer(1,g.player);
strikes = 0;
index = 1;
// The following is the sum for each enemy still alive and with a lower score than me:
// Regard(enemy towards me) * (myScore/enemyScore -1) * enemyScore/totalScore * myScore/totalScore
// = his opinion of me * how much I am beating him by * how strong he is * how strong I am
// = 1/totalScore^2 * SUM ( Regard * myScore * (myScore - enemyScore) )
while (index < numberOfPlayers) {
SetPlayer(2,index);
// this enemy must be alive and have a lower score to make terrorist strikes.
if ((IsPlayerAlive(index) == 1) && (player.1.score > player.2.score)) {
myScore = player.1.score - scoreBonus;
enemyScore = player.2.score - scoreBonus;
strikes = strikes + RegardLevel(index,g.player) * myScore * (myScore - enemyScore);
}
index = index +1;
}
// This division is deferred til now for speed and accuracy from rounding errors.
strikes = strikes / totalScoreSqd;
// Now resolve all the strikes.
// Note that CityCount > 0 is not the same as IsPlayerAlive. Consider turn 0.
// The chances that a terrorist strike kills a civ's last city is small but not nil
cityCount = Cities (g.player);
while ((strikes > 0) && (cityCount > 0)) {
destCity = Random (cityCount);
SetCityByIndex(1,g.player,destCity);
// Always message BEFORE reducing pop since it might destroy the city
Message(g.player, 'PopTerrorized');
AddPops(city.1, -1);
cityCount = Cities (g.player);
strikes = strikes - 1;
}
}
}
}
Gedrin
[This message has been edited by Gedrin (edited October 20, 2000).]
|
|
|  |
 |
|
Gedrin
|
|
Once again further testing has shown a mistake.
This time it was in my spreadsheet I used to justify the line:
strikes = (numberOfPlayers*strikes) / (totalScore*totalScore);
Since the number of terrorists increases as the number of players these two combine to introduce a factor of numberOfPlayers^2
So I corrected my spreadsheet and found out why in my 8 players games I get royally screwed when I've only got about 20% of the total score.
So the correction to:
strikes = (5*strikes) / (totalScore*totalScore);
keeps the strikes high enough without spelling doom.
So with every civ holding you in neutral regard this will cause the following number of strikes:
numberOf Targets Score as % of Total
Players 0.4 0.5 0.6 0.7
1 #DIV/0! #DIV/0! #DIV/0! #DIV/0!
2 0.00 0.00 1.20 1.80
3 0.90 1.88 2.40 2.48
4 1.80 2.50 2.80 2.70
5 2.25 2.81 3.00 2.81
6 2.52 3.00 3.12 2.88
7 2.70 3.13 3.20 2.93
8 2.83 3.21 3.26 2.96
9 2.93 3.28 3.30 2.98
10 3.00 3.33 3.33 3.00
11 3.06 3.38 3.36 3.02
12 3.11 3.41 3.38 3.03
13 3.15 3.44 3.40 3.04
14 3.18 3.46 3.42 3.05
15 3.21 3.48 3.43 3.05
16 3.24 3.50 3.44 3.06
17 3.26 3.52 3.45 3.07
18 3.28 3.53 3.46 3.07
19 3.30 3.54 3.47 3.08
20 3.32 3.55 3.47 3.08
21 3.33 3.56 3.48 3.08
22 3.34 3.57 3.49 3.09
23 3.35 3.58 3.49 3.09
24 3.37 3.59 3.50 3.09
25 3.38 3.59 3.50 3.09
26 3.38 3.60 3.50 3.10
27 3.39 3.61 3.51 3.10
28 3.40 3.61 3.51 3.10
29 3.41 3.62 3.51 3.10
30 3.41 3.62 3.52 3.10
31 3.42 3.63 3.52 3.11
32 3.43 3.63 3.52 3.11
Note also that all civs with whom you have no contact hold you in the same regard as 'love' meaning they do not contribute. Another reason not to build the P. Stone.
Notice also the strikes you suffer increase with more players and the top of the curve decreases. Which makes sense when I think about it.
I think I am finally done my terrorist trigger.
Gedrin
[This message has been edited by Gedrin (edited October 27, 2000).]
[This message has been edited by Gedrin (edited October 27, 2000).]
|
|
|  |
 |
|  |
 |
|  |
All times are GMT. The time now is 05:13. Apolyton Time is 00:13. |
top of page
|
|
|
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
|
|
|
|
|
|