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.

B.3 Strategy<br />

B.4 BroodwarBotQ<br />

Algorithm 9 Flow algorithm making sure there are no convex closures<br />

function init(region)<br />

{diri,j ← list()|(i, j) ∈ region}<br />

updated ← {(i, j)|(i, j) ∈ entrance(region)}<br />

{diri,j ← dir_towards(region)|(i, j) ∈ updated}<br />

while ∃diri,j == list() do<br />

(sources, new_updated) ← neighbours_couples(updated)<br />

<strong>for</strong> all ((x, y), (i, j)) ∈ (sources, new_updated) do<br />

if (x − i, y − j) /∈ dirx,y then<br />

diri,j.append((i − x, j − y))<br />

end if<br />

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

updated ← new_updated<br />

end while<br />

end function<br />

function build(i, j)<br />

refill ← list()<br />

<strong>for</strong> all (x, y) ∈ neighbours(i, j) do ⊲ cut the flow arround<br />

dirx,y.remove((x − i, y − j))<br />

if dirx,y.empty() then<br />

refill.append((x, y))<br />

build(x, y) ⊲ Recursively cut the flow<br />

end if<br />

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

while ¬fixed_point do ⊲ refill as in the initialization...<br />

current ← dir<br />

<strong>for</strong> all (x, y) ∈ refill do<br />

if ∃(i, j) ∈ neighbours(x, y) such that currenti,j �= list() then ⊲ non empty flow<br />

dirx,y.append((x − i, y − j))<br />

end if<br />

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

end while<br />

end function<br />

function is_isolated?(i, j)<br />

if diri,j.empty() then<br />

return True<br />

else<br />

return False<br />

end if<br />

end function<br />

204

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

Saved successfully!

Ooh no, something went wrong!