diff options
-rw-r--r-- | lib/colonial_twilight/fln_bot_rules.rb | 6 | ||||
-rw-r--r-- | spec/fln_bot_rules_spec.rb | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/colonial_twilight/fln_bot_rules.rb b/lib/colonial_twilight/fln_bot_rules.rb index f82cb39..4294136 100644 --- a/lib/colonial_twilight/fln_bot_rules.rb +++ b/lib/colonial_twilight/fln_bot_rules.rb @@ -234,6 +234,12 @@ module ColonialTwilight h.reject { |_k, v| v.zero? } # FIXME in empty? maybe hide active guerrillas ? end + def pick_guerrillas_from(board = @board) + return :available if board.available_fln_underground.positive? + + _remove_guerrillas_priority(board.spaces).sample + 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 diff --git a/spec/fln_bot_rules_spec.rb b/spec/fln_bot_rules_spec.rb index 328b316..2abe2b8 100644 --- a/spec/fln_bot_rules_spec.rb +++ b/spec/fln_bot_rules_spec.rb @@ -651,6 +651,13 @@ describe ColonialTwilight::FLNBotRules do expect(@rules._remove_guerrillas_priority([a, b, c, d], { d => true })[0]).to be b end + it 'pick guerrillas from most guerrillas' do + @rules.board.spaces << Sector.new(fln_active: 2, fln_underground: 1) + @rules.board.spaces << (b = Sector.new(fln_active: 2, fln_underground: 2)) + @rules.board.spaces << Sector.new(fln_active: 1, fln_underground: 2) + expect(@rules.pick_guerrillas_from(@rules.board)).to be b + end + it 'remove_from all' do a = Sector.new(fln_active: 2, fln_underground: 1, fln_bases: 1) h = @rules.remove_from(a, 6) |