Freeciv Forum Index Freeciv
'Cause civilization should be free!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Little patch for ai/advdiplomacy.c

 
Post new topic   Reply to topic    Freeciv Forum Index -> Contribution
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sat Feb 03, 2007 12:42 pm    Post subject: Little patch for ai/advdiplomacy.c Reply with quote

Due to what I consider bugs in the ai(easy to exploit anyway), I've made a few changes to my ai/advdiplomacy.c. Some are logical and probably just forgotten when it was written.

The first makes the ai only consider non obselete wonders, since they can't help it(except maybe increase a little tourism which freeciv doesn't do). The second is a result of me sometimes getting 100,000 or 200,000 or more in gold, but not having the ai consider it so sometimes I'll have a massive amount of gold, a small army, and the ai wants to attack me for being weak, but by the time the ceasefire after first meeting runs out, I can have a formidable army. The third's for the benefit of having Eiffel Tower and not having met an ai yet, because you can get 1000 love yet have never met.

Index: ai/advdiplomacy.c
===================================================================
--- ai/advdiplomacy.c (revision 12590)
+++ ai/advdiplomacy.c (working copy)
@@ -669,11 +669,20 @@

built_impr_iterate(pcity, id) {
want += impr_build_shield_cost(id);
- if (is_great_wonder(id)) {
- want += impr_build_shield_cost(id) * 2;
- } else if (is_small_wonder(id)) {
- want += impr_build_shield_cost(id);
- }
+
+ if (ai_handicap(pplayer, H_EXPERIMENTAL)) {
+ if (is_great_wonder(id) && !improvement_obsolete(target, id)) {
+ want += impr_build_shield_cost(id) * 2;
+ } else if (is_small_wonder(id) && !improvement_obsolete(target, id)) {
+ want += impr_build_shield_cost(id);
+ }
+ } else {
+ if (is_great_wonder(id)) {
+ want += impr_build_shield_cost(id) * 2;
+ } else if (is_small_wonder(id)) {
+ want += impr_build_shield_cost(id);
+ }
+ }
} built_impr_iterate_end;
} city_list_iterate_end;
unit_list_iterate(target->units, punit) {
@@ -712,6 +721,10 @@
distance = player_distance_to_player(pplayer, target);
ai->diplomacy.player_intel[target->player_no].distance = distance;

+ /* If they have too much more gold than us, we should be worried
+ * because they'll be able to build a quick force against us. */
+ fear += (target->economic.gold - pplayer->economic.gold) / 1000;
+
/* Tech lead is worrisome. FIXME: Only consider 'military' techs. */
fear += MAX(get_player_research(target)->techs_researched
- get_player_research(pplayer)->techs_researched, 0) * 100;
@@ -911,9 +924,11 @@
}

/* Increase the love if aplayer has got a building that makes
- * us love him more. Typically it's Eiffel Tower */
- pplayer->ai.love[aplayer->player_no] +=
- get_player_bonus(aplayer, EFT_GAIN_AI_LOVE) * MAX_AI_LOVE / 1000;
+ * us love him more. Typically it's Eiffel Tower. But only if the
+ * players have met so far. */
+ if (!NEVER_MET(pplayer, aplayer))
+ pplayer->ai.love[aplayer->player_no] +=
+ get_player_bonus(aplayer, EFT_GAIN_AI_LOVE) * MAX_AI_LOVE / 1000;
} players_iterate_end;

/* Can we win by space race? */
Back to top
Per
Code Developer


Joined: 17 May 2004
Posts: 667
Location: Trondheim, Norway

PostPosted: Mon Feb 05, 2007 5:47 am    Post subject: Reply with quote

Thanks for your contribution! The Eiffel fix is right on target. The obsoletion check should be made with respect to the considering player, not target. The fear check should, I think, not be relative to considering player's gold, but instead take into account the number of cities that the target can buy units in. If he has lots of gold and few cities, he may not be able to rush buy a large enough army in time.

I made a new patch and added it to the ticket: http://rt.freeciv.org/Ticket/Display.html?id=35145

Please test it and let us know if it works out right!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Freeciv Forum Index -> Contribution All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group