translation_unit
comment "/***********************************************************"...
preproc_ifdef
#ifdef "#ifdef"
identifier "HAVE_CONFIG_H"
preproc_include
#include "#include"
system_lib_string "<fc_config.h>"
#endif "#endif"
preproc_include
#include "#include"
system_lib_string "<stdlib.h>"
preproc_include
#include "#include"
system_lib_string "<string.h>"
comment "/* utility */"
preproc_include
#include "#include"
string_literal
" "\""
string_content "fcintl.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "log.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "mem.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "shared.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "support.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "timing.h"
" "\""
comment "/* common */"
preproc_include
#include "#include"
string_literal
" "\""
string_content "city.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "game.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "government.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "map.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "specialist.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "cm.h"
" "\""
comment "/*\n * Terms used\n * ==========\n *\n * Stats: food, shields, t"...
comment "/***********************************************************"...
comment "/* If this is uncommented, research loop runs without limit "...
comment "/* #define CM_LOOP_NO_LIMIT */"
comment "/* Maximal iterations before the search loop is stopped, or "...
preproc_def
#define "#define"
identifier "CM_MAX_LOOP"
preproc_arg "27500"
preproc_def
#define "#define"
identifier "CPUHOG_CM_MAX_LOOP"
preproc_arg "(CM_MAX_LOOP * 4)"
preproc_ifdef
#ifdef "#ifdef"
identifier "DEBUG_TIMERS"
preproc_def
#define "#define"
identifier "GATHER_TIME_STATS"
#endif "#endif"
preproc_ifdef
#ifdef "#ifdef"
identifier "FREECIV_DEBUG"
preproc_def
#define "#define"
identifier "CM_DEBUG"
#endif "#endif"
comment "/* Whether to print every query, or just at cm_free ; matter"...
preproc_def
#define "#define"
identifier "PRINT_TIME_STATS_EVERY_QUERY"
preproc_def
#define "#define"
identifier "LOG_TIME_STATS"
preproc_arg "LOG_DEBUG"
preproc_def
#define "#define"
identifier "LOG_CM_STATE"
preproc_arg "LOG_DEBUG"
preproc_def
#define "#define"
identifier "LOG_LATTICE"
preproc_arg "LOG_DEBUG"
preproc_def
#define "#define"
identifier "LOG_REACHED_LEAF"
preproc_arg "LOG_DEBUG"
preproc_def
#define "#define"
identifier "LOG_BETTER_LEAF"
preproc_arg "LOG_DEBUG"
preproc_def
#define "#define"
identifier "LOG_PRUNE_BRANCH"
preproc_arg "LOG_DEBUG"
preproc_ifdef (+74 nodes collapsed)
comment "/* GATHER_TIME_STATS */"
comment "/* Fitness of a solution. */"
struct_specifier
struct "struct"
type_identifier "cm_fitness"
field_declaration_list
{ "{"
field_declaration
primitive_type "int"
field_identifier "weighted"
; ";"
comment "/* weighted sum */"
field_declaration
primitive_type "bool"
field_identifier "sufficient"
; ";"
comment "/* false => doesn't meet constraints */"
} "}"
; ";"
comment "/*\n * We have a cyclic structure here, so we need to forward"...
struct_specifier
struct "struct"
type_identifier "cm_tile_type"
; ";"
struct_specifier
struct "struct"
type_identifier "cm_tile"
; ";"
comment "/*\n * A tile. Has a pointer to the type, and the x/y coords"...
struct_specifier (+21 nodes collapsed)
; ";"
comment "/* define the tile_vector as array<cm_tile> */"
preproc_def
#define "#define"
identifier "SPECVEC_TAG"
preproc_arg "tile"
preproc_def
#define "#define"
identifier "SPECVEC_TYPE"
preproc_arg "struct cm_tile"
preproc_include
#include "#include"
string_literal
" "\""
string_content "specvec.h"
" "\""
comment "/* define the tile_type_vector as array <cm_tile_type*> */"
preproc_def
#define "#define"
identifier "SPECVEC_TAG"
preproc_arg "tile_type"
preproc_def
#define "#define"
identifier "SPECVEC_TYPE"
preproc_arg "struct cm_tile_type *"
preproc_include
#include "#include"
string_literal
" "\""
string_content "specvec.h"
" "\""
preproc_function_def
#define "#define"
identifier "tile_type_vector_iterate"
preproc_params
( "("
identifier "vector"
, ","
identifier "var"
) ")"
preproc_arg "{ \\\n struct cm_tile_type *var; \\\n TYPED_VECTOR_ITERATE"...
preproc_def
#define "#define"
identifier "tile_type_vector_iterate_end"
preproc_arg "}} VECTOR_ITERATE_END; }"
comment "/*\n * A tile type.\n * Holds the production (a hill produces "...
struct_specifier (+57 nodes collapsed)
; ";"
comment "/*\n * A partial solution.\n * Has the count of workers assign"...
struct_specifier (+35 nodes collapsed)
; ";"
comment "/*\n * State of the search.\n * This holds all the information"...
struct_specifier (+99 nodes collapsed)
; ";"
comment "/* return #fields + specialist types */"
declaration
storage_class_specifier
static "static"
primitive_type "int"
function_declarator
identifier "num_types"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "cm_state"
pointer_declarator
* "*"
identifier "state"
) ")"
; ";"
comment "/* debugging functions */"
preproc_ifdef (+224 nodes collapsed)
comment "/* CM_DEBUG */"
declaration (+33 nodes collapsed)
declaration (+28 nodes collapsed)
declaration (+25 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Initialize the CM data at the start of each game. Not"...
function_definition (+115 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Initialize the CM citymap data. This function is call"...
function_definition
primitive_type "void"
function_declarator
identifier "cm_init_citymap"
parameter_list
( "("
parameter_declaration
primitive_type "void"
) ")"
compound_statement
{ "{"
comment "/* In the B&B algorithm there's not really anything to initi"...
} "}"
comment "/***********************************************************"...
comment "/**\n Clear the cache for a city.\n**************************"...
function_definition
primitive_type "void"
function_declarator
identifier "cm_clear_cache"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "city"
pointer_declarator
* "*"
identifier "pcity"
) ")"
compound_statement
{ "{"
comment "/* The B&B algorithm doesn't have city caches so there's not"...
} "}"
comment "/***********************************************************"...
comment "/**\n Called at the end of a game to free any CM data.\n*****"...
function_definition (+90 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Create a new cm_result.\n******************************"...
function_definition
struct_specifier
struct "struct"
type_identifier "cm_result"
pointer_declarator
* "*"
function_declarator
identifier "cm_result_new"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "city"
pointer_declarator
* "*"
identifier "pcity"
) ")"
compound_statement
{ "{"
declaration
struct_specifier
struct "struct"
type_identifier "cm_result"
pointer_declarator
* "*"
identifier "result"
; ";"
comment "/* initialise all values */"
expression_statement
assignment_expression
identifier "result"
= "="
call_expression
identifier "fc_calloc"
argument_list
( "("
number_literal "1"
, ","
sizeof_expression
sizeof "sizeof"
parenthesized_expression
( "("
pointer_expression
* "*"
identifier "result"
) ")"
) ")"
; ";"
expression_statement
assignment_expression
field_expression
identifier "result"
-> "->"
field_identifier "city_radius_sq"
= "="
conditional_expression
identifier "pcity"
? "?"
call_expression
identifier "city_map_radius_sq_get"
argument_list
( "("
identifier "pcity"
) ")"
: ":"
identifier "CITY_MAP_MAX_RADIUS_SQ"
; ";"
expression_statement (+34 nodes collapsed)
comment "/* test if the city pointer is valid; the cm_result struct c"...
expression_statement
call_expression
identifier "fc_assert_ret_val"
argument_list
( "("
binary_expression
identifier "pcity"
!= "!="
null
NULL "NULL"
, ","
identifier "result"
) ")"
; ";"
return_statement
return "return"
identifier "result"
; ";"
} "}"
comment "/***********************************************************"...
comment "/**\n Destroy a cm_result.\n*********************************"...
function_definition
primitive_type "void"
function_declarator
identifier "cm_result_destroy"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "cm_result"
pointer_declarator
* "*"
identifier "result"
) ")"
compound_statement
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "result"
!= "!="
null
NULL "NULL"
) ")"
compound_statement
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
field_expression
identifier "result"
-> "->"
field_identifier "worker_positions"
!= "!="
null
NULL "NULL"
) ")"
compound_statement
{ "{"
expression_statement
call_expression
identifier "FC_FREE"
argument_list
( "("
field_expression
identifier "result"
-> "->"
field_identifier "worker_positions"
) ")"
; ";"
} "}"
expression_statement
call_expression
identifier "FC_FREE"
argument_list
( "("
identifier "result"
) ")"
; ";"
} "}"
} "}"
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n Set all production to zero and initialize the vectors "...
function_definition (+77 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Duplicate a tile type, except for the vectors - the ve"...
function_definition (+110 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Free all the storage in the tile type (but don't free "...
function_definition (+59 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Destroy and free all types in the vector, and the vect"...
function_definition (+60 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return TRUE iff all categories of the two types are eq"...
function_definition (+99 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return positive value if tile a is better or equal to "...
function_definition (+236 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n If there is a tile type in the vector that is equivale"...
function_definition (+89 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return the number of tiles of this type that can be wo"...
function_definition (+56 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return the number of tile types that are better than t"...
function_definition (+31 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Retrieve a tile type by index. For a given state there"...
function_definition
storage_class_specifier
static "static"
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "cm_tile_type"
pointer_declarator
* "*"
function_declarator
identifier "tile_type_get"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "cm_state"
pointer_declarator
* "*"
identifier "state"
, ","
parameter_declaration
primitive_type "int"
identifier "type"
) ")"
compound_statement
{ "{"
comment "/* Sanity check the index. */"
expression_statement
call_expression
identifier "fc_assert_ret_val"
argument_list
( "("
binary_expression
number_literal "0"
<= "<="
identifier "type"
, ","
null
NULL "NULL"
) ")"
; ";"
expression_statement
call_expression
identifier "fc_assert_ret_val"
argument_list
( "("
binary_expression
field_expression
field_expression
identifier "state"
-> "->"
field_identifier "lattice"
. "."
field_identifier "size"
> ">"
identifier "type"
, ","
null
NULL "NULL"
) ")"
; ";"
return_statement
return "return"
subscript_expression
field_expression
field_expression
identifier "state"
-> "->"
field_identifier "lattice"
. "."
field_identifier "p"
[ "["
identifier "type"
] "]"
; ";"
} "}"
comment "/***********************************************************"...
comment "/**\n Retrieve a tile of a particular type by index. For a g"...
function_definition
storage_class_specifier
static "static"
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "cm_tile"
pointer_declarator
* "*"
function_declarator
identifier "tile_get"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "cm_tile_type"
pointer_declarator
* "*"
identifier "ptype"
, ","
parameter_declaration
primitive_type "int"
identifier "j"
) ")"
compound_statement
{ "{"
expression_statement
call_expression
identifier "fc_assert_ret_val"
argument_list
( "("
unary_expression
! "!"
field_expression
identifier "ptype"
-> "->"
field_identifier "is_specialist"
, ","
null
NULL "NULL"
) ")"
; ";"
expression_statement
call_expression
identifier "fc_assert_ret_val"
argument_list
( "("
binary_expression
number_literal "0"
<= "<="
identifier "j"
, ","
null
NULL "NULL"
) ")"
; ";"
expression_statement
call_expression
identifier "fc_assert_ret_val"
argument_list
( "("
binary_expression
identifier "j"
< "<"
field_expression
field_expression
identifier "ptype"
-> "->"
field_identifier "tiles"
. "."
field_identifier "size"
, ","
null
NULL "NULL"
) ")"
; ";"
return_statement
return "return"
pointer_expression
& "&"
subscript_expression
field_expression
field_expression
identifier "ptype"
-> "->"
field_identifier "tiles"
. "."
field_identifier "p"
[ "["
identifier "j"
] "]"
; ";"
} "}"
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n Return TRUE iff fitness A is strictly better than fitn"...
function_definition (+61 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return a fitness struct that is the worst possible res"...
function_definition (+46 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Compute the fitness of the given surplus (and disorder"...
function_definition (+205 nodes collapsed)
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n Allocate and initialize an empty solution.\n***********"...
function_definition (+156 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Free all storage associated with the solution. This is"...
function_definition (+41 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Copy the source solution into the destination one (the"...
function_definition (+149 nodes collapsed)
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n Apply the solution to state->workers_map.\n************"...
function_definition (+425 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Convert the city's surplus numbers into an array. Get "...
function_definition (+95 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Compute the fitness of the solution. This is a fairly "...
function_definition (+186 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Convert the solution into a cm_result. This is a fairl"...
function_definition (+144 nodes collapsed)
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n All the sorting in this code needs to respect the part"...
function_definition (+152 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Sort by fitness. Since fitness is monotone in the prod"...
function_definition (+155 nodes collapsed)
declaration
storage_class_specifier
static "static"
type_identifier "Output_type_id"
identifier "compare_key"
; ";"
declaration
storage_class_specifier
static "static"
primitive_type "double"
identifier "compare_key_trade_bonus"
; ";"
comment "/***********************************************************"...
comment "/**\n Compare by the production of type compare_key.\n If a "...
function_definition (+189 nodes collapsed)
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n Compute the production of tile [x,y] and stuff it into"...
function_definition (+87 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Add the tile [x,y], with production indicated by type,"...
function_definition (+295 nodes collapsed)
comment "/*\n * Add the specialist types to the lattice.\n */"
comment "/***********************************************************"...
comment "/**\n Create lattice nodes for each type of specialist. This"...
function_definition (+140 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Topologically sort the lattice.\n Sets the lattice_dep"...
function_definition (+553 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Remove unreachable lattice nodes to speed up processin"...
function_definition (+356 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Determine the estimated_fitness fields, and sort by th"...
function_definition (+163 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Create the lattice.\n**********************************"...
function_definition (+217 nodes collapsed)
comment "/***********************************************************"...
comment "/***********************************************************"...
comment "/**\n Return TRUE iff the stack is empty.\n******************"...
function_definition (+32 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return the last choice in the stack.\n*****************"...
function_definition (+59 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return the number of different tile types. There is o"...
function_definition (+35 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Update the solution to assign 'number' more workers on"...
function_definition (+436 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Add just one worker to the solution.\n*****************"...
function_definition (+47 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Remove just one worker from the solution.\n************"...
function_definition (+47 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Remove a worker from the current solution, and pop onc"...
function_definition (+67 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n True if all tiles better than this type have been used"...
function_definition (+81 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return the next choice to make after oldchoice.\n A ch"...
function_definition (+252 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Pick a sibling choice to the last choice. This works "...
function_definition (+163 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Go down from the current branch, if we can.\n Thanks t"...
function_definition (+187 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Complete the solution by choosing tiles in order off t"...
function_definition (+284 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Return number of specialists used in partial solution\n"...
function_definition (+116 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n The heuristic:\n A partial solution cannot produce mor"...
function_definition (+457 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n A choice is unpromising if isn't better than the best "...
function_definition (+360 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Initialize minimal production needed to be sufficient\n"...
function_definition (+79 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Get the tax rates, see city.c\n************************"...
function_definition (+222 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Estimate the fitness of a tile. Tiles are put into th"...
function_definition (+314 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n The high-level algorithm is:\n\n for each idle worker,\n"...
function_definition (+226 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Initialize the state for the branch-and-bound algorith"...
function_definition (+586 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Find the minimum food surplus needed to grow in the fe"...
function_definition (+397 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Set the parameter for the state. This is the first st"...
function_definition (+206 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Clean up after a search.\n Currently, does nothing exc"...
function_definition
storage_class_specifier
static "static"
primitive_type "void"
function_declarator
identifier "end_search"
parameter_list
( "("
parameter_declaration
struct_specifier
struct "struct"
type_identifier "cm_state"
pointer_declarator
* "*"
identifier "state"
) ")"
compound_statement
{ "{"
preproc_ifdef
#ifdef "#ifdef"
identifier "GATHER_TIME_STATS"
expression_statement
call_expression
identifier "timer_stop"
argument_list
( "("
field_expression
field_expression
identifier "performance"
. "."
field_identifier "current"
-> "->"
field_identifier "wall_timer"
) ")"
; ";"
preproc_ifdef
#ifdef "#ifdef"
identifier "PRINT_TIME_STATS_EVERY_QUERY"
expression_statement
call_expression
identifier "print_performance"
argument_list
( "("
field_expression
identifier "performance"
. "."
field_identifier "current"
) ")"
; ";"
#endif "#endif"
comment "/* PRINT_TIME_STATS_EVERY_QUERY */"
expression_statement
assignment_expression
field_expression
identifier "performance"
. "."
field_identifier "current"
= "="
null
NULL "NULL"
; ";"
#endif "#endif"
comment "/* GATHER_TIME_STATS */"
} "}"
comment "/***********************************************************"...
comment "/**\n Release all the memory allocated by the state.\n*******"...
function_definition (+120 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Run B&B until we find the best solution.\n*************"...
function_definition (+327 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Wrapper that actually runs the branch & bound, and ret"...
function_definition
primitive_type "void"
function_declarator (+34 nodes collapsed)
compound_statement
{ "{"
declaration
struct_specifier
struct "struct"
type_identifier "cm_state"
init_declarator
pointer_declarator
* "*"
identifier "state"
= "="
call_expression
identifier "cm_state_init"
argument_list
( "("
identifier "pcity"
, ","
identifier "negative_ok"
) ")"
; ";"
declaration (+21 nodes collapsed)
comment "/* Refresh the city. Otherwise the CM can give wrong results"...
expression_statement
call_expression
identifier "city_refresh_from_main_map"
argument_list
( "("
identifier "nmap"
, ","
identifier "pcity"
, ","
null
NULL "NULL"
) ")"
; ";"
expression_statement
call_expression
identifier "cm_find_best_solution"
argument_list
( "("
identifier "state"
, ","
identifier "param"
, ","
identifier "result"
, ","
identifier "negative_ok"
) ")"
; ";"
expression_statement
call_expression
identifier "cm_state_free"
argument_list
( "("
identifier "state"
) ")"
; ";"
} "}"
comment "/***********************************************************"...
comment "/**\n Returns true if the two cm_parameters are equal.\n*****"...
function_definition (+219 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Copy the parameter from the source to the destination "...
function_definition (+48 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Initialize the parameter to sane default values.\n*****"...
function_definition (+100 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Initialize the parameter to sane default values that w"...
function_definition (+102 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Count the total number of workers in the result.\n*****"...
function_definition (+91 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Count the total number of specialists in the result.\n*"...
function_definition (+55 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Count the total number of citizens in the result.\n****"...
function_definition (+36 nodes collapsed)
comment "/***********************************************************"...
comment "/**\n Copy the city's current setup into the cm result struc"...
function_definition
primitive_type "void"
function_declarator (+22 nodes collapsed)
compound_statement
{ "{"
expression_statement
call_expression
identifier "cm_result_copy"
argument_list
( "("
identifier "result"
, ","
identifier "pcity"
, ","
null
NULL "NULL"
) ")"
; ";"
} "}"
comment "/***********************************************************"...
comment "/**\n Copy the city's current setup into the cm result struc"...
function_definition
storage_class_specifier
static "static"
primitive_type "void"
function_declarator (+28 nodes collapsed)
compound_statement
{ "{"
declaration
struct_specifier
struct "struct"
type_identifier "tile"
init_declarator
pointer_declarator
* "*"
identifier "pcenter"
= "="
call_expression
identifier "city_tile"
argument_list
( "("
identifier "pcity"
) ")"
; ";"
declaration (+21 nodes collapsed)
comment "/* Clear worker positions */"
expression_statement (+36 nodes collapsed)
expression_statement
call_expression
identifier "city_tile_iterate_index"
argument_list
( "("
identifier "nmap"
, ","
field_expression
identifier "result"
-> "->"
field_identifier "city_radius_sq"
, ","
identifier "pcenter"
, ","
identifier "ptile"
, ","
identifier "ctindex"
) ")"
; ""
compound_statement
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "workers_map"
== "=="
null
NULL "NULL"
) ")"
compound_statement
{ "{"
comment "/* Use the main map */"
declaration
struct_specifier
struct "struct"
type_identifier "city"
init_declarator
pointer_declarator
* "*"
identifier "pwork"
= "="
call_expression
identifier "tile_worked"
argument_list
( "("
identifier "ptile"
) ")"
; ";"
expression_statement
assignment_expression
subscript_expression
field_expression
identifier "result"
-> "->"
field_identifier "worker_positions"
[ "["
identifier "ctindex"
] "]"
= "="
parenthesized_expression
( "("
binary_expression
binary_expression
null
NULL "NULL"
!= "!="
identifier "pwork"
&& "&&"
binary_expression
identifier "pwork"
== "=="
identifier "pcity"
) ")"
; ";"
} "}"
else_clause (+22 nodes collapsed)
} "}"
expression_statement
identifier "city_tile_iterate_index_end"
; ";"
comment "/* Copy the specialist counts */"
function_definition (+29 nodes collapsed)
expression_statement
identifier "specialist_type_iterate_end"
; ";"
comment "/* Find the surplus production numbers */"
expression_statement (+27 nodes collapsed)
comment "/* This is a valid result, in a sense */"
expression_statement
assignment_expression
field_expression
identifier "result"
-> "->"
field_identifier "found_a_valid"
= "="
true "TRUE"
; ";"
} "}"
comment "/***********************************************************"...
comment "/**\n Debugging routines.\n**********************************"...
preproc_ifdef (+828 nodes collapsed)
comment "/* CM_DEBUG */"
preproc_ifdef (+117 nodes collapsed)
comment "/* GATHER_TIME_STATS */"
comment "/***********************************************************"...
comment "/**\n Print debugging information about one city.\n**********"...
function_definition
primitive_type "void"
function_declarator
identifier "cm_print_city"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
struct_specifier
struct "struct"
type_identifier "city"
pointer_declarator
* "*"
identifier "pcity"
) ")"
compound_statement
{ "{"
declaration
struct_specifier
struct "struct"
type_identifier "tile"
init_declarator
pointer_declarator
* "*"
identifier "pcenter"
= "="
call_expression
identifier "city_tile"
argument_list
( "("
identifier "pcity"
) ")"
; ";"
declaration (+21 nodes collapsed)
expression_statement (+27 nodes collapsed)
expression_statement (+28 nodes collapsed)
expression_statement
call_expression
identifier "log_test"
argument_list
( "("
string_literal
" "\""
string_content " workers at:"
" "\""
) ")"
; ";"
expression_statement (+21 nodes collapsed)
compound_statement
{ "{"
declaration
struct_specifier
struct "struct"
type_identifier "city"
init_declarator
pointer_declarator
* "*"
identifier "pwork"
= "="
call_expression
identifier "tile_worked"
argument_list
( "("
identifier "ptile"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
null
NULL "NULL"
!= "!="
identifier "pwork"
&& "&&"
binary_expression
identifier "pwork"
== "=="
identifier "pcity"
) ")"
compound_statement (+54 nodes collapsed)
} "}"
expression_statement
identifier "city_tile_iterate_index_end"
; ";"
expression_statement (+29 nodes collapsed)
expression_statement (+29 nodes collapsed)
expression_statement
call_expression
identifier "log_test"
argument_list
( "("
string_literal
" "\""
string_content " trade = %3d"
" "\""
, ","
subscript_expression
field_expression
identifier "pcity"
-> "->"
field_identifier "surplus"
[ "["
identifier "O_TRADE"
] "]"
) ")"
; ";"
expression_statement (+29 nodes collapsed)
expression_statement
call_expression
identifier "log_test"
argument_list
( "("
string_literal
" "\""
string_content " luxury = %3d"
" "\""
, ","
subscript_expression
field_expression
identifier "pcity"
-> "->"
field_identifier "prod"
[ "["
identifier "O_LUXURY"
] "]"
) ")"
; ";"
expression_statement
call_expression
identifier "log_test"
argument_list
( "("
string_literal
" "\""
string_content " science = %3d"
" "\""
, ","
subscript_expression
field_expression
identifier "pcity"
-> "->"
field_identifier "prod"
[ "["
identifier "O_SCIENCE"
] "]"
) ")"
; ";"
} "}"
comment "/***********************************************************"...
comment "/**\n Print debugging information about a full CM result.\n**"...
function_definition (+287 nodes collapsed)