12005-06-06 02:33 Eric McDonald <eric_mcdonald@users.sourceforge.net> 2 3 Merge in CVS trunk between 'BPT_EMCDONALD_AI_12' and 4 'BPT_EMCDONALD_AI_13'. 5 62005-06-06 02:22 Eric McDonald <eric_mcdonald@users.sourceforge.net> 7 8 Update documentation. 9 * refman.texi (create-as-build): New entry. 10 11 Let standard set of units use 'create-as-build'. 12 * stdunit.g: Comment out create-specific tables. 13 (create-as-build): Enable for all utype pairs. 14 152005-06-06 01:08 Eric McDonald <eric_mcdonald@users.sourceforge.net> 16 17 Allow create action to act as a build action. 18 * table.def (uu_create_as_build): New TableUU, 'create-as-build'. 19 * actions.c (materials_req_for_build): New static function. 20 Materials requirement for build or create-as-build action. 21 (could_create): Fix bugs, and handle 'uu_create_as_build'. 22 (can_create_common): Use build-related values instead of 23 create-related values, if 'uu_create_as_build' is set. 24 (can_build): Call 'materials_req_for_build' instead of directly 25 computing consumption. 26 (consume_materials_for_build): New static function. 27 Consume materials needed by a build or create-as-build action. 28 (do_create_action_common_1): Use build-related values instead of 29 create-related values, if 'uu_create_as_build' is set. 30 (set_created_unit_props): Likewise. 31 (do_build_action): Call 'consume_materials_for_build' instead of 32 directly computing consumption. 33 * 3rd-age.g (unit-consumption-per-cp): Rename table, and make sure 34 that places do not charge materials for being colonized. 35 * advances.g: Likewise. 36 * civ2.g: Likewise. 37 * solar.g (unit-consumption-per-cp): Rename table. 38 39 Possibly fix "repair of healthy units" bug. 40 * aioprt.cc (handle_construction_or_repair): Only score repair, 41 if the unit is completed. 42 43 Rename 'unit-consumption-per-cp' for consistency. 44 Make consumption per CP apply to creation as well as building. 45 * table.def (um_consumption_per_cp): Rename GDL to 46 'consumption-per-cp'. 47 48 More cleanup and archival of the games library. 49 * colonizer.g: Move to 'bitrot' archive. 50 * game.dir: Remove 'colonizer' entry. 51 * bitrot/colonizer.g: New game. 52 * bitrot/game.dir: Add 'colonizer' entry. 53 542005-06-05 21:22 Eric McDonald <eric_mcdonald@users.sourceforge.net> 55 56 Bring documentation up-to-date wrt recent changes. 57 * refman.texi (can-create): New entry. 58 (can-build): New entry. 59 (minimal-size-goal): Rename to 'ai-minimal-size-goal' and reword 60 to be more generic. 61 62 Finish cleaning out the rest of the colonization logic. 63 * plan.def (PLAN_COLONIZE): Delete. 64 * ai.c (assign_to_colonize): Delete. 65 * mplayer.c (mplayer_decide_plan): Remove colonization plan 66 lottery chance slot and associated logic. 67 * plan.c (plan_colonize): Cut out everything but a few snippets. 68 69 Fix bug in UI code. 70 * ui.c (impl_build): Only assign "construct" in task, if it would 71 succeed. Sometimes when curunit occupies entire cell, it is 72 returned as the transport to create in, but in reality, the cell 73 is to be created in, not the transport. 74 752005-06-05 20:21 Eric McDonald <eric_mcdonald@users.sourceforge.net> 76 77 Ensure that Tkconq and the generic UI code rebuild 78 when the AI files are changed. 79 * kernel/Makefile.in (ui.o): Depend on 'AI_H' headers. 80 * tcltk/Makefile.in (AI_H): New variable. AI headers. 81 (ALL_H): Include 'AI_H'. 82 83 Add support for autoconf assignment of "sizeof" macros. 84 Start to add support for making primitve integer types of known size. 85 * acdefs.h.in: Undef 'SIZEOF_INT', 'SIZEOF_LONG', and 86 'SIZEOF_LONG_LONG'. 87 * config.h: Add typedefs to 'Xconq' namespace. 88 (Byte): Typedef of 'unsigned char'. 89 (Z16): Typedef of 'signed short int'. 90 (Z16u): Typedef of 'unsigned short int'. 91 (Z32): Typedef of 'signed int' or 'signed long int'. 92 (Z32u): Typedef of 'unsigned int' or 'unsigned long int'. 93 (Z64): Typedef of 'signed long' or 'signed long long'. 94 (Z64u): Typedef of 'unsigned long' or 'unsigned long long'. 95 96 Remove or disable more code associated with the colonization plan. 97 Improve colonization support in constructor oprole. 98 * utype.def (u_ai_minimal_size_goal): Renamed from 99 'u_minimal_size_goal'. New GDL name is 'ai-minimal-size-goal'. 100 * ai.c: Ifdef out colonization plan assignment, and other colonizer- 101 related support. 102 * aioprt.cc (generate_construction_task): Check if the cell would 103 allow the advanced utype to meet its size goal. 104 * aiunit2.h (could_meet_size_goal): New function decl. 105 Could u meet its size goal, if located at the given position? 106 * aiunit2.cc (could_meet_size_goal): New function. 107 * iplayer.c (iplayer_decide_plan): Remove assignments to colonization 108 and colonization support. 109 (iplayer_adjust_plan): Remove logic pertaining to colonization. 110 * plan.c (execute_plan): Likewise. 111 (good_cell_to_colonize): Delete. 112 * run.c (auto_pick_new_build_task): Remove logic pertaining to 113 colonization. 114 * 3rd-age.g: Change 'minimal-size-goal' to 'ai-minimal-size-goal'. 115 * advances.g: Likewise. 116 * civ2.g: Likewise. 117 * colonizer.g: Likewise. 118 119 Prepare support for action masks. 120 Remove now-unused 'buildingdone' flag. 121 Delete remnants of special ACP-indep construction code. 122 * conq.h (ActionMask): Typedef of 'Xconq::Z64u'. 123 An action mask can hold 64 types of actions. 124 (ACTM_CANNOT_TOOLUP): New data macro. 125 Cannot toolup for any? 126 (ACTM_CANNOT_CREATE): New data macro. 127 Cannot create any? 128 (ACTM_CANNOT_BUILD): New data macro. 129 Cannot build any? 130 (ACTM_CANNOT_REPAIR): New data macro. 131 Cannot repair any? 132 * kernel.h (set_unit_buildingdone): Delete. 133 * kpublic.h (net_set_unit_buildingdone): Delete. 134 * plan.c (set_unit_buildingdone): Delete. 135 * run.c (unit_still_acting): Remove logic specific to ACP-indep 136 builders. 137 (unit_still_acting_without_plan): Likewise. 138 (move_one_unit_multiple): Delete ACP-indep construction code. 139 (run_construction): Delete much of the code. Leave a few useful 140 snippets. 141 * run2.c (reset_all_reserves): Remove reset of 'buildingdone' flag. 142 * task.c (set_build_task): Remove set of 'buildingdone' flag. 143 (push_build_task): Likewise. 144 * tp.c (net_set_building_done): Delete. 145 (receive_unit_prop): Remove 'buildingdone' logic. 146 * unit.c (create_unit): Likewise. 147 * unit.h (struct a_unit): Remove 'buildingdone' flag. 148 (has_acp_left): Remove logic specific to ACP-indep builders. 149 1502005-06-05 02:46 Eric McDonald <eric_mcdonald@users.sourceforge.net> 151 152 Fix bugs in building and self-improvement. 153 Fix bug with Tkconq action-enablement in UI. 154 Make ACP-indep construction work correctly again. 155 Fix some (but not all) end-of-turn pauses. 156 * utype.def (u_base_construction_worth): New (but temporary) AI worth 157 property. 158 * actions.c (check_build_action): Call 'can_build' with buildee 159 instead of buildee utype, so that materials checks are performed. 160 * ai.c (set_u_base_construction_worth): New function. 161 (ai_init_shared): Calculate and set the base construction 162 worth for each utype. 163 * aioprt.cc (generate_construction_task): Consider location's 164 popularity as a construction spot, and consider resource 165 contention when rejecting possible locations. 166 (choose_construction_or_repair): Consider the return value 167 of 'generate_construction_task' to determine what to return to 168 caller. 169 * aitact.h (n_plan_to_construct_at): New function decl. 170 How many friendly units plan to construct at given location? 171 (resource_contention_with_any): New function decl. 172 Would any units be in contention with an utype at a given location? 173 * aitact.cc (n_plan_to_construct_at): New function. 174 (resource_contention_with_any): New function. 175 * aiunit2.cc (total_worth): Sum more worths into the total. 176 * mplayer.c (mplayer_review_units): Properly set the construct task 177 for units using the Time game upgrade mechanism. 178 (mplayer_decide_plan): Cut out all of the support plan chance slots 179 and logic, and replace with unified construction chance slot and logic. 180 Ifdef out colonization chance slot and logic, since colonization is 181 now handled through construction. 182 * plan.c (plan_defense): Remove ifedeffed out construction-related 183 logic. 184 (plan_improve): Fix bug with 'tmp_u_array' being used by both the 185 function and a function that it calls. Also, make sure that 186 construct tasks are being setup in transports or in cells correctly. 187 * run.c: Finish ifdeffing out the acp-indep construction logic. 188 * task.c (do_build_task): Call 'can_build' with buildee instead of 189 buildee utype. 190 * tkinit.c (update_action_controls_info): Check to make sure that 191 the unit is active before calling 'can_repair_any' and 192 'can_construct_any', and make sure that the 'valid' macro is 193 used to check those function's results. 194 1952005-06-02 01:43 Eric McDonald <eric_mcdonald@users.sourceforge.net> 196 197 Make creation and building ACP-less. 198 Rework build task. 199 Some more repair-related tests. 200 Improvement task management. Include support for enqueuing ops. 201 * table.def (uu_build): New TableUU, 'can-build'. 202 (uu_create): New TableUU, 'can-create'. 203 * task.def (TASK_BUILD): Alter parameter list. 204 * conq.h (ADD_TO_AGENDA_AS_LIFO): New data macro. 205 Push onto the top of the task agenda. 206 (ADD_TO_AGENDA_AS_FIFO): New data macro. 207 Enqueue at the end of the task agenda. 208 (CLEAR_AGENDA): New data macro. Moved from disparate files. 209 Clear task agenda, and set as new agenda item. 210 (could_create): New function decl. 211 Could u create u2? 212 (could_create_any): New function decl. 213 Could u create any utype? 214 (could_build): New function decl. 215 Could u build u2? 216 (could_build_any): New function decl. 217 Could u build any utype? 218 (can_build): New function decl. 219 Can given actor-builder pair build on a given utype? 220 (can_build): New function decl. 221 Can given actor-builder pair build on a given unit? 222 (can_repair): New function decl. 223 Can given actor-repairer pair explicitly repair given utype? 224 * game.h (could_create): Delete. 225 (could_build): Delete. 226 * actions.c (could_create): New function. 227 (could_create_any): New function. 228 (could_build): New function. 229 (could_build_any): New function. 230 (can_build): New function. 231 (can_build): Refactored. 232 (can_repair): New function. 233 (can_repair): Refactored. 234 * ai.c (build_depot_for_self): Set construct task instead of build 235 task. 236 * aioprt.cc (choose_construction_or_repair): Set build task with new 237 args. 238 * aiunit.h (can_repair_any): New function decl. 239 Can given actor-repairer pair repair any utype? 240 * aiunit.cc (can_repair_any): New function. 241 * help.c (describe_utype): Change calls from "type_can_*" to 242 "could_*_any" form. 243 * iplayer.c (iplayer_adjust_plan): Replace now-obsolete 244 'net_resume_build' can with 'net_set_build' call. Replace build call 245 with construct call. 246 * kpublic.h (net_resume_build_task): Delete. 247 * mplayer.c (mplayer_review_units): Replace call to build task with 248 call to construct task. 249 * plan.c (CLEAR_AGENDA): Delete. 250 (plan_passive): Use call to construct task rather than build task 251 for intro game hack. 252 (plan_colonize): Use call to construct task rather than build task. 253 (plan_improve): Likewise. 254 * run.c (run_construction): Replace build task resume with build 255 task set. 256 (auto_pick_new_build_task): Use call to construct task rather than 257 build task. 258 * task.c (CLEAR_AGENDA): Delete. 259 (do_build_task): Rewrite. 260 (do_construct_task): Call build task with new arg list. 261 (add_task): Use new task management macros in management cases. 262 New case, 'ADD_TO_AGENDA_AS_FIFO, enqueues a task at end of list, 263 rather than pushes at front of list. 264 (create_build_task): Rewrite. 265 (set_build_task): Rewrite. 266 (push_build_task): Rewrite. 267 (resume_build_task): Delete. 268 * tp.c (CLEAR_AGENDA): Delete. 269 (net_set_build_task): Call set and create functions with 270 new argument list. 271 (net_push_build_task): Likewise. 272 (net_resume_build_task): Delete. 273 * ui.h (impl_build): Add new parameter to parameter list. 274 * ui.c (impl_build): Call construct instead of build task. 275 Handle construct-in case. Add transport unit to parameter list. 276 * ccmd.c: Include 'aiunit.h' and 'aiunit2.h'. 277 (do_build): Call 'impl_build' with proper args depending on 278 whether we are creating in cell or transport. 279 * sdlcmd.cc: Include 'aiunit.h' and 'aiunit2.h'. 280 (do_build): Call 'impl_build' with proper args depending on 281 whether we are creating in cell or transport. 282 (aux_build): Likewise. 283 (aux_build2): Likewise. 284 * tkcmd.c: Include 'aiunit.h' and 'aiunit2.h'. 285 (do_build): Call 'impl_build' with proper args depending on 286 whether we are creating in cell or transport. 287 (aux_build): Likewise. 288 (aux_build2): Likewise. 289 * tkinit.c: Include 'aiunit.h'. 290 (update_action_controls_info): Call 'can_construct_any' instead of 291 a combination of 'can_repair' and 'can_build'. Call 292 'can_repair_any' instead of 'can_repair'. 293 * 1805.g: Remove unneeded setting of 'acp-to-create', 'acp-to-build', 294 and 'acp-to-repair' tables. 295 * 3rd-age.g: Add 'can-create' and 'can-build' tables based on the 296 'acp-to-create' and 'acp-to-build' tables. 297 * advances.g: Likewise. 298 * ancient-days.g: Likewise. 299 * awls-rules.g: Likewise. 300 * awls-testbed.g: Likewise. 301 * battles.g: Likewise. 302 * bolodd2.g: Likewise. 303 * bolodd3.g: Likewise. 304 * cave.g: Likewise. 305 * cave2.g: Likewise. 306 * cil-rules.g: Likewise. 307 * civ2.g: Likewise. 308 * classic.g: Likewise. 309 * colonizer.g: Likewise. 310 * fantasy.g: Likewise. 311 * fred.g: Likewise. 312 * future.g: Likewise. 313 * galaxy.g: Likewise. 314 * galaxy2.g: Likewise. 315 * insects.g: Likewise. 316 * lhsunit.g: Likewise. 317 * logunit.g: Likewise. 318 * mars.g: Likewise. 319 * modern.g: Likewise. 320 * mormon.g: Likewise. 321 * old-empire.g: Likewise. 322 * opal-rules.g: Likewise. 323 * postmodern.g: Likewise. 324 * quest.g: Likewise. 325 * roman.g: Likewise. 326 * russian-rev.g: Likewise. 327 * solar.g: Likewise. 328 * space.g: Likewise. 329 * spec-rules.g: Likewise. 330 * stdunit.g: Likewise. 331 * time.g: Likewise. 332 * voyages.g: Likewise. 333 * wizard.g: Likewise. 334 * ww2-adv.g: Likewise. 335 336 Fix crashing bug in SDL interface. 337 (Reported by Lincoln Peters.) 338 * sdlmain.cc (update_side_display): Watch out for NULL module titles. 339 Also be more cautious about concatenating text to buffers. 340 341 Fix apparent bug in net receive code. 342 * tp.c (receive_uprop): Call appropriate setters upon receipt of 343 the 'buildingdone' and 'researchdone' flags. Do this, instead of 344 calling the setter for the 'autobuild' flag. 345 346 Cleanup code. 347 * keyword.def (K_AUTOBUILD): Delete. It is unused. 348 (K_AUTOPLAN): Delete. 349 * kernel.h (set_unit_autoplan): Delete. It is unused. 350 (set_unit_autobuild): Delete. 351 (set_unit_autoresearch): Delete. 352 * kpublic.h (net_set_unit_autoplan): Delete. 353 (net_set_unit_autobuild): Delete. 354 (net_set_unit_autoresearch): Delete. 355 * ai.c (goal_truth): Cleanup unused vars and code. 356 (ai_pick_side_research_goal): Cleanup unused vars. 357 * mplayer.c (determine_subgoals): Cleanup unused vars and code. 358 (mplayer_adjust_plan): Cleanup unused vars. 359 * plan.c (set_unit_autoplan): Delete. 360 (set_unit_autoresearch): Delete. 361 (set_unit_autobuild): Delete. 362 * read.c (interp_unit): Remove 'K_AUTOBUILD', 'K_AUOTPLAN', and 363 'K_AUTORESEARCH' cases. 364 * run.c (move_one_unit_multiple): Remove check against unit's 365 'autobuild' flag. Remove weird piece of what is presumably leftover 366 debugging code. 367 (run_construction): Remove checks against unit's 'autobuild' flag. 368 (run_research): Remove check against unit's 'autoresearch' flag. 369 * tp.c (net_set_unit_autoplan): Delete. 370 (net_set_unit_autoresearch): Delete. 371 (net_set_unit_autobuild): Delete. 372 (receive_unit_prop): Remove cases for unit's 'autobuild', 373 'autoresearch', and 'autoplan' flags. 374 * unit.h (struct a_unit): Remove 'autobuild', 'autoresearch', 375 and 'autoplan' flags. 376 (can_toolup): Delete. 377 (type_can_toolup): Delete. 378 (can_create): Delete. 379 (type_can_create): Delete. 380 (can_complete): Delete. 381 (type_can_complete): Delete. 382 (can_repair): Delete. 383 (type_can_repair): Delete. 384 * unit.c (create_unit): Remove setting of 'autobuild', 'autoresearch', 385 and 'autoplan' flags for a new unit. 386 (change_unit_type): Likewise. 387 (type_can_toolup): Delete. 388 (can_create): Delete. 389 (type_can_create): Delete. 390 (can_complete): Delete. 391 (type_can_complete): Delete. 392 (can_repair): Delete. 393 (type_can_repair): Delete. 394 * write.c (write_unit_properties): Remove writing of 'autobuild', 395 'autoresearch', and 'autoplan' flags. 396 3972005-05-30 19:11 Eric McDonald <eric_mcdonald@users.sourceforge.net> 398 399 Separate out AI header make dependencies. 400 kernel/Makefile.in: Change deps. 401 (AI_H): New variable. List of AI headers. 402 403 Fix bugs in tooling checks. 404 New action result type. 405 * history.def (A_CONSTRUCT_NO_TOOLING): New action result. 406 * actions.c (can_create_common): Return 'A_CONSTRUCT_NO_TOOLING' 407 as appropriate. 408 (can_build): Likewise. 409 * aioprt.cc (choose_utype_to_construct): Consider a 410 'A_CONSTRUCT_NO_TOOLING' result to be valid. Do not choose utypes 411 that would not have access to enough of their operating terrain to 412 make them worthwhile. 413 (generate_construction_task): Perform primitive scoring based on 414 distance from constructor. (Needs enhancement.) 415 * aiunit.cc (can_create_completed): Consider a 416 'A_CONSTRUCT_NO_TOOLING' result to be valid. 417 (can_construct): Likewise. 418 * nlang.c (action_result_desc): Handle 'A_CONSTRUCT_NO_TOOLING' case. 419 * bolodd2.g (can-toolup-for): New table, because toolup is now 420 allowed to be ACP-less. 421 * bolodd3.g: Likewise. 422 * classic.g: Likewise. 423 * future.g: Likewise. 424 * old-empire.g: Likewise. 425 * postmodern.g: Likewise. 426 * wizard.g: Likewise. 427 * ww2-adv.g: Likewise. 428 429 Remove random plan, support plans, and other cruft from plan code. 430 * plan.def (PLAN_RANDOM): Delete. 431 * plan.c (plan_offense_support): Delete. 432 (plan_explorer_support): Delete. 433 (plan_colonize_support): Reduce, and leave small part ifdeffed out. 434 (plan_random): Delete. 435 (execute_plan): Remove 'PLAN_RANDOM' case. 436 (plan_offense): Remove ifdeffed out call to support plan. 437 (plan_colonize): Likewise. 438 (plan_exploration): Likewise. 439 (do_for_occupants): Remove unused variables. 440 (plan_defense): Remove support part of plan. Failover to construtor 441 oprol, if necessary. 442 * run.c (auto_pick_new_build_task): Remove 'PLAN_RANDOM' case. 443 Do not set a random plan if no other plan can be set; instead 444 become passive and go into reserve. 445 446 Shuffle some more unmaintained games into bitrot archive. 447 * greek.g: Likewise. 448 * pelops.g: Move to 'bitrot' directory. 449 * game.dir: Remove 'pelops' from list. 450 * bitrot/game.dir: Add 'pelops' to list. 451 452 Fix bug in Classic Xconq game and its children. 453 * classic.g (unit-size-as-occupant): Make sure that bases cannot 454 fit inside of bases. This prevents construction of bases inside of 455 bases inside of bases.... 456 4572005-05-29 21:37 Eric McDonald <eric_mcdonald@users.sourceforge.net> 458 459 Implement new construction features. 460 Fix bugs in operational roles. 461 Fix bug in hp-recovery mechanism. 462 Improve construction AI. 463 * table.def: Properly alphabetize some of the tables. 464 (uu_can_occupy_incomplete): New TableUU, 'can-occupy-incomplete'. 465 (uu_toolup_for): New TableUU, 'can-toolup-for'. 466 (um_consumption_per_tooledup): New TableUM, 467 'consumption-per-tooledup'. 468 (um_consumption_per_toolup): New TableUM, 'consumption-per-toolup'. 469 (um_consumption_per_tp): New TableUM, 'consumption-per-tp'. 470 (um_to_toolup): New TableUM, 'material-to-toolup'. 471 * refman.texi (can-occupy-incomplete): New. 472 (can-toolup-for): New. 473 (material-to-toolup): New. 474 (consumption-per-tooledup): New. 475 (consumption-per-toolup): New. 476 (consumption-per-tp): New. 477 * task.def (TASK_BUILD): Change verb from "Build" to "Construct". 478 (TASK_CONSTRUCT): New task. 479 * conq.h (MReq_AGENT_TREASURY): New data macro. 480 Use agent's side's treasury rather than actor's side's treasury. 481 (get_materials_availability): New function decl. 482 What are current and max materials availabilities for an actor-agent 483 pair? 484 (can_meet_materials_requirement): New function decl. 485 Is materials requirement satisfied by availabilities? 486 (can_create): Replace with 'can_create_common'. 487 (can_create_common): Replace 'can_create'. 488 (has_enough_tooling): New function decl. 489 Does the constructor have enough tooling to construct u2? 490 (could_toolup_for): New function decl. 491 Could u toolup for u2? 492 (could_toolup_for_any): New function decl. 493 Could u toolup for any utype? 494 (can_toolup_for): New function decl. 495 Can given actor-constructor pair toolup for given utype? 496 * actions.c (get_materials_availability): New function. 497 (can_meet_materials_requirement): New function. 498 (has_enough_tooling): New function. 499 (could_toolup_for): New function. 500 (could_toolup_for_any): New function. 501 (can_toolup_for): New function. 502 (can_create_common): Changes. 503 (prep_toolup_action): Changes. 504 (do_toolup_action): Refactor. 505 (check_toolup_action): Refactor. 506 (adjust_tooling_crossover): Make sure that all toolings are 507 reset, so that it is fair to toolings reset by crossover. 508 (do_create_action_common_1): New function. 509 (do_create_action_common_2): New function. 510 (do_create_in_action): Refactor. 511 (check_create_in_action): Refactor. 512 (check_create_common): Delete. 513 (do_create_at_action): Refactor. 514 (check_create_at_action): Refactor. 515 * aioprt.h (enum OpRole_Outcome): Operational role outcomes. 516 (for_all_oproles): Deal with NULL master AI for side. 517 (for_all_oproles_of_type): Likewise. 518 (choose_transport_to_construct_in): Change parameter list. 519 (handle_constructor_oprole): Change return type. 520 * aioprt.cc: Include 'ai.h' for now, so that we can use theaters. 521 (choose_utype_to_construct): Changes to calls. Consider how 522 toolup affects turns to complete an utype. 523 (choose_transport_to_construct_in): Implement. 524 (generate_construction_task): Fix bugs. Add support for theater-wide 525 location searches for mobile units with construction ranges >= 0. 526 Push move tasks as appropriate. 527 (choose_construction_or_repair): Fix bug in debugging output for 528 new construction. 529 (handle_constructor_oprole): Return oprole outcome as appropriate. 530 (handle_oprole): Deal with oproles depending on oprole outcomes. 531 * aiunit.h (can_be_on): Add optional parameter. 532 (can_be_on_known): Add optional parameter. 533 (can_survive_on_known): Add optional parameter to all signatures. 534 (can_be_in): New function decl. 535 Can a given utype be in the given transport? 536 * aiunit.cc (can_be_on): Add parameter. Handle list of volume 537 cancellations. 538 (can_be_on_known): Likewise. 539 (can_survive_on_known): Likewise, for all signatures. 540 (could_be_occupant_of): Handle occ limits. 541 (can_be_in): New function. 542 (can_create_completed_unit): Changes. 543 * aiunit2.h (can_create_in): New function decl. 544 Does a given side seem to be able to create u3 in a given transport? 545 (can_create_at): New function decl. 546 Does a given side seem to be able to create u3 at a given location? 547 (tp_per_turn_est): New function decl. 548 How many TP for a given utype can a given unit add to itself per turn? 549 * aiunit2.cc (seer_worth): Divide worth accumulator by 100, before 550 proceeding with other worth modifications. This will hopefully 551 prevent an overflow of 32-bit ints in some cases. (What should be 552 done is to take the mean of the see chances across all utypes, and 553 then calculate the worth with that.) 554 (can_create_in): New function. 555 (can_create_at): New function. 556 (tp_per_turn_est): New function. 557 (cp_per_turn_est): Changes. 558 (hp_per_turn_est): Changes. 559 * help.c (describe_utype): Use 'could_toolup_for_any' instead of 560 'type_could_toolup'. 561 * kernel.h (any_hp_recovery): Add variable to namespace 'Xconq'. 562 * init.c (calculate_globals): Properly consider the hp-recovery 563 mechanism. 564 * mplayer.c (mplayer_decide_plan): Boost the worth of base 565 constructors to increase their chance of being able to construct 566 bases. 567 * nlang.c (task_desc): Store value for 5th argument to a task. 568 Handle new case for 'TASK_CONSTRUCT'. 569 * run.c (move_one_unit_multiple): Ignore ACP-indep special junk. 570 This is in preparation for getting rid of it. 571 * run2.c (any_hp_recovery): Initialize to FALSE. 572 (run_auto_repair): Fix bugs which preventing hp-recovery mechanism 573 from functioning correctly. 574 * task.c (do_toolup_subtask): New static function. 575 Perform a toolup subtask on behalf of a construct/build task. 576 (do_construct_task): New function. Create new units, or, if 577 created, then push/set build tasks to complete. 578 (create_construct_task): New function. 579 (set_construct_task): New function. 580 (push_construct_task): New function. 581 * tp.c (net_set_construct_task): New function. 582 (net_push_construct_task): New function. 583 * unit.c (can_toolup): Delete. 584 585 Fix bugs related to change-type action. 586 * unit.c (change_unit_type): Only consume materials of in-play 587 units. 588 (enter_cell): Suppress overcorwded cell warnings for now. 589 (This is not an ideal fix, but the change-type code assumes that 590 this will be allowed. Need to rethink the change-type code.) 591 5922005-05-21 16:09 Eric McDonald <eric_mcdonald@users.sourceforge.net> 593 594 Archive or delete some unmaintained games that do not work well. 595 * lib/bitrot: New directory. 596 * ChangeLog-bellum: Delete file. 597 * bellum.g: Likewise. 598 * t-bellum.g: Likewise. 599 * u-bellum.g: Likewise. 600 * uu-bellum.g: Likewise. 601 * wreckr-t.g: Likewise. 602 * wreckreation.g: Likewise. 603 * empire.g: Move to 'bitrot' directory. 604 * napoleon.g: Likewise. 605 * space-civ.g: Likewise. 606 * game.dir: Remove 'bellum', 'empire', 'space-civ', and 'wreckreation'. 607 608 Implement new construction and repair features. 609 Improve support for operational roles. 610 Add tatical-level calculations for AI. 611 Enhance materials consumption code. 612 * kernel/Makefile.in: Add 'aitact.o' and 'aitact.h' as appropriate. 613 * table.def (uu_repair): New TableUU, 'can-repair'. 614 (um_consumption_per_built): New TableUM, 'consumption-per-built'. 615 (um_consumption_per_create): New TableUM, 'consumption-per-create'. 616 (um_consumption_per_repaired): New TableUM, 617 'consumption-per-repaired'. 618 (uu_hp_per_repair): Rename from 'uu_repair'. 619 (uu_hp_to_repair): Delete. 620 (uu_repair_range): New TableUU, 'repair-range'. 621 (um_consumption_per_cp): Allow negative consumption. 622 * conq.h (can_meet_materials_requirement): Modify. 623 (consume_materials): Likewise. 624 (can_build): Likewise. 625 (could_auto_repair): New function decl. 626 Could u auto-repair u2? 627 (can_auto_repair): New function decl. 628 Can given repairer auto-repair given repairee? 629 (could_repair): New function decl. 630 Could u explicitly repair u2? 631 (can_repair): New function decl. 632 Can given repairer explicitly repair given repairee? 633 * game.h (u_mobile): New function macro. Is utype mobile? 634 (could_repair): Delete. 635 * refman.texi (hp-recovery): Move to section on repair action. 636 (hp-to-reover): Likewise. 637 (consumption-per-build): Reword. 638 (consumption-per-built): New. 639 (can-repair): New. 640 (material-to-repair): Update. 641 (consumption-per-repair): Update. 642 (hp-to-repair): Delete. 643 * actions.c (can_any_repair_common): New function. 644 (can_meet_materials_requirement): New parameters to control 645 utype used in lookup, and multiplier on requirement. 646 (consume_materials): Likewise. 647 (can_create): Move. 648 (can_build); Move. 649 (could_auto_repair): New function. 650 (can_auto_repair): New function. 651 (could_repair): New function. 652 (can_repair): New function. 653 (do_create_in_action): Rewrite. 654 (do_create_at_action): Rewrite. 655 (build_step_consumption): Delete. 656 (prep_repair_action): Rewrite. 657 (do_repair_action): Rewrite. 658 (check_repair_action): Rewrite. 659 * ai.c (run_local_ai): Call 'handle_oproles' instead of 660 'evaluate_oproles'. 661 * aioprt.h: Wrap in 'Xconq::AI' namespace. Rename 'AI_OpRole' to 662 'OpRole' everywhere. 663 (struct OpRole): Add 'execs_this_turn' and 'fails_this_turn' 664 fields. 665 (choose_utype_to_construct): New function decl. 666 Choose utype to construct, and optionally return its relative worth. 667 (choose_transport_to_construct_in): New function decl. 668 Choose transport to construct given utype in. 669 (generate_construction_task): New function decl. 670 Generate an appropriate construction task given constructor and utype. 671 (choose_construction_or_repair): New function decl. 672 Choose a construction or repair task to perform. 673 (handle_constructor_oprole): New function decl. 674 Handle constructor operational role. 675 * aioprt.cc: Include 'aitact.h'. Wrap in 'Xconq::AI' namespace. 676 Rename 'AI_OpRole' to 'OpRole' everywhere. 677 (acquire_oprole): Fix bugs. 678 (release_oprole): Fix bugs. 679 (choose_utype_to_construct): New function. 680 (choose_transport_to_construct_in): New function. 681 (generate_construction_task): New function. 682 (choose_construction_or_repair): New function. 683 (handle_constructor_oprole): New function. 684 (handle_oprole): Release oprole and return if unit is no longer 685 valid. Increment execution counter on each pass. 686 * aiunit.cc (can_construct): Modify call to 'can_build'. 687 * aiunit2.h (cp_per_turn_est): New function decl. 688 How many CP can a given unit add to a given utype per turn? 689 (cp_gained_per_turn_est): New function decl. 690 How many CP can a given side add to a given unit per turn? 691 (hp_per_turn_est): New function decl. 692 How many HP can a given unit add to a given utype per turn? 693 (hp_gained_per_turn_est): New function decl. 694 How many HP can a given side add to a given unit per turn? 695 (total_worth): New function decl. 696 Sum of all the basic worths. 697 * aiunit2.cc (cp_per_turn_est): New function. 698 (cp_gained_per_turn_est): New function. 699 (hp_per_turn_est): New function. 700 (hp_gained_per_turn_est): New function. 701 (total_worth): New function. 702 * help.c (describe_utype): Modify construction and repair 703 descriptions. 704 * kernel.h (any_auto_repair): Add to namespace 'Xconq'. 705 (will_be_auto_repaired): Rename to 'cv__could_be_auto_repaired' and 706 add to namespace 'Xconq'. 707 (auto_repair_range_max): Rename to 'cv__auto_repaired_range_max' and 708 add to namespace 'Xconq'. 709 * init.c (calculate_globals): Use namespace 'Xconq'. Place some 710 globals in that namespace. 711 * mplayer.c (mplayer_init): Initialize new side master struct for 712 AI. 713 (mplayer_init_turn): Reset all oprole per-turn exec counters. 714 (mplayer_decide_plan): Replace assignments to support plans with 715 assignment to new constructor/repairer oprole. 716 (mplayer_adjust_plan): Honor any oprole that is in effect. 717 * nlang.c: Include the various new AI-related headers. 718 (oprole_desc): Describe an operational role. 719 (plan_desc): Alternatively describe an oprole instead of plan, 720 if an oprole is in effect. 721 (task_desc): Alter description of repair task. 722 * plan.c: Ifdef out all invocations of support plans. The constructor 723 oprole supercedes them. 724 (repair_if_damaged): Rewrite to call revised repair task. 725 (maybe_set_materials_goal): Take into consideration the new 726 'um_consumption_per_built' table. 727 * run2.c (run_hp_recovery): Delete. 728 (auto_repair_unit): Delete. 729 (auto_repair_from_in): New static function. 730 Auto-repair from within given transport. 731 (any_auto_repair): Add to namespace 'Xconq'. 732 (will_be_auto_repaired): Rename to 'cv__could_be_auto_repaired' and 733 add to namespace 'Xconq'. 734 (auto_repair_range_max): Rename to 'cv__auto_repaired_range_max' and 735 add to namespace 'Xconq'. 736 (auto_repair_from_here): Revise to use action checking and execution 737 code. 738 * side.h (struct AI_Side): Forward declare inside 'Xconq::AI' 739 namespace. 740 (query_unit_from_uview): New function decl. 741 * side.c (query_unit_from_uview): New function in preparation of 742 eventual client-server separation of code. Returns pointer to an 743 unit from a given uview. 744 * task.def (TASK_REPAIR): Modify arg encoding and parameter list. 745 * task.c: Include some of the new AI headers. 746 (repair_here): Ifdef out. 747 (do_build_task): Get rid of extraneous decls. 748 (do_hit_unit_task): Get rid of weird debugging hack. 749 (do_pickup_task): Get rid of extraneous decls. 750 (do_repair_self_subtask): New function. 751 (do_repair_task): Rewrite. 752 (create_repair_task): Modify. 753 (set_repair_task): Modify. 754 (push_repair_task): Modify. 755 * tp.c (net_set_repair_task): New function. 756 (net_push_repair_task): New function. 757 * 1805.g: Add 'can-repair' table. 758 * gettysburg.g: Likewise. 759 * lhsunit.g: Likewise. 760 * logunit.g: Likewise. 761 * monster.g: Likewise. 762 * opal-rules.g: Likewise. 763 * russian-rev.g: Likewise. 764 * spec-rules.g: Likewise. 765 * stdunit.g: Likewise. 766 * bolodd2.g: Change 'consumtpion-per-build' to 'consumption-per-built'. 767 * bolodd3.g: Likewise. 768 * fantasy.g: Likewise. 769 * modern.g: Likewise. 770 * greek.g: Change 'material-to-build' to 'consumption-per-built'. 771 * postmodern.g: Likewise. 772 * wizard.g: Likewise. 773 * tkmain.c (draw_unit_info): Do not show previous action description. 774 7752005-04-30 23:10 Eric McDonald <eric_mcdonald@users.sourceforge.net> 776 777 Merge in CVS trunk between 'BPT_EMCDONALD_AI_10' and 778 'BPT_EMCDONALD_AI_11'. 779 7802005-04-30 22:37 Eric McDonald <eric_mcdonald@users.sourceforge.net> 781 782 Change behavior of attack vision. 783 * combat.c (one_attack): Instead of calling 'see_exact' call 784 'see_cell'. 785 7862005-04-30 20:39 Eric McDonald <eric_mcdonald@users.sourceforge.net> 787 788 Fix bug in resupply. 789 (Bug reported by Elijah.) 790 * kernel.h (can_auto_resupply_self): Transplant from 'task.c'. 791 * task.c (can_auto_resupply_self); Transplant prototype to 792 'kernel.h'. 793 * plan.c (plan_resupply): If unit can resupply from existing location, 794 then let it do so rather move to another location. 795 7962005-04-30 16:20 Eric McDonald <eric_mcdonald@users.sourceforge.net> 797 798 Try to improve indep city density in Default game. 799 (Thanks to Elijah.) 800 * standard.g (density1): New variant, "More Towns". Double number 801 of indep towns in plains. 802 (density2): New variant, "Even More Towns". Quintuple number of 803 indep towns in plains. 804 8052005-04-30 15:46 Eric McDonald <eric_mcdonald@users.sourceforge.net> 806 807 Nice new terrain images. 808 (Created by Tommy, yobbobandana at yahoo dot co dot nz.) 809 (Imported by Elijah.) 810 * kiwiterr.imf: New image family file. 811 * kiwiterr32x32.gif: New image collection. 812 * kiwiterr44x48.gif: New image collection. 813 814 Update to Opal. 815 * opal-rules.g: Use new Kiwi terrain set. 816 8172005-04-28 02:23 Eric McDonald <eric_mcdonald@users.sourceforge.net> 818 819 Fix buffer overflow in side country grower code. 820 (Thanks to Elijah for bug report.) 821 * mkunits.c (make_countries): Use 'strncat' instead of 'strcat', 822 and shrink remaining length available as buffer is filled. 823 8242005-04-27 02:51 Eric McDonald <eric_mcdonald@users.sourceforge.net> 825 826 Couple of minor AI tweaks. 827 (AI tweaks on the AI development branch? Imagine that.) 828 * ai.c (ai_go_after_victim): If unit has no combat usefulness and 829 cannot move, then return immediately. 830 * plan.c (plan_passive): If unit is AI-controlled, then make sure 831 we check materials levels and act accordingly. 832 * task.c (resupply_here): Check all units in stack to see if any 833 are a valid resupplier, instead of ducking out after encoutering 834 first failure or success. 835 8362005-04-26 02:13 Eric McDonald <eric_mcdonald@users.sourceforge.net> 837 838 Improve RPM spec file. 839 (Thanks to anonymous for pointing out lack of BuildRequires.) 840 * pkg/xconq.spec.in: Update. 841 (BuildRequires): List build deps for building from source RPM. 842 (URL): Change from Redhat to Sourceforge. 843 (Packager): Change from Xconq team to me, since no one else is 844 working on the spec file, and we do not have a team email address 845 at Sourceforge. 846 8472005-04-24 21:25 Eric McDonald <eric_mcdonald@users.sourceforge.net> 848 849 Fix some memory leaks in Tkconq. 850 (These would also be GDI resource leaks under Windows.) 851 * tkimf.c (tk_make_color_pixmap): Free temp bitmap after it is 852 blitted to pixmap. 853 (tk_make_mono_pixmap): Likewise. 854 (tk_make_mask_pixmap): Likewise. 855 8562005-04-24 18:23 Eric McDonald <eric_mcdonald@users.sourceforge.net> 857 858 Fix occs-in-dead-transport bug. (Reported by Elijah.) 859 * unit.c (kill_unit_aux): When recursing through occs, be sure to 860 make occs leave the world (and therefore their transports as well). 861 862 Fix combat reporting. 863 * combat.c (maybe_hit_unit): Do not reckon damage prematurely. 864 Caller will also reckon damage on attacker/defender. 865 (reckon_damage): If there was a possibility of detonations, 866 the reckon damage around the potential detonator. 867 8682005-04-24 16:47 Eric McDonald <eric_mcdonald@users.sourceforge.net> 869 870 Add beautiful new terrain images. (Thanks Elijah.) 871 * images/isoph32x32.gif: New file. 872 * images/isoph44x48.gif: New file. 873 874 Updates to Starfleet Battles and Opal. (From Elijah.) 875 * lib/battles.g: Update. 876 * lib/opal-rules.g: Update. 877 8782005-04-24 16:27 Eric McDonald <eric_mcdonald@users.sourceforge.net> 879 880 Add new armor images. (Thanks Elijah.) 881 * lib/dg_armor32.imf: New file. 882 * images/dg_armor32.gif: New file, including some nice shields. 883 8842005-04-23 21:14 Eric McDonald <eric_mcdonald@users.sourceforge.net> 885 886 Shuffle around some configure-related files. 887 * config.sub: Update and move to 'pkg' directory. 888 * config.guess: Likewise. 889 * install: Move to 'pkg' directory. 890 * install.sh: Likewise. 891 * pkg/config.sub: Move from top-level directory. 892 * pkg/config.guess: Likewise. 893 * pkg/install: Likewise. 894 * pkg/install.sh: Likewise. 895 * configure.in: Tell 'configure' to find aux files in 'pkg' dir. 896 * configure: Regenerated. 897 8982005-04-23 04:34 Eric McDonald <eric_mcdonald@users.sourceforge.net> 899 900 Fix some detonation bugs. 901 (Reported by Elijah Meeks.) 902 * combat.c (maybe_hit_unit): Call 'reckon_damage_around' to make 903 sure damage is applied after a detonation-with-attack occurs. 904 (reckon_damage_here): Do special iteration through ustack that 905 avoids stopping short if current unit is pulled out from 906 beneath iterator. 907 (detonate_unit): Make sure that unit or terrain is actually 908 within detonation range by checking appropriate table. It is 909 erroneous to rely on the max range as check. 910 (detonate_on_cell): Limit terrain damage to cells that are 911 actually within range according to their terrain, not according to 912 max detonation range over any terrain. 913 9142005-04-22 16:24 Eric McDonald <eric_mcdonald@users.sourceforge.net> 915 916 Some experimental AI improvements. 917 Some proven-to-be-good AI improvements. 918 * ai.c (run_local_ai): Handle operational roles. 919 (assign_to_offense): Be more aggressive in finding targets and 920 less aggressive in assigning general goals. 921 * aioprt.h: Rename some functions and data structures. 922 * aioprt.cc: Rename some functions and data structures. 923 (evaluate_shuttle_oprole): Start writing code for evaluating a 924 shuttle operational role. 925 * mplayer.c (mplayer_decide_plan): Honor any existing oproles 926 rather than deciding a new plan. Tweak exploration chances. 927 * plan.c: Remove use of 'real_operating_range_best' as a restriction 928 on the range of the victim finder in most places. 929 * task.c (do_approach_subtask): If failure to find shortest path, 930 then try finding other paths. 931 (choose_move_direction): Likewise. 932 * unit.c (real_operating_range_best): Fix bug that would allow 933 immobile transports to be considered in range calcs. 934 9352005-04-17 16:32 Eric McDonald <eric_mcdonald@users.sourceforge.net> 936 937 Continue laying foundation for more AI improvements. 938 * aioprt.h: New header file. Dedicated to operational roles and 939 decisions. 940 * aioprt.cc: New implementation file. Dedicated to operational 941 roles and decisions. 942 * kernel/Makefile.in: Add support for new files. 943 * side.h (struct a_side): Add slot for new master AI struct. 944 * ai.c: Include 'aiscore.h' and 'aioprt.h'. 945 * mplayer.c: Include 'aioprt.h'. 946 (mplayer_init): Create an instance of the new master AI struct, 947 and bind it to the side. 948 (determine_subgoals): Bind the list of scorekeeper analyses to 949 the master AI struct. 950 9512005-04-16 16:17 Eric McDonald <eric_mcdonald@users.sourceforge.net> 952 953 Fix bug in auto-upgrade of units. 954 (Reported by Elijah Meeks.) 955 * unit.h (could_auto_upgrade_to): Swap 'u' and 'u2'. 956 9572005-04-13 00:55 Eric McDonald <eric_mcdonald@users.sourceforge.net> 958 959 More treasury-checking functions. 960 * conq.h (could_take_from_treasury): New prototype. 961 (could_take_from_treasury): Likewise. 962 (could_take_directly_from_treasury): Likewise. 963 (could_take_directly_from_treasury): Likewise. 964 (could_give_to_treasury): Likewise. 965 (could_give_to_treasury): Likewise. 966 (could_give_directly_to_treasury): Likewise. 967 (could_give_directly_to_treasury): Likewise. 968 * actions.c (could_take_from_treasury): New function. 969 Could u take m from treasury, assuming side has treasury? 970 (could_take_from_treasury): New function. 971 Could u on a given side take m from treasury? 972 (could_take_direclty_from_treasury): New function. 973 Could u take m directly from treasury, assuming side has treasury? 974 (could_take_directly_from_treasury): New function. 975 Could u on a given side take m directly from treasury? 976 (could_give_to_treasury): New function. 977 Could u give m to treasury, assuming side has treasury? 978 (could_give_to_treasury): New function. 979 Could u on a given side give m to treasury? 980 (could_give_directly_to_treasury): New function. 981 Could u give m directly to treasury, assuming side has treasury? 982 (could_give_directly_to_treasury): New function. 983 Could u on a given side give m directly to treasury? 984 985 Many AI tweaks, plus foundation for further enhancements. 986 * table.def (uu_ai_base_worth_for): New table, 'ai-base-worth-for'. 987 * utype.def (u_ai_base_worth): New uprop, 'ai-base-worth'. 988 * game.h (could_be_on): Delete function macro. 989 (could_be_on): New prototype. 990 (tmp_u2_array): New global variable. 991 (tmp_uu_array): Likewise. 992 * ai.c (need_explorers): Make exploration a little bit less 993 aggressive, when we have made contact with enough enemies. 994 (ai_init_shared): Call 'maybe_set_base_worths_for' and 995 'maybe_set_base_worths'. 996 (exploring_worth): Remove some code from the ideffed out function. 997 * aiunit.h (can_be_on): New prototype. 998 (can_be_on_known): Likewise. 999 (longest_economic_input): Likewise. 1000 (longest_economic_input): Likewise. 1001 (longest_economic_input): Likewise. 1002 (productivity_on_known): Likewise. 1003 (can_survive_on_known): Likewise. 1004 (can_survive_on_known): Likewise. 1005 * aiunit.cc (can_be_on): New function. Can u on a given side be on 1006 a given cell? 1007 (can_be_on_known): New function. Can u on a given side be on a 1008 given known cell? 1009 (longest_economic_input): New function. Longest direct economic 1010 input for a material from u2 to u. 1011 (longest_economic_input): New function. Longest direct economic 1012 input from u2 to u. 1013 (longest_economic_input): New function. Longest direct economic 1014 input from any utype to u. 1015 (productivity_on_known): New function. Materials productivity 1016 on given known cell for given utype and side. 1017 (can_survive_on_known): New function. Can u on a given side 1018 survive on a given known cell? 1019 (can_survive_on_known): New function. Can a given unit survive 1020 a given known cell? 1021 * aiunit2.h (cv__acp_max_wo_effects): New extern variable declaration 1022 in namespace 'Xconq'. 1023 (cv__acp_per_turn_max_wo_effects): Likewise. 1024 (acp_max_wo_effects): New prototype. 1025 (acp_per_turn_max_wo_effects): New prototype. 1026 (cv__speed_max_wo_effects): New extern variable declaration in 1027 namespace 'Xconq'. 1028 (mp_per_turn_max): New prototype. 1029 (cv__moves_per_turn_max_on_t): New extern variable declaration in 1030 namespace 'Xconq'. 1031 (moves_per_turn_max): New prototype. 1032 (cv__move_range_max_on_t_with_m): New extern variable declaration 1033 in namespace 'Xconq'. 1034 (cv__move_range_max_on_t): Likewise. 1035 (move_range_max_on): New prototype. 1036 (move_range_max): Likewise. 1037 (move_range_best): Likewise. 1038 (move_range_worst): Likewise. 1039 (producer_worth_on_known): Likewise. 1040 (base_worth_for): Likewise. 1041 (set_base_worth_for): Likewise. 1042 (maybe_set_base_worths_for): Likewise. 1043 (base_worth): Likewise. 1044 (set_base_worth): Likewise. 1045 (maybe_set_base_worths): Likewise. 1046 * combat.c: Various checks to make sure that the units we are 1047 dealing with are valid. 1048 * aiunit2.cc (cv__acp_max_wo_effects): New global variable in 1049 namespace 'Xconq'. Cache for maximum ACP of utypes without 1050 enhancing effects. 1051 (cv__acp_per_turn_max_wo_effects): New global variable in 1052 namespace 'Xconq'. Cache for maximum ACP per turn of utypes 1053 without enhancing effects. 1054 (acp_max_wo_effects): New function. Maximum ACP u can have without 1055 enhancing effects. 1056 (acp_per_turn_max_wo_effects): New function. Maximum ACP per turn u 1057 can have without enhancing effects. 1058 (cv__speed_max_wo_effects): New global variable in namespace 1059 'Xconq'. Cache for maximum speed of utypes without enhancing effects. 1060 (speed_max_wo_effects): New function. Maximum speed u can have 1061 without enhancing effects. 1062 (cv__mp_per_turn_max): New global variable in namespace 'Xconq'. 1063 Cache for maximum MP per turn of utypes. 1064 (mp_per_turn_max): New function. Maximum MP u can get per turn. 1065 (cv__moves_per_turn_max_on_t): New global variable in namespace 1066 'Xconq'. Cache of maximum moves utypes can make per turn on t. 1067 (moves_per_turn_max): New function. Maximum moves u can make per 1068 turn on t. 1069 (cv__move_range_max_on_t_with_m): New global variable in 1070 namespace 'Xconq'. Cache of max movement range of u if producing m 1071 on t. 1072 (cv__move_range_max_on_t): New global variable in namespace 'Xconq'. 1073 Cache of max movement range of u on t. 1074 (move_range_max_on): New function. Max movement range of u if 1075 producing m on t, and given an amount of m. 1076 (move_range_max): New function. Max movement range of u on t, and 1077 given amounts of mtypes. 1078 (move_range_best): New function. Best movement range of u, given 1079 amounts of mtypes. 1080 (move_range_worst): New function. Worst movement range of u, given 1081 amounts of mtypes. 1082 (producer_worth_on): New function. Given unit's worth as a producer 1083 on a given known cell. 1084 (base_worth_for): New function. Basic worth as a base for u2. 1085 (set_base_worth_for): New function. Set basic worth as a base for u2. 1086 (maybe_set_base_worths_for): New function. Set basic worths as 1087 bases for utypes, if necessary. 1088 (base_worth): New function. Basic worth as a base. 1089 (set_base_worth): New function. Set basic worth as a base. 1090 (maybe_set_base_worths): New function. Set basic worths as bases, 1091 if necessary. 1092 * generic.c (tmp_u2_array): Declare new global variable. 1093 (tmp_uu_array): Declare new global variable. 1094 (disallow_more_unit_types): Allocate space for 'tmp_u2_array', 1095 and 'tmp_uu_array'. 1096 * mplayer.c (mplayer_decide_plan): Try to help transports stay on 1097 task with what occs have in mind. Gather some useful info from the 1098 theater where the unit is located, if there is a theater. Weight 1099 explorer assignments by amount of unexplored cells in theater. 1100 Don't assign occs of mobile transports to defense plans. 1101 (mplayer_adjust_plan): Remove ifdeffed out code. 1102 (mplayer_react_to_task_result): Have units hail transports, 1103 even if they are on an exploratory plan. 1104 (mplayer_finish_movement): Search for a transport even if a 1105 hit-unit task is not in the queue. 1106 * plan.c (plan_offense): Be more aggressive about fishing for 1107 targets, even if we are in pursuit of a goal. 1108 (ai_score_potential_victim): Add in potential victim's worth as 1109 a supporter of various plans. 1110 * task.c (do_approach_subtask): Try to help occs stay on 1111 transport. 1112 (do_sentry_task): If next task is to occupy, but we already 1113 occupy the unit we are supposed to, then cancel the sentry task 1114 so that we will be more alert. 1115 * unit.c (could_be_on): New function. Could u be on t? 1116 (real_operating_range_best): If on mobile transport, then use 1117 mobile transport's operating range. Also, account for productivity 1118 of an adjacent cell. 1119 1120 Fix bug in my earlier bugfix in the economy code. 1121 * economy.c (try_sharing_need): If to-unit is occ of from-unit, 1122 then share, even if in-length is -1. 1123 (try_transfer_aux): Likewise. 1124 11252005-04-09 16:41 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1126 1127 Merge in CVS trunk between 'BPT_EMCDONALD_AI_8' and 1128 'BPT_EMCDONALD_AI_9'. 1129 11302005-04-04 02:17 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1131 1132 Fix crashing bug in unit creation code. 1133 * actions.c (do_create_in_action): Only assign the creation ID 1134 to a task arg, if a task exists. 1135 1136 Various and sundry AI improvements. 1137 * utype.def (u_ai_prod_enhancer_worth): New definition, 1138 'ai-prod-enhancer-worth'. 1139 (u_ai_producer_worth): New defintion, 'ai-producer-worth'. 1140 * ai.c (ai_go_after_victim): Clip victim-seeking range to 1141 available fuel. This is intended to help reduce units from 1142 running out of fuel. Also, if unit is on a transport, then 1143 only go after a victim that is in striking range. 1144 (ai_init_shared): Call 'maybe_set_producer_worths' and 1145 'maybe_set_prod_enhancer_worths'. 1146 * aiunit.h (could_be_occupant): New prototype. 1147 (can_refuel): New prototype. 1148 * aiunit.cc (could_be_occupant): New function. Could u be an 1149 occupant of any utypes? 1150 (can_refuel): New function. Can a given unit refuel another 1151 given unit with a given fuel? 1152 * aiunit.h (producer_worth): New prototype. 1153 (set_producer_worth): New prototype. 1154 (maybe_set_producer_worths): New prototype. 1155 (prod_enhancer_worth): New prototype. 1156 (set_prod_enhancer_worth): New prototype. 1157 (maybe_set_prod_enhancer_worth): New prototype. 1158 * aiunit2.cc (producer_worth): New function. Basic worth as a 1159 producer. 1160 (set_producer_worth): New function. Set basic worth as a producer. 1161 (maybe_set_producer_worths): New function. Set basic worths as 1162 producers, if necessary. 1163 (prod_enhancer_worth): New function. Basic worth as a 1164 production enhancer. 1165 (set_prod_enhancer_worth): New function. Set basic worth as a 1166 production enhancer. 1167 (maybe_set_prod_enhancer_worths): New function. Set basic worths as 1168 production enhancers, if necessary. 1169 * mplayer.c (mplayer_decide_plan): Make sure that chances in the 1170 chance slots are cumulative and do not clobber one another. Add 1171 support for boosting the chance of taking an improvement plan on 1172 account of being able to build production enhancers. 1173 (search_for_available_transport): If unit is already on a transport, 1174 then don't bother looking for another; this reduces unnecssary 1175 transport-hopping. If transport is moving away from unit and appears 1176 to be already dropping off one or more of its occs, then do not 1177 hijack it. If transport is full, then do not attempt to hijack it. 1178 * plan.c (plan_offense): Do not tell transport where to go, if unit 1179 is on transport. The transport will decide later on, possibly taking 1180 into account the unit's desires. Clip victim-seeking range to the 1181 operating range. 1182 (do_for_occupants): If the transport is not AI-controlled, then 1183 don't mess with what its doing (or not doing); that is up to the 1184 non-AI player to decide. Make sure transport is mobile, before 1185 trying to alter its tasks. 1186 (plan_defense): Early on, check to see of occs want us to do 1187 anything. Clip victim-seeking range to the operating range. 1188 (plan_improve): Prevent negative values from entering the 1189 lottery. Add support for improvement by building production enhancers 1190 for self. 1191 (plan_exploration): Rearm if ammo is low. Listen to what occs 1192 want to do. 1193 (ai_score_potential_victim): Penalize the score if the uview is 1194 old in a non-see-all world and with a non-see-always unit. 1195 (ai_victim_here): Disregard units which cannot be reached and 1196 which can outrun us. 1197 * task.c (do_move_to_task): Insert some ifdeffed out experimental 1198 code. Code still needs refinement to prevent heavy buzzing. Intent 1199 is to help ensure that AI-controlled units are not deliberately 1200 running out of fuel. 1201 * unit.c (real_operating_range_best): Clip operating range if it 1202 appears that unit is operating from a mobile transport. Intent is 1203 to help ensure that AI-controlled units are not deliberately 1204 running out of fuel. 1205 12062005-04-02 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1207 1208 Fix crashing bug in explorer worths. 1209 (Reported by Elijah.) 1210 * aiunit2.cc (explorer_worth): Do not call 'maybe_set_*' 1211 functions as they may have set values that mimic the default 1212 value, and thus force recalculation of entries in the temp 1213 utypes array. 1214 1215 Update for Opal Rules game. (From Elijah.) 1216 * opal-rules.g: Various changes. 1217 12182005-04-01 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1219 1220 Merge in CVS trunk between 'BPT_EMCDONALD_AI_5' and 1221 'BPT_EMCDONALD_AI_6'. 1222 1223 Fix (?) crashing bug in improvement plan. 1224 * plan.c (plan_improve): Make sure that totalchance is set to 0 1225 before summing. 1226 12272005-03-31 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1228 1229 New functions for handling materials checking and consumption for 1230 any actions. 1231 Add support for tech restrictions and materials consumption 1232 associated with the change-type action. 1233 * table.def (um_consumption_per_change_type): New TableUM. 1234 Consumption to change type from u to any other utype. 1235 * utype.def (u_tech_to_change_type_to): New uprop. Tech needed to 1236 change type to u. 1237 * conq.h (can_meet_materials_requirement): New prototype. 1238 (consume_materials): Likewise. 1239 * actions.c (can_meet_materials_requirement): New function. 1240 Takes an actor unit, agent unit, and TableUM getter function, 1241 and evaluates whether the agent's supply, and possibly the actor's 1242 side's treasury, and checks if they can satisfy the materials 1243 requirements returned by the getter function. 1244 (consume_materials): New function. Possibly consumes an agent's 1245 supply, actor's side's treasury, or both, based on what the 1246 getter for a consumption (or any, actually) TableUM returns. Also, 1247 has support for getters that return negative consumption (production). 1248 (can_change_type_to): Check to make sure that tech requirements 1249 are met. 1250 (can_change_type_to): Check to make sure consumption requirements 1251 are met. 1252 (notify_tech): Add notification for when 'tech-to-change-type-to' 1253 is met. 1254 * help.c (describe_utype): Add descritpion of tech needed to change 1255 type into utype being described. 1256 * unit.c (change_unit_type): Call 'consume_materials' to handle 1257 materials consumption. 1258 12592005-03-29 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1260 1261 Various and sundry improvements to the AI. 1262 Specific focus on enabling AI use of manual change-type. 1263 Also, allow ACP-less manual change-type. 1264 * conq.h (can_change_type_to): New prototype. 1265 (can_change_type_to): Likewise. 1266 * actions.c (can_change_type_to): New function. Can u on a given 1267 side change type to u2? 1268 (can_change_type_to): New function. Can given unit change into 1269 given utype? 1270 (check_change_type_action): Call 'can_change_type_to'. 1271 * ai.h (assign_to_improve): Move function out of ifdeffed out 1272 section. 1273 * ai.c (assign_to_improve): Fix prototype. As a hack, give an 1274 improving unit a maingoal of 'GOAL_COLONIZE', until we can 1275 disentangle the materials collection stuff out of it. 1276 * mplayer.c (mplayer_decide_plan): Get rid of ifdeffed out 1277 section. The Time game does not need it. Fix defensive support 1278 case in plan lottery. Add a new lottery slot for 'PLAN_IMPROVEMENT'. 1279 Fill in slot with a fixed chance (for now), if an unit can 1280 change type. 1281 (mplayer_adjust_plan): Put in crude hack with 'GOAL_COLONIZE' 1282 to prevent improvement plan from being clobbered, and causing an 1283 infinite loop between decide/assign and adjust/clobber. 1284 * plan.c (plan_passive): If unit is AI-controlled, go ahead and 1285 execute tasks assigned to it. What can it hurt? If no tasks 1286 assigned to AI-controlled unit, then force replan as before. 1287 (plan_colonize): Check if colonizer is trying to reach an 1288 unreachable spot. If so, then don't let it set a move-to and 1289 build task combo. 1290 (plan_improve): Remove ifdeffed out stuff. Write anew. Handle 1291 case where a change-type can be immediately performed. (Still 1292 need to handle preparation for change-type.) 1293 (ai_score_potential_victim): Simplify. Use basic ratings instead 1294 of doing some calculation that partially mimics them. Bring back 1295 the notion of a potential target's popularity; I don't know why 1296 Hans was so insistent on having everyone go after the same target; 1297 it makes things WORSE. Ifdef out damage ratio stuff. 1298 * side.c (choose_side_research_goal_from_weighted_list): Return 1299 lispnil instead of warning when weights sum to zero. 1300 * unit.h (could_auto_upgrade_to): New macro. 1301 * unit.c (can_change_type): Iterate over utypes, calling 1302 'can_change_type_to' for each one. 1303 (could_change_type_to): Remove ACP > 0 constraint. 1304 1305 Update games lib to account for the allowance of ACP-less 1306 manual change-type. 1307 * advances.g: Add 'can-change-type-to' table. 1308 * space-civ.g: Likewise. 1309 13102005-03-28 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1311 1312 Various and sundry improvements to the AI. 1313 * conq.h (should_play_movies): New prototype. 1314 * actions.c (should_play_movies): New function. Determine if all 1315 sides are either playerless or have an AI. If so, then request that 1316 movies/animations not be played. This speeds up AI-testing quite 1317 a bit. 1318 (play_action_movies): Test 'should_play_movies' before 1319 proceeding. 1320 * ai.c (ai_pick_side_research_goal): Fix bug that caused a 1321 weighted list of possible new advances to be one less than it 1322 should have been. 1323 (probably_explorable): Return FALSE if the cell in question is 1324 already seen. Fix bug: check each neighboring cell instead of 1325 same cell 6 times. 1326 (ai_init_shared): Properly calculate colonization, exploration, 1327 offensive, and defensive support worths. Normalize basic attack, 1328 fire, capture, and transport worths to their respective maxima 1329 on 10000 scale. 1330 (offensive_worth): Improve calc. Consider detonation damage. 1331 (basic_hit_worth): Improve calc. Consider estimated number of 1332 attacks per turn. 1333 (basic_fire_worth): Improve calc. Consider estiamted number of 1334 firings per turn. 1335 * aiunit.cc (could_colonize): Return boolean instead of 1336 ActionResult. 1337 * plan.c (plan_offense_support): Properly decide which new utypes 1338 can be constructed. 1339 (plan_defense): Likewise. 1340 (plan_explorer_support): Likewise. 1341 (plan_colonize_support): Choose support in manner similar to 1342 other plan support functions. 1343 (plan_colonize): Determine whether to invoke colonizer support 1344 early on. Proactively seek out new places to colonize instead of 1345 random walking. Also try exploring, if necessary. 1346 (plan_exploration): If explorer can also colonize, then keep an 1347 eye out for colonization opportunities. 1348 * tkmain.c (play_movies): Check 'should_play_movies' before 1349 proceeding. 1350 1351 Improve the Advances game. 1352 * advances.g: Revise the AI research hints. Make Swordmen able to 1353 be constructed once Bronze has been researched, rather than 1354 Military. 1355 13562005-03-27 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1357 1358 Various and sundry improvements to the AI. 1359 * utype.def (u_ai_depot_worth): New definition. 1360 (u_ai_distributor_worth): New definition. 1361 * ai.h (add_goal): Transplant prototype from 'mplayer.c'. 1362 (has_goal): Likewise. 1363 (has_unsatisfied_goal): Likewise. 1364 * ai.c (add_goal): Transplant function from 'mplayer.c'. 1365 (has_goal): Likewise. 1366 (has_unsatisfied_goal): Likewise. 1367 (build_base_for_self): Delete ifdeffed out function. 1368 (ai_init_shared): Call 'maybe_set_depot_worths' and 1369 'maybe_set_distributor_worths'. 1370 * aiunit2.h (depot_worth): New prototype. 1371 (set_depot_worth): Likewise. 1372 (maybe_set_depot_worths): Likewise. 1373 (distributor_worth): Likewise. 1374 (set_distributor_worth): Likewise. 1375 (maybe_set_distributor_worths): Likewise. 1376 * aiunit2.cc (depot_worth): New function. Basic worth as a depot. 1377 (set_depot_worth): New function. Set basic worth as a depot. 1378 (maybe_set_depot_worths): New function. Set basic worths as depots, 1379 if necessary. 1380 (distributor_worth): New function. Basic worth as a distributor. 1381 (set_distributor_worth): New function. Set basic worth as a 1382 distributor. 1383 (maybe_set_distributor_worths): New function. Set basic worths 1384 as distributors, if necessary. 1385 * mplayer.c (add_goal): Transplant function to 'ai.c'. 1386 (has_goal): Likewise. 1387 (has_unsatisifed_goal): Likewise. 1388 (mplayer_adjust_plan): Don't try handling support tasks here. This 1389 is done in the plans (for now). 1390 * plan.c (maybe_set_materials_goal): New function. Set a side goal 1391 to acquire materials if it looks like a certain construction task 1392 may need them to complete. 1393 (plan_offense_support, plan_defense, plan_explorer_support): 1394 Only skip construction of naval utypes when they are not air utypes. 1395 Call 'maybe_set_materials_goal' whenever a new construction is 1396 assigned. 1397 (plan_explorer_support): Delete ifdeffed out code. 1398 1399 Fix bug in backdrop model 0 scarce materials distribution. 1400 (This appears to largely fix the problem with Fighters crashing 1401 in the Default game.) 1402 * economy.c (try_transfer_aux): Make sure that we are not trying 1403 to transfer from an unit with an out-length of -1 for the given 1404 material. 1405 (try_sharing_need): Ditto. 1406 14072005-03-26 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1408 1409 Various and sundry improvements to the AI. 1410 * kernel/Makefile.in: Incorporate 'aiunit2.h' and 'aiunit2.cc' 1411 into the build process. 1412 * aiunit2.h: New header for AI utype/unit worth functions. 1413 * aiunit2.cc: New implementation for AI utype/unit worth functions. 1414 * conq.h (could_move): New prototype. 1415 * utype.def (u_explorer_worth): Delete definition. 1416 (u_ai_explorer_worth): New definition. 1417 (u_ai_seer_worth): Likewise. 1418 * ai.h (build_depot_for_self): Change prototype. 1419 (suitable_port): Transplant prototype from 'ai.c'. 1420 (need_more_transportation): Likewise. 1421 (need_explorers): Transplant prototype from 'mplayer.c'. 1422 * ai.c: Include 'aiunit2.h'. 1423 (set_u_explorer_worth): Delete function. 1424 (need_more_transportation): Remove staticness. 1425 (suitable_port): Remove staticness. 1426 (need_explorers): Transplant from 'mplayer.c'. 1427 (build_depot_for_self): Use 'can_construct' test instead of 1428 some custom one. Change prototype. 1429 (ai_init_shared): Call 'maybe_set_mover_worths', 1430 'maybe_set_seer_worths', and 'maybe_set_explorer_worths'. Remove 1431 support for setting 'u_explorer_worth'. 1432 * aiunit.h (could_see): New prototype. 1433 * aiunit.cc (could_see): New function. 1434 * iplayer.c (iplayer_decide_plan): Use 'u_ai_explorer_worth' instead 1435 of 'u_explorer_worth'. 1436 (iplayer_react_to_task_result): Alter arguments to call to 1437 'build_depot_for_self'. 1438 * move.c (could_move): New function. Could uactor move umover? 1439 (can_move): Use 'could_move' function. 1440 * mplayer.c (mplayer_decide_plan): Use 'u_ai_explorer_worth' instead 1441 of 'u_explorer_worth'. Remove ifdeffed out code. 1442 (need_explorers): Transplant to 'ai.c'. 1443 * plan.c (self_build_base_for_self): Delete function. 1444 (plan_offense): Immediately try offensive support, if no pending 1445 tasks to run. Remove code to switch to exploration and to build 1446 bases. (We will handle this in other places and in other ways.) 1447 (plan_offense_support): Run an improved lottery to determine 1448 utype to construct. 1449 (plan_defense): Immediately try defensive support, if no pending 1450 tasks to run. Use a lottery similar to offensive support to 1451 determine utype to construct. Remove code to switch to exploration 1452 and to build bases. 1453 (plan_colonization_support): Use 'can_construct' instead of 1454 'unit_can_build_type'. 1455 (plan_exploration): Immediately try exploration support, if no 1456 pending tasks to run. Get rid of code that allowed the plan to 1457 become distracted offensively. Knock out goals that are not 1458 related to exploration. Remove ifdeffed out code. 1459 (plan_explorer_support): Run an improved lottery to determine 1460 utype to construct. 1461 (should_capture_maker): Delete ifdeffed out function. 1462 (no_possible_moves): Likewise. 1463 * run.c (auto_pick_new_build_task): Use 'u_ai_explorer_worth' 1464 instead of 'u_explorer_worth'. 1465 * table.def (uu_see_at): Swap description string with 'uu_see_adj'. 1466 * unit.c (can_build_explorers): Use 'u_ai_explorer_worth' instead 1467 of 'u_explorer_worth'. 1468 14692005-03-25 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1470 1471 Move some useful functions to a more common location. 1472 * game.h (table_default): New prototype. 1473 (uprop_i_default): Likewise. 1474 (uprop_s_default): Likewise. 1475 (uprop_l_default): Likewise. 1476 (tprop_i_default): Likewise. 1477 (tprop_s_default): Likewise. 1478 (tprop_l_default): Likewise. 1479 (mprop_i_default): Likewise. 1480 (mprop_s_default): Likewise. 1481 (mprop_l_default): Likewise. 1482 (aprop_i_default): Likewise. 1483 (aprop_s_default): Likewise. 1484 (aprop_l_default): Likewise. 1485 (gvar_i_default): Likewise. 1486 (gvar_s_default): Likewise. 1487 (gvar_l_default): Likewise. 1488 * generic.c (table_default): Transplant from 'help.c'. 1489 (uprop_i_default): Likewise. 1490 (uprop_s_default): Likewise. 1491 (uprop_l_default): Likewise. 1492 (tprop_i_default): Likewise. 1493 (tprop_s_default): Likewise. 1494 (tprop_l_default): Likewise. 1495 (mprop_i_default): New function. 1496 (mprop_s_default): Likewise. 1497 (mprop_l_default): Likewise. 1498 (aprop_i_default): Likewise. 1499 (aprop_s_default): Likewise. 1500 (aprop_l_default): Likewise. 1501 (gvar_i_default): Transplant from 'help.c'. 1502 (gvar_s_default): Likewise. 1503 (gvar_l_default): Likewise. 1504 * help.c (table_default): Transplant to 'generic.c'. 1505 (uprop_i_default): Likewise. 1506 (uprop_s_default): Likewise. 1507 (uprop_l_default): Likewise. 1508 (tprop_i_default): Likewise. 1509 (tprop_s_default): Likewise. 1510 (tprop_l_default): Likewise. 1511 (gvar_i_default): Likewise. 1512 (gvar_s_default): Likewise. 1513 (gvar_l_default): Likewise. 1514 1515 Start laying groundwork for new set of designer-specifiable 1516 AI worth functions. 1517 * utype.def (u_ai_mover_worth): New uprop, 'ai-mover-worth'. 1518 1519 Fix warning in Default and related games. 1520 * stdunit.g: Do not quote 'notes' lists. 1521 15222005-03-21 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1523 1524 Merge in CVS trunk between 'BPT_EMCDONALD_AI_1' and 1525 'BPT_EMCDONALD_AI_3'. 1526 1527 Add new unit analysis capabilities to AI. 1528 Implement a plan-decision lottery. (Still needs work.) 1529 Break out common, useful parts of kernel action-checking code. 1530 * kernel/Makefile.in: Add support for 'aiunit.h' and 'aiunit.cc'. 1531 * utype.def (u_offensive_support_worth): New uprop for AI, 'zz-osw'. 1532 (u_defensive_support_worth): New uprop for AI, 'zz-dsw'. 1533 (u_coloinzation_support_worth): New uprop for AI, 'zz-csw'. 1534 (u_exploration_support_worth): New uprop for AI, 'zz-esw'. 1535 * conq.h (can_act): New prototype. 1536 (can_move): Likewise. 1537 (can_create): Likewise. 1538 (can_build): Likewise. 1539 (could_fire_at_any): Likewise. 1540 (can_fire): Likewise. 1541 (can_fire_at): Likewise. 1542 (can_fire_at_any): Likewise. 1543 (could_attack): Likewise. 1544 (could_attack_any): Likewise. 1545 (can_attack): Likewise. 1546 (can_attack_any): Likewise. 1547 (could_hit): Likewise. 1548 (can_detonate): Likewise. 1549 (could_capture_any): Likewise. 1550 (can_capture): Likewise. 1551 (can_capture_directly): Delete prototype. 1552 (type_can_capture_directly): Likewise. 1553 * aiunit.h: New file. MANY new prototypes related to unit status 1554 and analysis. See file for details. 1555 * aiunit.cc: New file. MANY new functions related to unit status 1556 and analysis. See file for details. 1557 * actions.c (has_supply_to_act): New location in file. 1558 (can_act): New function. Checks if the actor and agent are both 1559 in play, and if they have enough materials to act. 1560 (can_create): New function. Can a given unit create an unit of 1561 the given type? 1562 (check_create_common): Use 'can_create' for part of checks. 1563 (can_build): New function. Can a given unit build an unit of 1564 a given type? 1565 (check_build_action): Use 'can_build' for part of checks. 1566 * ai.c: Include 'aiunit.h' for now; probably remove later. 1567 (set_u_colonization_support_worth): New setter function. 1568 (set_u_exploration_support_worth): Likewise. 1569 (set_u_offensive_support_worth): Likewise. 1570 (set_u_defensive_support_worth): Likewise. 1571 (offensive_reaction): Delete ifdeffed out code. 1572 (ai_go_after_victim): Change several calls to their new names. 1573 (ai_init_shared): Normalize the various worths on a +/-10000 scale. 1574 Set colonization, exploration, offensive, and defensive support 1575 worths. 1576 * aiutil.h (could_damage_by_attack): Delete prototype. 1577 (could_damage_by_fire): Likewise. 1578 (could_capture_any): Likewise. 1579 * aiutil.c (could_damage_by_attack): Delete function. 1580 (could_damage_by_fire): Likewise. 1581 (could_damage): Likewise. 1582 (could_capture_any): Likewise. 1583 * combat.c (capture_chance): Move to new location in file. 1584 (could_fire_at): New function. Could u fire at u2? 1585 (could_fire_at_any): New function. Could u fire at >= 1 utypes? 1586 (can_fire): New function. Can a given unit fire? 1587 (can_fire_at): New function. Can a given unit fire at a given utype? 1588 (can_fire_at_any): New function. Can a given unit fire at >= 1 1589 enemy utypes? 1590 (could_attack): New function. Could u hit u2 by attacks? 1591 (could_attack_any): New function. Could the given utype attack 1592 >= 1 utypes? 1593 (can_attack): New function. Can a given unit attack a given utype? 1594 (can_attack_any): New function. Can a given unit attack >= 1 1595 enemy utypes? 1596 (could_hit): New function. Could u hit u2 by attacks or fire? 1597 (can_detonate): New function. Can given unit detonate? 1598 (could_capture_by_fire): Revised function. Could u capture u2 by 1599 fire? 1600 (could_capture_by_attacks): Revised function. Could u capture u2 by 1601 attacks? 1602 (could_capture_by_capture): Revised function. Could u capture u2 by 1603 direct capture? 1604 (could_capture): Move to new location in file. 1605 (could_capture_any): New function. Could the given utype capture 1606 any utypes by any means? 1607 (can_capture): New function. Can a given unit capture a given utype 1608 on a given side? 1609 (check_attack_action): Call 'can_attack' for part of checks. 1610 (check_fire_at_action): Call 'can_fire_at' for part of checks. 1611 (check_fire_into_action): Call 'can_fire' for part of checks. 1612 (retreat_in_dir): Add ACP for rereating after movement check 1613 succeeds. 1614 (check_capture_action): Call 'can_capture' for part of checks. 1615 (check_detonate_action): Call 'can_detonate' for part of checks. 1616 (type_can_attack): Delete function. 1617 (type_can_fire): Likewise. 1618 (type_can_capture): Likewise. 1619 (can_capture_directly): Likewise. 1620 (type_can_capture_directly): Likewise. 1621 * help.c (describe_utype): Call functions by their new names. 1622 * move.c (can_move): New function. Can a given unit move? 1623 (check_move_action): Call 'can_move' for part of checks. Also, 1624 get rid of ACP-altering hack for retreating units. 1625 * mplayer.c: Include 'aiunit.h'. 1626 (enum AI_PL_ChanceSlots): New enum. Lottery slots for reserve and 1627 the various plans. 1628 (mplayer_decide_plan): Total rewrite. Implement plan lottery 1629 system. Relies heavily on the new functions in 'aiunit.cc'. 1630 * plan.c: Include 'aiunit.h' for now; perhaps on the longer term as 1631 well. 1632 (plan_offense): Delete ifdeffed out cruft. 1633 (plan_defense): Call functions by their new names. 1634 * task.c (do_hit_unit_task): Call functions by their new names. 1635 * tkinit.c (update_action_controls_info): Likewise. 1636 1637 Provide a normalization macro. 1638 * misc.h (normalize_on_pmscale): Normalize a number against a max 1639 on a +/- scale of a given range. 1640 1641 Fix bug with quoted encounter lists. 1642 * combat.c (model_1_attack): Unquote a quoted list. 1643 * civ2.g (encounter-result): Fix list. 1644 16452005-03-08 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1646 1647 Fix crashing bug in unit creation code. 1648 * actions.c (do_create_at_action): Only assign the new unit's ID 1649 to the first task's first arg, if the unit has a plan and tasks. 1650 1651 Remove another worthless side goal. 1652 * goal.def (GOAL_WORLD_KNOWN): Delete. 1653 * ai.c (goal_truth): Ifdef out test for 'GOAL_WORLD_KNOWN'. 1654 * mplayer.c (determine_subgoals): Do not create 'world-known' goal. 1655 Set 'positions-known' goal for 'indepside' rather than legacy NULL 1656 side. 1657 (mplayer_decide_plan): Remove check for 'GOAL_WORLD_KNOWN'. 1658 It is sufficient to check if any theaters need explorers. 1659 (need_explorers): If the side can see everything, or at least all 1660 terrain, then there is no need to explore. 1661 (plan_exploration): Comment out case relating to 'GOAL_WORLD_KNOWN'. 1662 The case handling 'GOAL_VICINITY_KNOWN' and 'GOAL_VICINITY_HELD' 1663 is sufficient. 1664 1665 * aiscore.h (for_all_ai_sk_analyses): New macro. Iterate over all 1666 scorekeeper analyses. 1667 16682005-03-07 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1669 1670 Remove some worthless side goals. 1671 * goal.def (GOAL_WON_GAME): Delete. 1672 (GOAL_LOST_GAME): Delete. 1673 * ai.c (goal_truth): Remove 'GOAL_WON_GAME' and 'GOAL_LOST_GAME' 1674 cases. 1675 * mplayer.c (analyze_the_game): Do not create a 'won-game' goal. 1676 16772005-03-06 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1678 1679 Hook scorekeeper analysis code into mplayer logic. 1680 Fix a couple of minor bugs. 1681 * ai.h (a_strategy): Remove 'sk_analyses' field. 1682 * aiscore.h: Do not include 'conq.h' and 'kernel.h'. Rely on 1683 implementation file to pull those in as is done elsewhere in 1684 Xconq. 1685 (enum AI_SKANKind): Add 'AI_SKAN_TESTOP'. (Note: We may just get 1686 rid of this, and the whole business of subclassing from 1687 'AI_SKANode' since it has not proved to be advantageous as it 1688 might have been.) 1689 (AI_SK_CHANGE_SCORE): New macro. Value for scorekeepers that 1690 just add or set a raw number for a score. 1691 (analyze_scorekeepers): New prototype. 1692 * aiscore.cc: Include 'conq.h' and 'kernel.h'. 1693 (AI_SKANode_UpropInt::merge_or_insert_into_list): Handle case 1694 where a node with an unique upropname is being merged into existing 1695 list. 1696 (analyze_sk_test): Handle recursing into sublists. Handle numbers 1697 as tests in certain contexts. 1698 (analyze_sk_action): Do not check if a symbol is bound or not 1699 when testing for keyowrds. It doesn't matter, since the keyword 1700 comes from the symbol's string. Some keywords, such as 'win', 'lose', 1701 and 'draw' are bound. 1702 (analyze_scorekeepers): New function. Runs analysis on all 1703 scorekeepers. 1704 * mplayer.c: Include 'aiscore.h'. 1705 (determine_subgoals): Ifdef out old scorekeeper analysis. Hook 1706 in new scorekeeper analysis. 1707 (analyze_sk_test): Finish cleaning out old draft 1 implementation. 1708 17092005-03-06 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1710 1711 Make AI scorekeeper analysis stuff compile and link. 1712 * kernel/Makefile.in: Hook in 'aiscore.o' and 'aiscore.h'. 1713 * aiscore.h: Include 'kernel.h' instead of 'ai.h'. 1714 (enum AI_SKANKind): Place ';' after definition. 1715 (AI_SKANode_UpropInt::destroy): Fix prototype. 1716 (AI_SKANode_UpropInt::destroy_all): Rename to 'destroy_list'. 1717 (AI_SKANode_TestOp::construct): Add missing parameter. 1718 (AI_SKANode_TestOp::destroy_all): Rename to 'destroy_list'. 1719 (AI_SKAnalysis::init): Fix typo in declaration. 1720 (AI_SKAnalysis::construct): Likewise. 1721 (AI_SKAnalysis::copy_to): Likewise. 1722 (AI_SKAnalysis::clone): Likewise. 1723 (AI_SKAnalysis::destroy): Likewise. 1724 (analyze_sk_action): Likewise. 1725 (analyze_scorekeeper): Likewise. 1726 * aiscore.cc (AI_SKANode_UpropInt::construct): Fix improper use of 1727 'sizeof'. 1728 (AI_SKANode_UpropInt::clone): Do not call constructor; allocate 1729 and init directly. 1730 (AI_SKANode_UpropInt::clone_list): Cast 'next' pointer to proper 1731 type. 1732 (AI_SKANode_UpropInt::destroy_list): Likewise. 1733 (AI_SKANode_UpropInt::merge_or_insert_into_list): Declare missing 1734 variable. Cast 'next' pointer to proper type. 1735 (AI_SKANode_TestOp::construct): Make parameter list match declared 1736 one. Fix improper use of 'sizeof'. 1737 (AI_SKANode_TestOp::clone): Do not call constructor; allocate 1738 and init directly. 1739 (AI_SKANode_TestOp::clone_list): Cast 'next' pointer to proper 1740 type. 1741 (AI_SKANode_TestOp::destroy_list): Likewise. 1742 (AI_SKAnalysis::construct): Fix improper use of 'sizeof'. 1743 (AI_SKAnalysis::clone): Return cloned node. 1744 (AI_SKAnalysis::destroy): Scope static methods from 1745 'AI_SKANode_UpropInt' not 'SKANode_UpropInt'. 1746 (AI_SKAnalysis::pop_test_op): Cast 'next' pointer to proper type. 1747 (AI_SKAnalysis::search_test_ops_for): Likewise. Declare missing 1748 'curop' variable. 1749 (analyze_sk_sum_uprop_test): Declare missing variables. Call 1750 methods with correct number of arguments. 1751 (analyze_sk_turn_test): Declare missing variable. 1752 (analyze_sk_score_test): Likewise. 1753 (analyze_sk_arith_op_test): Pop and destroy operators as two 1754 separate actions to prevent l-value problems with '&'. Call 1755 'analyze_*' functions rather than 'eval_*' functions. 1756 (analyze_sk_arith_comp_test): Likewise. 1757 (analyze_sk_bool_comp_test): Likewise. 1758 (analyze_sk_if_action): Delete unused, shadowed variable. Fix 1759 typo. Fix unclosed comments. 1760 17612005-03-06 Eric McDonald <eric_mcdonald@users.sourceforge.net> 1762 1763 Changelog for CVS branch: BRANCH_EMCDONALD_AI. 1764