Freeciv21
Develop your civilization from humble roots to a global empire
metaknowledge.cpp
Go to the documentation of this file.
1 /*
2 _ ._ Copyright (c) 1996-2021 Freeciv21 and Freeciv contributors.
3  \ | This file is part of Freeciv21. Freeciv21 is free software: you
4  \_| can redistribute it and/or modify it under the terms of the
5  .' '. GNU General Public License as published by the Free
6  :O O: Software Foundation, either version 3 of the License,
7  '/ \' or (at your option) any later version. You should have
8  :X: received a copy of the GNU General Public License along with
9  :X: Freeciv21. If not, see https://www.gnu.org/licenses/.
10  */
11 
12 // common
13 #include "diptreaty.h"
14 #include "game.h"
15 #include "map.h"
16 #include "tile.h"
17 #include "traderoutes.h"
18 
19 #include "metaknowledge.h"
20 
25 static bool is_tile_seen_cadj(const struct player *pow_player,
26  const struct tile *target_tile)
27 {
28  // The tile it self is unseen.
29  if (!tile_is_seen(target_tile, pow_player)) {
30  return false;
31  }
32 
33  // A cardinally adjacent tile is unseen.
34  cardinal_adjc_iterate(&(wld.map), target_tile, ptile)
35  {
36  if (!tile_is_seen(ptile, pow_player)) {
37  return false;
38  }
39  }
41 
42  // They are all seen.
43  return true;
44 }
45 
50 static bool is_tile_seen_adj(const struct player *pow_player,
51  const struct tile *target_tile)
52 {
53  // The tile it self is unseen.
54  if (!tile_is_seen(target_tile, pow_player)) {
55  return false;
56  }
57 
58  // An adjacent tile is unseen.
59  adjc_iterate(&(wld.map), target_tile, ptile)
60  {
61  if (!tile_is_seen(ptile, pow_player)) {
62  return false;
63  }
64  }
66 
67  // They are all seen.
68  return true;
69 }
70 
74 static bool is_tile_seen_city(const struct player *pow_player,
75  const struct city *target_city)
76 {
77  // Don't know the city radius.
78  if (!can_player_see_city_internals(pow_player, target_city)) {
79  return false;
80  }
81 
82  // A tile of the city is unseen
84  city_tile(target_city), ptile)
85  {
86  if (!tile_is_seen(ptile, pow_player)) {
87  return false;
88  }
89  }
91 
92  // They are all seen.
93  return true;
94 }
95 
100 static bool is_tile_seen_traderoute(const struct player *pow_player,
101  const struct city *target_city)
102 {
103  // Don't know who the trade routes will go to.
104  if (!can_player_see_city_internals(pow_player, target_city)) {
105  return false;
106  }
107 
108  // A tile of the city is unseen
109  if (!is_tile_seen_city(pow_player, target_city)) {
110  return false;
111  }
112 
113  // A tile of a trade parter is unseen
114  trade_partners_iterate(target_city, trade_partner)
115  {
116  if (!is_tile_seen_city(pow_player, trade_partner)) {
117  return false;
118  }
119  }
121 
122  // They are all seen.
123  return true;
124 }
125 
130 static bool can_plr_see_all_sym_diplrels_of(const struct player *pplayer,
131  const struct player *tplayer)
132 {
133  if (pplayer == tplayer) {
134  // Can see own relationships.
135  return true;
136  }
137 
138  if (player_has_embassy(pplayer, tplayer)) {
139  // Gets reports from the embassy.
140  return true;
141  }
142 
143  if (player_diplstate_get(pplayer, tplayer)->contact_turns_left > 0) {
144  // Can see relationships during contact turns.
145  return true;
146  }
147 
148  return false;
149 }
150 
159 static bool is_req_knowable(
160  const struct player *pow_player, const struct player *target_player,
161  const struct player *other_player, const struct city *target_city,
162  const struct tile *target_tile, const struct unit *target_unit,
163  const struct requirement *req, const enum req_problem_type prob_type)
164 {
165  fc_assert_ret_val_msg(nullptr != pow_player, false, "No point of view");
166 
167  if (req->source.kind == VUT_UTFLAG || req->source.kind == VUT_UTYPE
168  || req->source.kind == VUT_UCLASS || req->source.kind == VUT_UCFLAG
169  || req->source.kind == VUT_MINVETERAN
170  || req->source.kind == VUT_MINHP) {
171  switch (req->range) {
172  case REQ_RANGE_LOCAL:
173  if (target_unit == nullptr) {
174  /* The unit may exist but not be passed when the problem type is
175  * RPT_POSSIBLE. */
176  return prob_type == RPT_CERTAIN;
177  }
178 
179  return can_player_see_unit(pow_player, target_unit);
180  case REQ_RANGE_CADJACENT:
181  case REQ_RANGE_ADJACENT:
182  case REQ_RANGE_CONTINENT:
183  case REQ_RANGE_CITY:
184  case REQ_RANGE_TRADEROUTE:
185  case REQ_RANGE_PLAYER:
186  case REQ_RANGE_TEAM:
187  case REQ_RANGE_ALLIANCE:
188  case REQ_RANGE_WORLD:
189  case REQ_RANGE_COUNT:
190  return false;
191  }
192  }
193 
194  if (req->source.kind == VUT_UNITSTATE) {
195  fc_assert_ret_val_msg(req->range == REQ_RANGE_LOCAL, false,
196  "Wrong range");
197 
198  if (target_unit == nullptr) {
199  /* The unit may exist but not be passed when the problem type is
200  * RPT_POSSIBLE. */
201  return prob_type == RPT_CERTAIN;
202  }
203 
204  switch (req->source.value.unit_state) {
205  case USP_TRANSPORTED:
206  case USP_LIVABLE_TILE:
207  case USP_DOMESTIC_TILE:
208  case USP_TRANSPORTING:
209  case USP_NATIVE_TILE:
210  case USP_NATIVE_EXTRA:
211  // Known if the unit is seen by the player.
212  return can_player_see_unit(pow_player, target_unit);
213  case USP_HAS_HOME_CITY:
214  case USP_MOVED_THIS_TURN:
215  // Known to the unit's owner.
216  return unit_owner(target_unit) == pow_player;
217  case USP_COUNT:
218  fc_assert_msg(req->source.value.unit_state != USP_COUNT,
219  "Invalid unit state property.");
220  // Invalid property is unknowable.
221  return false;
222  }
223  }
224 
225  if (req->source.kind == VUT_MINMOVES) {
226  fc_assert_ret_val_msg(req->range == REQ_RANGE_LOCAL, false,
227  "Wrong range");
228 
229  if (target_unit == nullptr) {
230  /* The unit may exist but not be passed when the problem type is
231  * RPT_POSSIBLE. */
232  return prob_type == RPT_CERTAIN;
233  }
234 
235  switch (req->range) {
236  case REQ_RANGE_LOCAL:
237  // The owner can see if his unit has move fragments left.
238  return unit_owner(target_unit) == pow_player;
239  case REQ_RANGE_CADJACENT:
240  case REQ_RANGE_ADJACENT:
241  case REQ_RANGE_CITY:
242  case REQ_RANGE_TRADEROUTE:
243  case REQ_RANGE_CONTINENT:
244  case REQ_RANGE_PLAYER:
245  case REQ_RANGE_TEAM:
246  case REQ_RANGE_ALLIANCE:
247  case REQ_RANGE_WORLD:
248  case REQ_RANGE_COUNT:
249  // Invalid range
250  return false;
251  }
252  }
253 
254  if (req->source.kind == VUT_ACTIVITY) {
255  fc_assert_ret_val_msg(req->range == REQ_RANGE_LOCAL, false,
256  "Wrong range");
257 
258  if (target_unit == nullptr) {
259  /* The unit may exist but not be passed when the problem type is
260  * RPT_POSSIBLE. */
261  return prob_type == RPT_CERTAIN;
262  }
263 
264  if (unit_owner(target_unit) == pow_player) {
265  return true;
266  }
267 
268  if (req->source.value.activity != ACTIVITY_EXPLORE
269  && (req->source.value.activity != ACTIVITY_GOTO)) {
270  // Sent in package_short_unit()
271  return can_player_see_unit(pow_player, target_unit);
272  }
273  }
274 
275  if (req->source.kind == VUT_DIPLREL) {
276  switch (req->range) {
277  case REQ_RANGE_LOCAL:
278  if (other_player == nullptr || target_player == nullptr) {
279  /* The two players may exist but not be passed when the problem
280  * type is RPT_POSSIBLE. */
281  return prob_type == RPT_CERTAIN;
282  }
283 
284  if (pow_player == other_player) {
285  return true;
286  }
287 
288  if (can_plr_see_all_sym_diplrels_of(pow_player, target_player)
289  || can_plr_see_all_sym_diplrels_of(pow_player, other_player)) {
290  return true;
291  }
292 
293  // TODO: Non symmetric diplomatic relationships.
294  break;
295  case REQ_RANGE_PLAYER:
296  if (target_player == nullptr) {
297  /* The target player may exist but not be passed when the problem
298  * type is RPT_POSSIBLE. */
299  return prob_type == RPT_CERTAIN;
300  }
301 
302  if (pow_player == target_player) {
303  return true;
304  }
305 
306  if (can_plr_see_all_sym_diplrels_of(pow_player, target_player)) {
307  return true;
308  }
309 
310  // TODO: Non symmetric diplomatic relationships.
311  break;
312  case REQ_RANGE_TEAM:
313  // TODO
314  break;
315  case REQ_RANGE_ALLIANCE:
316  // TODO
317  break;
318  case REQ_RANGE_WORLD:
319  // TODO
320  break;
321  case REQ_RANGE_CADJACENT:
322  case REQ_RANGE_ADJACENT:
323  case REQ_RANGE_CITY:
324  case REQ_RANGE_TRADEROUTE:
325  case REQ_RANGE_CONTINENT:
326  case REQ_RANGE_COUNT:
327  // Invalid range
328  return false;
329  break;
330  }
331  }
332 
333  if (req->source.kind == VUT_MINSIZE) {
334  if (target_city == nullptr) {
335  /* The city may exist but not be passed when the problem type is
336  * RPT_POSSIBLE. */
337  return prob_type == RPT_CERTAIN;
338  }
339 
340  if (player_can_see_city_externals(pow_player, target_city)) {
341  return true;
342  }
343  }
344 
345  if (req->source.kind == VUT_CITYTILE) {
346  struct city *pcity;
347 
348  if (target_tile == nullptr) {
349  /* The tile may exist but not be passed when the problem type is
350  * RPT_POSSIBLE. */
351  return prob_type == RPT_CERTAIN;
352  }
353 
354  switch (req->range) {
355  case REQ_RANGE_LOCAL:
356  // Known because the tile is seen
357  if (tile_is_seen(target_tile, pow_player)) {
358  return true;
359  }
360 
361  // The player knows its city even if he can't see it
362  pcity = tile_city(target_tile);
363  return pcity && city_owner(pcity) == pow_player;
364  case REQ_RANGE_CADJACENT:
365  // Known because the tile is seen
366  if (is_tile_seen_cadj(pow_player, target_tile)) {
367  return true;
368  }
369 
370  // The player knows its city even if he can't see it
371  cardinal_adjc_iterate(&(wld.map), target_tile, ptile)
372  {
373  pcity = tile_city(ptile);
374  if (pcity && city_owner(pcity) == pow_player) {
375  return true;
376  }
377  }
379 
380  // Unknown
381  return false;
382  case REQ_RANGE_ADJACENT:
383  // Known because the tile is seen
384  if (is_tile_seen_adj(pow_player, target_tile)) {
385  return true;
386  }
387 
388  // The player knows its city even if he can't see it
389  adjc_iterate(&(wld.map), target_tile, ptile)
390  {
391  pcity = tile_city(ptile);
392  if (pcity && city_owner(pcity) == pow_player) {
393  return true;
394  }
395  }
397 
398  // Unknown
399  return false;
400  case REQ_RANGE_CITY:
401  case REQ_RANGE_TRADEROUTE:
402  case REQ_RANGE_CONTINENT:
403  case REQ_RANGE_PLAYER:
404  case REQ_RANGE_TEAM:
405  case REQ_RANGE_ALLIANCE:
406  case REQ_RANGE_WORLD:
407  case REQ_RANGE_COUNT:
408  // Invalid range
409  return false;
410  }
411  }
412 
413  if (req->source.kind == VUT_IMPR_GENUS) {
414  // The only legal range when this was written was local.
415  fc_assert(req->range == REQ_RANGE_LOCAL);
416 
417  if (!target_city) {
418  /* RPT_CERTAIN: Can't be. No city to contain it.
419  * RPT_POSSIBLE: A city like that may exist but not be passed. */
420  return prob_type == RPT_CERTAIN;
421  }
422 
423  // Local BuildingGenus could be about city production.
424  return can_player_see_city_internals(pow_player, target_city);
425  }
426 
427  if (req->source.kind == VUT_IMPROVEMENT) {
428  switch (req->range) {
429  case REQ_RANGE_WORLD:
430  case REQ_RANGE_ALLIANCE:
431  case REQ_RANGE_TEAM:
432  case REQ_RANGE_PLAYER:
433  case REQ_RANGE_CONTINENT:
434  /* Only wonders (great or small) can be required in those ranges.
435  * Wonders are always visible. */
436  return true;
437  case REQ_RANGE_TRADEROUTE:
438  /* Could be known for trade routes to cities owned by pow_player as
439  * long as the requirement is present. Not present requirements would
440  * require knowledge that no trade routes to another foreign city
441  * exists (since all possible trade routes are to a city owned by
442  * pow_player). Not worth the complexity, IMHO. */
443  return false;
444  case REQ_RANGE_CITY:
445  case REQ_RANGE_LOCAL:
446  if (!target_city) {
447  /* RPT_CERTAIN: Can't be. No city to contain it.
448  * RPT_POSSIBLE: A city like that may exist but not be passed. */
449  return prob_type == RPT_CERTAIN;
450  }
451 
452  if (can_player_see_city_internals(pow_player, target_city)) {
453  /* Anyone that can see city internals (like the owner) known all
454  * its improvements. */
455  return true;
456  }
457 
459  && player_can_see_city_externals(pow_player, target_city)) {
460  /* Can see visible improvements when the outside of the city is
461  * seen. */
462  return true;
463  }
464 
465  // No way to know if a city has an improvement
466  return false;
467  case REQ_RANGE_CADJACENT:
468  case REQ_RANGE_ADJACENT:
469  case REQ_RANGE_COUNT:
470  // Not supported by the requirement type.
471  return false;
472  }
473  }
474 
475  if (req->source.kind == VUT_NATION
476  || req->source.kind == VUT_NATIONGROUP) {
477  if (!target_player
478  && (req->range == REQ_RANGE_PLAYER || req->range == REQ_RANGE_TEAM
479  || req->range == REQ_RANGE_ALLIANCE)) {
480  /* The player (that can have a nationality or be alllied to someone
481  * with the nationality) may exist but not be passed when the problem
482  * type is RPT_POSSIBLE. */
483  return prob_type == RPT_CERTAIN;
484  }
485 
486  return true;
487  }
488 
489  if (req->source.kind == VUT_ADVANCE || req->source.kind == VUT_TECHFLAG) {
490  if (req->range == REQ_RANGE_PLAYER) {
491  if (!target_player) {
492  /* The player (that may or may not possess the tech) may exist but
493  * not be passed when the problem type is RPT_POSSIBLE. */
494  return prob_type == RPT_CERTAIN;
495  }
496 
497  return can_see_techs_of_target(pow_player, target_player);
498  }
499  }
500 
501  if (req->source.kind == VUT_GOVERNMENT) {
502  if (req->range == REQ_RANGE_PLAYER) {
503  if (!target_player) {
504  /* The player (that may or may not possess the tech) may exist but
505  * not be passed when the problem type is RPT_POSSIBLE. */
506  return prob_type == RPT_CERTAIN;
507  }
508 
509  return (pow_player == target_player
510  || could_intel_with_player(pow_player, target_player));
511  }
512  }
513 
514  if (req->source.kind == VUT_MAXTILEUNITS) {
515  if (target_tile == nullptr) {
516  /* The tile may exist but not be passed when the problem type is
517  * RPT_POSSIBLE. */
518  return prob_type == RPT_CERTAIN;
519  }
520 
521  switch (req->range) {
522  case REQ_RANGE_LOCAL:
523  return can_player_see_hypotetic_units_at(pow_player, target_tile);
524  case REQ_RANGE_CADJACENT:
525  if (!can_player_see_hypotetic_units_at(pow_player, target_tile)) {
526  return false;
527  }
528  cardinal_adjc_iterate(&(wld.map), target_tile, adjc_tile)
529  {
530  if (!can_player_see_hypotetic_units_at(pow_player, adjc_tile)) {
531  return false;
532  }
533  }
535 
536  return true;
537  case REQ_RANGE_ADJACENT:
538  if (!can_player_see_hypotetic_units_at(pow_player, target_tile)) {
539  return false;
540  }
541  adjc_iterate(&(wld.map), target_tile, adjc_tile)
542  {
543  if (!can_player_see_hypotetic_units_at(pow_player, adjc_tile)) {
544  return false;
545  }
546  }
548 
549  return true;
550  case REQ_RANGE_CONTINENT:
551  case REQ_RANGE_CITY:
552  case REQ_RANGE_TRADEROUTE:
553  case REQ_RANGE_PLAYER:
554  case REQ_RANGE_TEAM:
555  case REQ_RANGE_ALLIANCE:
556  case REQ_RANGE_WORLD:
557  case REQ_RANGE_COUNT:
558  // Non existing.
559  return false;
560  }
561  }
562 
563  if (req->source.kind == VUT_TERRAIN || req->source.kind == VUT_TERRFLAG
564  || req->source.kind == VUT_TERRAINALTER
565  || req->source.kind == VUT_TERRAINCLASS
566  || req->source.kind == VUT_EXTRA || req->source.kind == VUT_EXTRAFLAG
567  || req->source.kind == VUT_BASEFLAG
568  || req->source.kind == VUT_ROADFLAG) {
569  if (target_tile == nullptr) {
570  /* The tile may exist but not be passed when the problem type is
571  * RPT_POSSIBLE. */
572  return prob_type == RPT_CERTAIN;
573  }
574 
575  switch (req->range) {
576  case REQ_RANGE_LOCAL:
577  return tile_is_seen(target_tile, pow_player);
578  case REQ_RANGE_CADJACENT:
579  /* TODO: The answer is known when the universal is located on a seen
580  * tile. Is returning TRUE in those cases worth the added complexity
581  * and the extra work for the computer? */
582  return is_tile_seen_cadj(pow_player, target_tile);
583  case REQ_RANGE_ADJACENT:
584  /* TODO: The answer is known when the universal is located on a seen
585  * tile. Is returning TRUE in those cases worth the added complexity
586  * and the extra work for the computer? */
587  return is_tile_seen_adj(pow_player, target_tile);
588  case REQ_RANGE_CITY:
589  /* TODO: The answer is known when the universal is located on a seen
590  * tile. Is returning TRUE in those cases worth the added complexity
591  * and the extra work for the computer? */
592  return is_tile_seen_city(pow_player, target_city);
593  case REQ_RANGE_TRADEROUTE:
594  /* TODO: The answer is known when the universal is located on a seen
595  * tile. Is returning TRUE in those cases worth the added complexity
596  * and the extra work for the computer? */
597  return is_tile_seen_traderoute(pow_player, target_city);
598  case REQ_RANGE_CONTINENT:
599  case REQ_RANGE_PLAYER:
600  case REQ_RANGE_ALLIANCE:
601  case REQ_RANGE_TEAM:
602  case REQ_RANGE_WORLD:
603  case REQ_RANGE_COUNT:
604  // Non existing range for requirement types.
605  return false;
606  }
607  }
608 
609  if (req->source.kind == VUT_ACTION || req->source.kind == VUT_OTYPE
610  || req->source.kind == VUT_VISIONLAYER) {
611  // This requirement type is intended to specify the situation.
612  return true;
613  }
614 
615  if (req->source.kind == VUT_SERVERSETTING) {
616  // Only visible server settings can be requirements.
617  return true;
618  }
619 
620  // Uncertain or no support added yet.
621  return false;
622 }
623 
630  const struct player *pow_player, const struct player *target_player,
631  const struct player *other_player, const struct city *target_city,
632  const struct impr_type *target_building, const struct tile *target_tile,
633  const struct unit *target_unit, const struct output_type *target_output,
634  const struct specialist *target_specialist,
635  const struct requirement *req, const enum req_problem_type prob_type)
636 {
637  const struct unit_type *target_unittype;
638 
639  if (!is_req_knowable(pow_player, target_player, other_player, target_city,
640  target_tile, target_unit, req, prob_type)) {
641  return TRI_MAYBE;
642  }
643 
644  if (target_unit) {
645  target_unittype = unit_type_get(target_unit);
646  } else {
647  target_unittype = nullptr;
648  }
649 
650  if (is_req_active(target_player, other_player, target_city,
651  target_building, target_tile, target_unit,
652  target_unittype, target_output, target_specialist,
653  nullptr, req, prob_type)) {
654  return TRI_YES;
655  } else {
656  return TRI_NO;
657  }
658 }
659 
666  const struct player *pow_player, const struct player *target_player,
667  const struct player *other_player, const struct city *target_city,
668  const struct impr_type *target_building, const struct tile *target_tile,
669  const struct unit *target_unit, const struct output_type *target_output,
670  const struct specialist *target_specialist,
671  const struct requirement_vector *reqs,
672  const enum req_problem_type prob_type)
673 {
674  enum fc_tristate current;
675  enum fc_tristate result;
676 
677  result = TRI_YES;
679  {
680  current =
681  mke_eval_req(pow_player, target_player, other_player, target_city,
682  target_building, target_tile, target_unit,
683  target_output, target_specialist, preq, prob_type);
684  if (current == TRI_NO) {
685  return TRI_NO;
686  } else if (current == TRI_MAYBE) {
687  result = TRI_MAYBE;
688  }
689  }
691 
692  return result;
693 }
694 
698 bool can_see_techs_of_target(const struct player *pow_player,
699  const struct player *target_player)
700 {
701  return pow_player == target_player
702  || player_has_embassy(pow_player, target_player);
703 }
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
Definition: city.cpp:1083
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
Definition: city.cpp:1095
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
Definition: city.cpp:130
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
Definition: city.h:202
#define city_tile_iterate_end
Definition: city.h:209
bool could_intel_with_player(const struct player *pplayer, const struct player *aplayer)
Returns TRUE iff pplayer can get intelligence about aplayer.
Definition: diptreaty.cpp:74
struct @19::@20 reqs
req_problem_type
Definition: fc_types.h:566
@ RPT_CERTAIN
Definition: fc_types.h:568
struct world wld
Definition: game.cpp:48
bool is_improvement_visible(const struct impr_type *pimprove)
Return TRUE if the improvement should be visible to others without spying.
#define fc_assert_msg(condition, message,...)
Definition: log.h:96
#define fc_assert(condition)
Definition: log.h:89
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition: log.h:132
#define adjc_iterate_end
Definition: map.h:358
#define cardinal_adjc_iterate_end
Definition: map.h:384
#define adjc_iterate(nmap, center_tile, itr_tile)
Definition: map.h:351
#define cardinal_adjc_iterate(nmap, center_tile, itr_tile)
Definition: map.h:380
static bool is_tile_seen_cadj(const struct player *pow_player, const struct tile *target_tile)
Returns TRUE iff the target_tile it self and all tiles cardinally adjacent to it are seen by pow_play...
bool can_see_techs_of_target(const struct player *pow_player, const struct player *target_player)
Can pow_player see the techs of target player?
static bool is_tile_seen_city(const struct player *pow_player, const struct city *target_city)
Returns TRUE iff all tiles of a city are seen by pow_player.
static bool can_plr_see_all_sym_diplrels_of(const struct player *pplayer, const struct player *tplayer)
Returns TRUE iff pplayer can see all the symmetric diplomatic relationships of tplayer.
enum fc_tristate mke_eval_reqs(const struct player *pow_player, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct output_type *target_output, const struct specialist *target_specialist, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
Evaluate a requirement vector given pow_player's knowledge.
static bool is_tile_seen_traderoute(const struct player *pow_player, const struct city *target_city)
Returns TRUE iff all the tiles of a city and all the tiles of its trade partners are seen by pow_play...
static bool is_req_knowable(const struct player *pow_player, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct tile *target_tile, const struct unit *target_unit, const struct requirement *req, const enum req_problem_type prob_type)
Is an evaluation of the requirement accurate when pow_player evaluates it?
static bool is_tile_seen_adj(const struct player *pow_player, const struct tile *target_tile)
Returns TRUE iff the target_tile it self and all tiles adjacent to it are seen by pow_player.
enum fc_tristate mke_eval_req(const struct player *pow_player, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct output_type *target_output, const struct specialist *target_specialist, const struct requirement *req, const enum req_problem_type prob_type)
Evaluate a single requirement given pow_player's knowledge.
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
Checks if a unit can be seen by pplayer at its current location.
Definition: player.cpp:1016
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
Returns TRUE iff pow_player can see externally visible features of target_city.
Definition: player.cpp:1074
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
Check if pplayer could see all units on ptile if it had units.
Definition: player.cpp:917
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the player can see the city's internals.
Definition: player.cpp:1060
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Check if pplayer has an embassy with pplayer2.
Definition: player.cpp:195
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
Definition: player.cpp:288
bool is_req_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement to see if it is active on the given target.
#define requirement_vector_iterate_end
Definition: requirements.h:80
#define requirement_vector_iterate(req_vec, preq)
Definition: requirements.h:78
fc_tristate
Definition: shared.h:42
@ TRI_YES
Definition: shared.h:42
@ TRI_NO
Definition: shared.h:42
@ TRI_MAYBE
Definition: shared.h:42
Definition: city.h:291
Definition: player.h:231
enum req_range range
Definition: requirements.h:69
struct universal source
Definition: requirements.h:68
Definition: tile.h:42
Definition: unit.h:134
enum universals_n kind
Definition: fc_types.h:740
universals_u value
Definition: fc_types.h:739
struct civ_map map
Definition: world_object.h:21
bool tile_is_seen(const struct tile *target_tile, const struct player *pow_player)
Returns TRUE iff the target_tile is seen by pow_player.
Definition: tile.cpp:416
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
Definition: tile.cpp:72
#define trade_partners_iterate_end
Definition: traderoutes.h:163
#define trade_partners_iterate(c, p)
Definition: traderoutes.h:153
const struct impr_type * building
Definition: fc_types.h:579
enum unit_activity activity
Definition: fc_types.h:616
enum ustate_prop unit_state
Definition: fc_types.h:615
#define unit_owner(_pu)
Definition: unit.h:370
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
Definition: unittype.cpp:114