summaryrefslogtreecommitdiffstats
path: root/lib/colonial_twilight
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2023-10-24 09:32:52 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2023-10-24 09:32:52 +0200
commit4a3f2e4adce52e7a3495f0a825fe2f502e052006 (patch)
tree466b94034eb6d84dd76c7eaea2178570ebf746fd /lib/colonial_twilight
parentab2b97fc77b8b52c8b9a402b59dbf4454516b64f (diff)
downloadcolonial-twilight-4a3f2e4adce52e7a3495f0a825fe2f502e052006.zip
colonial-twilight-4a3f2e4adce52e7a3495f0a825fe2f502e052006.tar.gz
FLNBotRules : add #available_fln_bases, comment, fix Mock#terror
Diffstat (limited to 'lib/colonial_twilight')
-rw-r--r--lib/colonial_twilight/fln_bot_rules.rb34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb
index cbe2145..1049b82 100644
--- a/lib/colonial_twilight/fln_bot_rules.rb
+++ b/lib/colonial_twilight/fln_bot_rules.rb
@@ -158,27 +158,30 @@ module ColonialTwilight
spaces.select { |s| s.send(sym) == v }
end
+ def available_fln_bases?(board = @board)
+ board.available_fln_bases.positive?
+ end
+
def may_add_base_in?(space)
space.guerrillas > 2 && (space.fln_bases < (space.country? ? space.max_bases : 1))
end
def max_placable_guerrillas_in?(space)
- n = max_placable_guerrillas(space)
- n = n.clamp(0, space.pop + 1 - space.guerrillas) if space.fln_bases.positive?
- n
+ max_placable_guerrillas(space).clamp(0, space.fln_bases.positive? ? (space.pop + 1 - space.guerrillas) : 666)
end
- # 1) place: outofplay -> available | bases -> guerrillas if choice
- # 2) place: underground first unless from map then place active first flipped as underground
- # 3) march: underground -> active, unless march would activate then move active first
+ # 1) place: outofplay -> available | bases -> guerrillas if choice
+ # 2) place: underground first unless from map then place active first flipped as underground
+ # 3) march: underground -> active, unless march would activate then move active first
+ # applied as last filter in FLNBot#_place_fln
def place_guerrillas(spaces)
# 4) support -> with friendly pieces -> random
- l0 = (l0 = spaces.select(&:support?)).empty? ? spaces : l0
- l1 = (l1 = l0.select { |s| s.guerrillas.positive? }).empty? ? l0 : l1
- l1.shuffle
+ f = _filter(spaces, &:support?)
+ _filter(f) { |s| s.guerrillas.positive? }.shuffle
end
+ # FLNBot#_place_fln_in
def removable_guerrillas(space)
# 5) active only, leave 2 guerrillas at base or support
a = (a = space.fln_underground) > 2 ? 2 : a
@@ -190,6 +193,7 @@ module ColonialTwilight
spaces.reject { |s| steps.key?(s) }
end
+ # FLNBot#_place_fln_in
def remove_guerrillas_priority(spaces, steps)
# 5) #removable_guerrillas then most guerrillas first
return [] if (l = not_selected(spaces, steps).select { |s| removable_guerrillas(s).positive? }).empty?
@@ -197,6 +201,7 @@ module ColonialTwilight
_max(l, :guerrillas).shuffle
end
+ # not used yet
def remove_from(space, num = 1)
# 6) remove active -> underground -> base
h = {}
@@ -206,12 +211,9 @@ module ColonialTwilight
h
end
- def remove_gov(num = 1)
- # 7) map -> availabe (base -> french -> algerian; troops -> police)
- end
-
- # 8) reduce : commitment -> support -> france track -> gov resource
- # 9) shift : support -> oppose | best combined; remove terror only if also shift
- # 10) random
+ # 7) remove gov : map -> availabe (base -> french -> algerian; troops -> police)
+ # 8) reduce : commitment -> support -> france track -> gov resource
+ # 9) shift : support -> oppose | best combined; remove terror only if also shift
+ # 10) random
end
end