Author: cazfi
Date: Mon Jan 25 04:13:26 2016
New Revision: 31580

URL: http://svn.gna.org/viewcvs/freeciv?rev=31580&view=rev
Log:
Move ai_fuzzy() from common/player.c to ai/difficulty.c

See patch #5915

Modified:
    trunk/ai/default/advmilitary.c
    trunk/ai/default/aicity.c
    trunk/ai/default/aiunit.c
    trunk/ai/difficulty.c
    trunk/ai/difficulty.h
    trunk/common/player.c
    trunk/common/player.h

Modified: trunk/ai/default/advmilitary.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advmilitary.c?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/ai/default/advmilitary.c      (original)
+++ trunk/ai/default/advmilitary.c      Mon Jan 25 04:13:26 2016
@@ -47,6 +47,7 @@
 #include "infracache.h" /* adv_city */
 
 /* ai */
+#include "difficulty.h"
 #include "handicaps.h"
 
 /* ai/default */

Modified: trunk/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Mon Jan 25 04:13:26 2016
@@ -48,6 +48,7 @@
 
 /* ai */
 #include "aitraits.h"
+#include "difficulty.h"
 #include "handicaps.h"
 
 /* ai/default */

Modified: trunk/ai/default/aiunit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiunit.c?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/ai/default/aiunit.c   (original)
+++ trunk/ai/default/aiunit.c   Mon Jan 25 04:13:26 2016
@@ -34,7 +34,6 @@
 #include "map.h"
 #include "movement.h"
 #include "packets.h"
-#include "player.h"
 #include "specialist.h"
 #include "traderoutes.h"
 #include "unit.h"
@@ -62,6 +61,7 @@
 #include "autosettlers.h"
 
 /* ai */
+#include "difficulty.h"
 #include "handicaps.h"
 
 /* ai/default */

Modified: trunk/ai/difficulty.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/difficulty.c?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/ai/difficulty.c       (original)
+++ trunk/ai/difficulty.c       Mon Jan 25 04:13:26 2016
@@ -17,6 +17,7 @@
 
 /* utility */
 #include "bitvector.h"
+#include "rand.h"
 
 /* common */
 #include "player.h"
@@ -217,3 +218,30 @@
 
   return 100;
 }
+
+/**************************************************************************
+  Return the value normal_decision (a boolean), except if the AI is fuzzy,
+  then sometimes flip the value.  The intention of this is that instead of
+    if (condition) { action }
+  you can use
+    if (ai_fuzzy(pplayer, condition)) { action }
+  to sometimes flip a decision, to simulate an AI with some confusion,
+  indecisiveness, forgetfulness etc. In practice its often safer to use
+    if (condition && ai_fuzzy(pplayer,1)) { action }
+  for an action which only makes sense if condition holds, but which a
+  fuzzy AI can safely "forget".  Note that for a non-fuzzy AI, or for a
+  human player being helped by the AI (eg, autosettlers), you can ignore
+  the "ai_fuzzy(pplayer," part, and read the previous example as:
+    if (condition && 1) { action }
+  --dwp
+**************************************************************************/
+bool ai_fuzzy(const struct player *pplayer, bool normal_decision)
+{
+  if (!is_ai(pplayer) || pplayer->ai_common.fuzzy == 0) {
+    return normal_decision;
+  }
+  if (fc_rand(1000) >= pplayer->ai_common.fuzzy) {
+    return normal_decision;
+  }
+  return !normal_decision;
+}

Modified: trunk/ai/difficulty.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/difficulty.h?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/ai/difficulty.h       (original)
+++ trunk/ai/difficulty.h       Mon Jan 25 04:13:26 2016
@@ -15,4 +15,6 @@
 
 void set_ai_level_directer(struct player *pplayer, enum ai_level level);
 
+bool ai_fuzzy(const struct player *pplayer, bool normal_decision);
+
 #endif /* FC__DIFFICULTY_H */

Modified: trunk/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.c?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/common/player.c       (original)
+++ trunk/common/player.c       Mon Jan 25 04:13:26 2016
@@ -19,7 +19,6 @@
 #include "fcintl.h"
 #include "log.h"
 #include "mem.h"
-#include "rand.h"
 #include "shared.h"
 #include "support.h"
 
@@ -1189,33 +1188,6 @@
     }
   } city_list_iterate_end;
   return NULL;
-}
-
-/**************************************************************************
-Return the value normal_decision (a boolean), except if the AI is fuzzy,
-then sometimes flip the value.  The intention of this is that instead of
-    if (condition) { action }
-you can use
-    if (ai_fuzzy(pplayer, condition)) { action }
-to sometimes flip a decision, to simulate an AI with some confusion,
-indecisiveness, forgetfulness etc. In practice its often safer to use
-    if (condition && ai_fuzzy(pplayer,1)) { action }
-for an action which only makes sense if condition holds, but which a
-fuzzy AI can safely "forget".  Note that for a non-fuzzy AI, or for a
-human player being helped by the AI (eg, autosettlers), you can ignore
-the "ai_fuzzy(pplayer," part, and read the previous example as:
-    if (condition && 1) { action }
---dwp
-**************************************************************************/
-bool ai_fuzzy(const struct player *pplayer, bool normal_decision)
-{
-  if (!is_ai(pplayer) || pplayer->ai_common.fuzzy == 0) {
-    return normal_decision;
-  }
-  if (fc_rand(1000) >= pplayer->ai_common.fuzzy) {
-    return normal_decision;
-  }
-  return !normal_decision;
 }
 
 /**************************************************************************

Modified: trunk/common/player.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.h?rev=31580&r1=31579&r2=31580&view=diff
==============================================================================
--- trunk/common/player.h       (original)
+++ trunk/common/player.h       Mon Jan 25 04:13:26 2016
@@ -434,8 +434,6 @@
 
 struct city *player_capital(const struct player *pplayer);
 
-bool ai_fuzzy(const struct player *pplayer, bool normal_decision);
-
 const char *love_text(const int love);
 
 enum diplstate_type cancel_pact_result(enum diplstate_type oldstate);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to