From 1ea4ff0f267c1ac3161b0ae1efdec164f2e04755 Mon Sep 17 00:00:00 2001 From: Simon Forsyth Date: Sat, 12 Jan 2013 23:31:59 +0000 Subject: [PATCH] Add healer support micro AI to experimental multiplayer AI --- changelog | 1 + data/ai/ais/ai_generic-rush.cfg | 7 +++++++ data/ai/lua/generic-rush_engine.lua | 15 ++++++++++++++- players_changelog | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 397425aafa8..25ac914a8f5 100644 --- a/changelog +++ b/changelog @@ -11,6 +11,7 @@ Version 1.11.1+svn: * Fix bug when playing on maps with a turn limit * Fix bug handling regeneration * Minor improvements in switching between castles + * Add healer support micro AI to improve healer use * New [micro_ai] tag, 18 different Micro AIs, and 14 test scenarios * This includes AIs for 7 different animal behaviors, bottleneck defense, 2 different guardians and a coward, healer support, lurkers, diff --git a/data/ai/ais/ai_generic-rush.cfg b/data/ai/ais/ai_generic-rush.cfg index 5181f7cb72a..6a7d5f9cecc 100644 --- a/data/ai/ais/ai_generic-rush.cfg +++ b/data/ai/ais/ai_generic-rush.cfg @@ -54,5 +54,12 @@ evaluation="return (...):spread_poison_eval()" execution="(...):spread_poison_exec()" [/candidate_action] + [candidate_action] + engine=lua + name=move_to_enemy + max_score=95000 + evaluation="return (...):place_healers_eval()" + execution="(...):place_healers_exec()" + [/candidate_action] [/stage] [/ai] diff --git a/data/ai/lua/generic-rush_engine.lua b/data/ai/lua/generic-rush_engine.lua index 362d03957aa..01fd9d7cd11 100644 --- a/data/ai/lua/generic-rush_engine.lua +++ b/data/ai/lua/generic-rush_engine.lua @@ -9,6 +9,7 @@ return { local AH = wesnoth.require "ai/lua/ai_helper.lua" local BC = wesnoth.require "ai/lua/battle_calcs.lua" local LS = wesnoth.require "lua/location_set.lua" + local HS = wesnoth.require("ai/micro_ais/ais/mai_healer_support_engine.lua").init(ai) ------ Stats at beginning of turn ----------- @@ -69,7 +70,8 @@ return { formula = '($this_unit.moves = $this_unit.max_moves) and ($this_unit.hitpoints = $this_unit.max_hitpoints)' }[1] if not leader then - -- CA is irrelevant if no leader + -- CA is irrelevant if no leader or the leader may have moved from another CA + self.data.leader_target = nil AH.done_eval_messages(start_time, ca_name) return 0 end @@ -465,6 +467,17 @@ return { self.data.attack = nil end + generic_rush.healer_support_eval = HS.healer_support_eval + + function generic_rush:place_healers_eval() + if generic_rush:healer_support_eval() > 0 then + return 95000 + end + return 0 + end + + generic_rush.place_healers_exec = HS.healer_support_exec + return generic_rush end } diff --git a/players_changelog b/players_changelog index 83403174e92..71682ffe42f 100644 --- a/players_changelog +++ b/players_changelog @@ -15,6 +15,7 @@ Version 1.11.1+svn: * Fix bug when playing on maps with a turn limit. * Fix bug handling regeneration. * Minor improvements in switching between castles. + * Add healer support micro AI to improve healer use. * New [micro_ai] tag, 18 different Micro AIs, and 14 test scenarios * This includes AIs for 7 different animal behaviors, bottleneck defense, 2 different guardians and a coward, healer support, lurkers,