General > Discussion

Money: "Patch" included, but tester needed.

<< < (2/5) > >>

Bandobras:

--- Quote from: "Rei" ---That wouldn't work.
--- End quote ---

 
You are right. With this setup some missions on the territory of a state will not bother it, but erroneously bother a neighbouring state.

What about affecting happiness of all countries that have capital city in a given radius from the mission spot? On the premises that states are worried about close missions, even if not on their territory.


--- Quote ---The nation field is pretty darn tiny compared to the rest of the mission text,

--- End quote ---


This is not the main problem. Problem is in maintanance. There would be two fields with related information: position and nation. This is bad, beause they are likely to get out of sync. There is no much problem if you accidentaly move a mission form Beijing to New York (perhaps it happens in China Town?). But there is a problem if you send aircrafts to China and the game insists they are just flying to US. And there is a problem if US told you about the mission (based on nation field), but the game spawns it in China (based on position field). Then Chinese shoot your uncalled for aircrafts and US sends nukes at your base for ignoring them.

Moreover if the field is likely to be removed in the future, I would rather fix other bugs, than do this. In a complicated client-server application, such as q2, adding and removing fields is a horrible coding work --- you have to change lots of code sending, receiving, initializing, reading, writing, formats, order of sent bytes, etc. And even after that you get bugs and you don't now what they come from. For example, I have no clue if the fields you add need writing/reading between client and server, or on save/load game, and it's not that easy to see that (rgrep not always helps).


--- Quote ---and after all, I'm the one offering to write hundreds of mission script files here once you get autogenerated maps working better.  :) I already added it to all of the extant missions in missions.ufo.
--- End quote ---


Great! This file needs a lot of urgent work (I will be glad to answer your questions why some things there look as they look, thought for most the answer is: because nobody had the time to fix it :) ). But don't be so quick with changing things --- this is a team effort and we try hard to respect others' work:  to read and understand their code and discuss before we change things. There is so much work to do, we can't afford to waste anybody's work, or introduce chaos into the code. I think, by submitting without discussing the existing code, you risk that most of your patch will not be used, and I would be very sorry to see that happen... Fortunately there are some changes in the patch that look safe and nice, so not all will be lost... :)


--- Quote ---And yes, I would like SVN access because I may randomly feel like contributing more whenever I encounter a bug that's bothering me or want to implement some requested features.  ;)
--- End quote ---


I really hope you will contribute and I very kindly invite you to our open IRC channel. I do not have the power to grant you SVN access, and, I guess it's granted only after the contributor has proven himself able to reasonably discuss things he want's to change/add/remove. Mattn is the boss, but he is very busy, so IRC is a real help.


--- Quote ---New issue: Civilians.  Currently I'm just dealing with win/loss conditions.  Should we also take into account the number of civilians killed vs. the number that survived (and for that matter, aliens killed vs. survivors if there's a mission in which they can escape)?
--- End quote ---


Good points. Isn't it already implemented? I think at the end of a mission it tells you how many you rescued... Oh, you mean, afffect the state happiness by this? Sure! After we discuss the "happiness" flag...


--- Quote ---Old issue, resurfacing: Combat rewards are pretty pathetic.  So are penalties for failing to go to a mission.  With countries adjusting their payment to you based on how you perform, shouldn't we just remove those altogether?
--- End quote ---


A very important thing. I'm for doing as you say, but this is too serious (removing somebody's work) too discuss just between us. Please come to our IRC channel, or I can tell about it there but, frankly, I would rather not work as your proxy. :)

Bandobras:
I'm just reading your patch, the "happiness" part (that I think is likely to get in-game soon), more closely. I don't quite get the meaning of the various flags. What do you thing, what is the difference between funding, alienFriendly and happiness? Aren't they the same? Are funding and alienFriendly used in the SVN trunk, already? How? Do you use them in your patch?

For whatever reason, we don't use "fprintf(stderr", but other prints. Don't ask me why...

