15.12.2012 Views

Bayesian Programming and Learning for Multi-Player Video Games ...

Bayesian Programming and Learning for Multi-Player Video Games ...

Bayesian Programming and Learning for Multi-Player Video Games ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix B<br />

StarCraft AI<br />

B.1 Micro-management<br />

Algorithm 8 (Simplified) Target selection heuristic, efficiently implemented with a enemy units<br />

↔ damages bidirectional map: bimap : u, d → (left : u → d, right : d → u)<br />

function on_death(unit)<br />

remove_incoming_damages(unit.target, damages(unit, unit.target))<br />

end function<br />

function register_target(unit, target)<br />

add_incoming_damages(target, damages(unit, target))<br />

unit.target ← target<br />

end function<br />

function select_target(unit)<br />

<strong>for</strong> all eunit ∈ focus_fire_order(enemy_units) do<br />

if eunit.type ∈ priority_targets(unit.type) then<br />

if in_range(unit, eunit) then<br />

register_target(unit, eunit)<br />

else if unit.prio_target == NULL then<br />

unit.prio_target ← eunit<br />

end if<br />

end if<br />

end <strong>for</strong><br />

if unit.target == NULL then<br />

<strong>for</strong> all eunit ∈ focus_fire_order(enemy_units) do<br />

if in_range(unit, eunit) then<br />

register_target(unit, eunit)<br />

end if<br />

end <strong>for</strong><br />

end if<br />

if unit.target == NULL <strong>and</strong> unit.prio_target == NULL then unit.prio_target ←<br />

closer(unit, enemy_units)<br />

end if<br />

end function<br />

197

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!