From fcf6ba4f7962f893e44aa9f3c515a64efd0c0232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 17 Nov 2023 17:00:30 +0100 Subject: FLNBotRules : fix attack_priority --- lib/colonial_twilight/fln_bot_rules.rb | 8 ++++---- spec/fln_bot_rules_spec.rb | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb index 8f0f37a..30fe9ec 100644 --- a/lib/colonial_twilight/fln_bot_rules.rb +++ b/lib/colonial_twilight/fln_bot_rules.rb @@ -230,7 +230,7 @@ module ColonialTwilight def may_ambush_1_in?(space) # do not expose a base r = may_ambush_in?(space) && (space.fln_bases.zero? ? true : space.guerrillas > 1) - dbg " may_attack_1_in : #{space.name}", r + dbg " may_ambush_1_in : #{space.name}", r r end @@ -242,9 +242,9 @@ module ColonialTwilight end def attack_priority(spaces) - # GOV bases -> French Troops -> French Police -> most pieces - f = _filter(spaces) { |s| s.gov_bases.positive? } - f = _filter(f) { |s| s.french_troops.positive? } + # remove priority GOV bases -> French Troops -> French Police -> most pieces + f = _filter(spaces) { |s| s.gov_bases.positive? && s.troops.zero? && s.police.zero? } + f = _filter(f) { |s| s.french_troops.positive? && s.police.zero? } f = _filter(f) { |s| s.french_police.positive? } _max(f, :gov) end diff --git a/spec/fln_bot_rules_spec.rb b/spec/fln_bot_rules_spec.rb index 6140f68..981e46c 100644 --- a/spec/fln_bot_rules_spec.rb +++ b/spec/fln_bot_rules_spec.rb @@ -721,16 +721,16 @@ describe ColonialTwilight::FLNBotRules do end it 'attack priority french troops' do - a = Sector.new(gov_bases: 2) - b = Sector.new(gov_bases: 2, french_troops: 2) - c = Sector.new(gov_bases: 2, french_troops: 1) + a = Sector.new(gov_bases: 2, algerian_troops: 6) + b = Sector.new(gov_bases: 3, french_troops: 2) + c = Sector.new(gov_bases: 3, french_troops: 1) expect(@rules.attack_priority([a, b, c])[0]).to be b end it 'attack priority french police' do - a = Sector.new(gov_bases: 2, french_troops: 2) + a = Sector.new(gov_bases: 1, french_troops: 3, algerian_police: 6) b = Sector.new(gov_bases: 2, french_troops: 2, french_police: 2) - c = Sector.new(gov_bases: 2, french_troops: 2, french_police: 1) + c = Sector.new(gov_bases: 3, french_troops: 1, french_police: 1) expect(@rules.attack_priority([a, b, c])[0]).to be b end @@ -747,6 +747,13 @@ describe ColonialTwilight::FLNBotRules do c = Sector.new(gov_bases: 2, french_troops: 2, french_police: 2) expect(@rules.attack_priority([a, b, c])[0]).to be b end + + it 'attack priority gov most pieces, french police' do + a = Sector.new(gov_bases: 2, french_troops: 2, french_police: 2) + b = Sector.new(gov_bases: 2, french_troops: 2, french_police: 3) + c = Sector.new(gov_bases: 2, french_troops: 2, french_police: 2) + expect(@rules.attack_priority([a, b, c])[0]).to be b + end end describe '8.1.2 Procedure Guidelines' do -- cgit v1.1-2-g2b99