More questions will come...

Rei:
I'll try to get on IRC at some point, although I can't say when.  Is there a specific time that's best?

Are there any plans to have a "coordinate to nation lookup" function implemented any time soon?  Because I'd hate to see such a critical feature as nations actually caring whether you sit on your duff all day (vs actually fight the aliens) not get implemented simply because some day, some time in the unknown future, people plan to implement the nation lookup feature.  But if that code does get implemented, I promise to take care of modifying the game to use it in terms of nation happiness.  :)  It only took me about 15 minutes to update the missions.ufo file to add that field in.

As for the flags:

Funding: max funding provided by a nation.  If they're 100% happy with you, they'll give you 100% of that money.  If they're 50% happy with you, they'll give you 50% of that money.
Happiness: How happy the nation is with your work at any given point in time.
AlienFriendly: How much a nation tolerates alien activity.  The higher the alienFriendly value, the slower they will be to get upset with you for missing a mission and the faster they'll become thankful for you succeeding in a mission.  

As an example of how this goes:

The United Americas provides a base level funding of 110000, starts out at half happiness, and is 40% alien friendly.  If nothing happened between the start of the game and the first payday, you would get 110,000 * 0.5 = 55,000 credits from the United Americas.

Now lets say that Russia was attacked and  you succeeded in your mission.  The United Americas get the following positive reaction:

            nation->happiness /= pow(1 - nation->alienFriendly/100, 0.2);
            nation->happiness += nation->alienFriendly/100 / 50;

Lets look at what this does.  nation->alienFriendly/100 normalizes the percentage (i.e., 40% becomes 0.4, which is what you generally need to work with percents mathematically).  So this becomes:

            nation->happiness /= pow(1 - 0.4, 0.2);
            nation->happiness += 0.4 / 50;

Lets look at the first line.  One minus a percentage will always be between zero and one.   So here, the more alien friendly they are, the closer the difference is to zero, which means a lot of change.  The closer it is to one (i.e., alien unfriendly), the closer to one it is, which means the less it will change.  Raising that to a >1 power would make the number approach zero, while raising it to a <1 power makes it approach 1.  Since we're raising it to the 0.2 power, that pow() statement makes us not change as much in happiness as the "strong positive reaction" formula, which is the same but missing the pow statement.  

The second line is pretty simple: it's a constant increment, based on the alienFriendly value.  Adding this in makes it easier to recover from completely ticking off a nation.  If their happiness got down to, say, 0.00001, trying to recover it with /= statements alone would take forever.

So, what does this work out to?  

            nation->happiness /= pow(0.6, 0.2);
            nation->happiness += 0.008;

Which is:

            nation->happiness = 0.5 / pow(0.6, 0.2) + 0.008;

Which equals ~0.56.  Even for reasonably alien-tolerant America, Attacks in other peoples' countries don't change attitudes very quickly.  Now your pay from the United Americas would be 110,000 * 0.56 = 61,600 credits.  

Now, lets say that New York was attacked and you didn't defeat the aliens.  Well, that would be a "strong negative reaction":

              nation->happiness *= nation->alienFriendly/100;

This is pretty straightforward: we convert alienFriendly to a decimal value, then we multiply that value times the happiness.  In this case:

              nation->happiness = 0.56 * 0.4;

This equals ~0.26.  Thus, your new pay from recently-angered America will be 110,000 * 0.26 = 28,600.

Now, what if this had been the arabs watching you save another country and then having one of their cities hit?  They'll judge you more harshly.  So, after the first attack, their opinion of you is only up to ~0.53.  After having an arabian city hit, however, it would go all the way down to 0.13.

Of course, even for the arabs, who don't recover happiness at your failure very well, a success at stopping a raid in one of their countries will still significantly help their happiness rating -- boosting it to 0.20.  A success in America after your failure would get you all the way back up to 0.49 -- right near your starting happiness level.

The consequence of this system is that you need to make careful calls on your base placement (or at least will, once you don't see every mission that pops onto the map  ;)  ).  Do you build near the players that will get upset with you more easily and risk alienating your bigger, more tolerant funders?  Or vice versa?

Anyways, feel free to ask any other questions or favors you have; this is my first patch for this game, so I expect to be grilled.  ;)

Bandobras:

--- Quote from: "Rei" ---I'll try to get on IRC at some point, although I can't say when.  Is there a specific time that's best?
--- End quote ---


Middle-European time. :)
Perhaps try around 18:00 UTC.


--- Quote ---Are there any plans to have a "coordinate to nation lookup" function implemented any time soon?
--- End quote ---


You mean, with nation borders data? I guess not. This is a lot of data to dig out, store in-game, look up. We are still trying to freeze thing and get 2.0 out (not much success with the freezing part).


--- Quote ---Because I'd hate to see such a critical feature as nations actually caring whether you sit on your duff all day (vs actually fight the aliens) not get implemented

--- End quote ---


You are totally right. What about my proposal to affect nations based on the distance from mission to capital? Having capitals on map in game will be fun, regardless of happiness, and it's much easier to implement than borders. If that's not OK then, based on your patch, we will make all nations equally caring, wherever the mission happens. This is minimalistic, but with such code we should actually start, let others review it, test it, and only then move to bigger changes... Believe me, this code is very brittle...

As for the flags:


--- Quote ---Funding: max funding provided by a nation.  [...]
--- End quote ---


Oh, I see, this is based on economy and fixed (unless we implement economies crumbling due to alien invasion). So this is not a dublet of happiness, good.


--- Quote ---Happiness: How happy the nation is with your work at any given point in time.
AlienFriendly: How much a nation tolerates alien activity.
[...lots of fine ideas and reasonable pseudocode...]
--- End quote ---


You didn't say if alienFriendly is actually used anywhere in the current code, but a quick rgrep shows it is not. Then, based on the KISS principle, especially when touching a long forgotten part of code, and especially before 2.0, I propose to merge happiness and alienFriendly, under the name alienFriendly (we can even change the name to "happiness", that should be safe). In other words I propose to make the alien-friendliness in your calculations a constant for all nations, or perhaps base it on soldiers, scientists or funding fields --- there is enough to choose from. Perhaps funding is the simplest choice, as the soldiers and scientists may well disappear in future versions...

So, for instance, the welthier the nation is, the more careful you have to be to please it. Not totally trivial, but simple enough for most players to notice after a dozen of games. What do you think?

If we get this, we (or you) can move to having this in savegames (is it there already?), then taking into account saved civilians, and then --- who knows, capitals, borders, or even your nation fields in missions.ufo, though I will voice my doubts again when we get to that point.


--- Quote ---this is my first patch for this game, so I expect to be grilled.  ;)
--- End quote ---


Not my intention, really. :D I'm just trying to help you (I was a UFO:AI newbie a month ago, too) and to get you hacked for this project by accepting your patch, without getting us stoned by an angry mob of coders and testers. ;> I also hope, if there are any old ideas, either in some forgotten docs, or on the forum, about e.g. how saved civilians should affect happiness or what "soldiers" and "scientists" mean, they can emerge due to this thread...

Rei:
That's a tough time for me to get on IRC -- I'm at work then  :P  This weekend would work.  I'm on now, if that counts   ;)

All great ideas; we should discuss them as a group.  I'm not so sure about the capitals idea; there are so many national capitals out there, and how we'd list them on a 800x600 default map... and what about, say, Russia, whose capital is a third of the way around the world from its east coast?

On the other hand, your ideas for replacing alienFriendly are all quite reasonable and workable.  Lets chat on IRC and see if that's what others want.  I didn't want to take out/coopt a variable that another person wanted to use to be happiness, so I added a new field and used alienFriendly to mean... well, how much they tolerate the aliens  :).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version