• Nenhum resultado encontrado

6.5.1 Tactical Model

We preferred to map the continuous values from heuristics to a few discrete values to enable quick complete computations. Another strategy would keep more values and use Monte-Carlo sampling for computation. We think that discretization is not a concern because 1) heuristics are simple and biased already 2) we often reason about imperfect information and this uncertainty tops discretization fittings.

Variables

Withnregions, we have:

• A1:n2 {true, f alse},Ai: attack in regionior not?

• E1:n 2 {no, low, high}, Ei is the discretized economical value of the region i for the defender. We choose 3 values: no workers in the regions, low: a small amount of workers (less than half the total) andhigh: more than half the total of workers in this region i.

• T1:n 2 discrete levels, Ti is the tactical value of the region i for the defender, see above for an explanation of the heuristic. Basically,T is proportional to the proximity to the de- fender’s army. In benchmarks, discretization steps are0,0.05,0.1,0.2,0.4,0.8 (log2 scale).

11adapted from http://github.com/SnippyHolloW/bwrepdump/blob/master/BWRepDump.cpp#L1773 and http://github.com/SnippyHolloW/bwrepdump/blob/master/BWRepDump.cpp#L1147

Algorithm 5Simplified attack tracking heuristic for extraction from games. The heuristics to determine the attack type and the attack radius and position are not described here. They look at the proportions of units types, which units are firing and the last actions of the players.

list tracked_attacks

function unit_death_event(unit)

tmp tracked_attacks.which_contains(unit) if tmp6=; then

tmp.update(unit) .,update(tmp, unit)

else

tracked_attacks.push(attack(unit)) end if

end function

function attack(unit) .new attack constructor

. self ,this self.convex_hull propagate_def ault_hull(unit)

self.type determine_attack_type(update(self, unit)) returnself

end function

function update(attack, unit)

attack.update_hull(unit) . takes units ranges into account c get_context(attack.convex_hull)

self.units_involved.update(c) self.tick def ault_timeout() returnc

end function

function tick_update self.tick self.tick−1 if self.tick <0 then

self.destruct() end if

end function

• T A1:n2discrete levels,T Ai is the tactical value of the regionifor the attacker (as above but for the attacker instead of the defender).

• B1:n2 {true, f alse},Bitells if the region belongs (or not) to the defender. P(Bi=true) = 1 if the defender has a base in region i and P(Bi = f alse) = 1 if the attacker has one.

Influence zones of the defender can be measured (with uncertainty) byP(Bi =true)≥0.5 and vice versa. In fact, when uncertain,P(Bi=true)is proportional to the distance from ito the closest defender’s base (and vice versa).

• H1:n2 {ground, air, invisible, drop},Hi: in predictive mode: how we will be attacked, in decision-making: how to attack, in regioni.

• GD1:n 2 {no, low, med, high}: ground defense (relative to the attacker power) in region i, result from a heuristic. no defense if the defender’s army is ≥1/10th of the attacker’s, low defense above that and under half the attacker’s army, medium defense above that and under comparable sizes,high if the defender’s army is bigger than the attacker.

• AD1:n2 {no, low, med, high}: same for air defense.

• ID1:n 2 {no detector, one detector, several}: invisible defense, equating to numbers of detectors.

• T T 2 [;, building1, building2, building1^building2, techtrees, . . .]: all the possible tech- nological trees for the given race. For instance {pylon, gate} and {pylon, gate, core} are two different TechTrees, see chapter 7.

• HP 2 {ground, ground^air, ground^invis, ground^air^invis, ground^drop, ground^ air^drop, ground^invis^drop, ground^air^invis^drop}: howpossible types of attacks, directly mapped from T T information. This variable serves the purpose of extracting all that we need to know from T T and thus reducing the complexity of a part of the model from n mappings from T T to Hi to one mapping from T T to HP and n mapping from HP to Hi. Without this variable, learning the co-occurrences of T T and Hi is sparse in the dataset. In prediction, with this variable, we make use of what we can infer on the opponent’s strategy Synnaeve and Bessière [2011b], Synnaeve and Bessière [2011], in decision-making, we know our own possibilities (we know our tech tree as well as the units we own).

We can consider a more complex version of this tactical model taking soft evidences into account (variables on which we have a probability distribution), which is presented in appendix B.2.1.

Decomposition

P(A1:n, E1:n, T1:n, T A1:n, B1:n, (6.1) H1:n, GD1:n, AD1:n, ID1:n, HP, T T) (6.2)

=

n

Y

i=1

[P(Ai)P(Ei, Ti, T Ai, Bi|Ai) (6.3) P(ADi, GDi, IDi|Hi)P(Hi|HP)] P(HP|T T)P(T T) (6.4) This decomposition is also shown in Figure 6.4. We can see that we have in fact two models:

one for A1:n and one forH1:n. Forms and learning

We will explain the forms for a given/fixediregion number:

• P(A) is the prior on the fact that the player attacks in this region, in our evaluation we set it tonbattles/(nbattles+nnot battles).

• P(E, T, T A, B|A) is a co-occurrences table of the economical, tactical (both for the de- fender and the attacker), belonging scores where an attacks happen. We just use Laplace’s law of succession (“add one” smoothing) [Jaynes, 2003] and count the co-occurrences in the games of the dataset (see section 6.4), thus almost performing maximum likelihood learning of the table.

P(E=e, T =t, T A=ta, B=b|A=T rue) = 1 +nbattles(e, t, ta, b)

|E| |T| |T A| |B|+P

E,T ,T A,Bnbattles(E, T, T A, B)

N [0..2]

E [0..5]

T [0..5]

TA 0,1 B

0,1 A

[0..3]

AD [0..3]

GD [0..2]

ID

[0..3]

H

[0..7]

HP

#TT TT

Figure 6.4: Plate diagram (factor graph notation) of the Bayesian tactical model.

• P(AD, GD, ID|H) is a co-occurrences table of the air, ground, invisible defense values depending on how the attack happens. As for P(E, T, T A, B|A), we use a Laplace’s rule of succession learned from the dataset.

P(AD=ad, GD=gd, ID=id|H =h) = 1 +nbattles(ad, gd, id, h)

|AD| |GD| |ID|+P

AD,GD,IDnbattles(AD, GD, ID, h)

• P(H|HP)is the categorical distribution (histogram) on how the attack happens depending on what is possible. Trivially P(H = ground|HP = ground) = 1.0, for more complex possibilities we have different smoothed maximum likelihood multinomial distributions on H values depending on HP.

P(H =h|HP =hp) = 1 +nbattles(h, hp)

|H|+P

Hnbattles(H, hp)

• P(HP|T T =tt)is a Dirac distribution on theHP =hpwhich is compatible withT T =tt.

It is the direct mapping of what the tech tree allows as possible attack types: P(HP = hp|T T) = 1 is a function ofT T (allP(HP 6=hp|T T) = 0).

• P(T T): if we are sure of the tech tree (prediction without fog of war, or in decision-making mode), P(T T =k) = 1 and P(T T 6=k) = 0; otherwise, it allows us to take uncertainty about the opponent’s tech tree and balanceP(HP|T T). We obtain a distribution on what is possible (P(HP)) for the opponent’s attack types.

There are two approaches to fill up these probability tables, either by observing games (supervised learning), as we did in the evaluation section, or by acting (reinforcement learning).

The model is highly modular, and some parts are more important than others. We can separate three main parts: P(E, T, T A, B|A),P(AD, GD, ID|H) andP(H|HP). In prediction, P(E, T, T A, B|A) uses the inferred (uncertain) economic (E), tactical (T) and belonging (B) scores of the opponent while knowing our own tactical position fully (T A). In decision-making, we know E, T, B (for us) and estimate T A. In our prediction benchmarks, P(AD, GD, ID|H) has the lesser impact on the results of the three main parts, either because the uncertainty from the attacker onAD, GD, IDis too high or because our heuristics are too simple, though it still contributes positively to the score. In decision-making, it allows for reinforcement learning to have tuple values forAD, GD, ID at which to switch attack types. In prediction, P(H|HP) is used to takeP(T T)(coming from strategy prediction [Synnaeve and Bessière, 2011], chapter 7) into account and constraintsH to what is possible. For the use of P(H|HP)P(HP|T T)P(T T) in decision-making, see the results section (6.6) or the appendix B.2.1.

Questions

For a given regioni, we can ask the probability to attack here,

P(Ai =ai|ei, ti, tai, bi) (6.5)

= P(ei, ti, tai, bi|ai)P(ai) P

AiP(ei, ti, tai, bi|Ai)P(Ai) (6.6) / P(ei, ti, tai, Bi|ai)P(ai) (6.7) and the mean by which we should attack,

P(Hi=hi|adi, gdi, idi) (6.8)

/ X

T T,HP

[P(adi, gdi, idi|hi)P(hi|HP)P(HP|T T)P(T T)] (6.9)

We always sum over estimated, inferred variables, while we know the one we observe fully. In prediction mode, we sum over T A, B, T T, HP; in decision-making, we sum over E, T, B, AD, GD, ID (see appendix B.2.1). The complete question that we ask our model is P(A, H|F ullyObserved). The maximum ofP(A, H) = P(A)⇥P(H)may not be the same as the maximum of P(A) or P(H) take separately. For instance think of a very important economic zone that is very well defended, it may be the maximum ofP(A), but not once we takeP(H)into account. Inversely, some regions are not defended against anything at all but present little or no interest. Our joint distribution 6.3 can be rewritten: P(Searched, F ullyObserved, Estimated), so we ask:

P(A1:n, H1:n|F ullyObserved) (6.10)

/ X

Estimated

P(A1:n, H1:n, Estimated, F ullyObserved) (6.11)

The Bayesian program of the model is as follows:

Bayesianprogram 8

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

<

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

:

Description

8

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

><

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>:

Specification(⇡)

8

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

<

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

:

V ariables

A1:n, E1:n, T1:n, T A1:n, B1:n, H1:n, GD1:n, AD1:n, ID1:n, HP, T T Decomposition

P(A1:n, E1:n, T1:n, T A1:n, B1:n, H1:n, GD1:n, AD1:n, ID1:n, HP, T T)

=Qn

i=1[P(Ai)P(Ei, Ti, T Ai, Bi|Ai)

P(ADi, GDi, IDi|Hi)P(Hi|HP)] P(HP|T T)P(T T) F orms

P(Ai) prior on attack in region i

P(E, T, T A, B|A) covariance/probability table P(AD, GD, ID|H) covariance/probability table P(H|HP) =Categorical(4, HP)

P(HP =hp|T T) = 1.0 if f T T !hp, else P(HP|T T) = 0.0 P(T T) comes from a strategic model

Identif ication (using δ) P(A=true) = n nbattles

battles+nnot battles = µbattles/game

µregions/map (probability to attack a region) it could be learned online (preference of the opponent) :

P(Ai =true) = 2+P1+nbattles(i)

j2regionsnbattles(i) (online for each game8r)

P(E =e, T =t, T A=ta, B =b|A=T rue) = |E|⇥|T|⇥|T A|⇥|B|+1+nPbattles(e,t,ta,b)

E,T,T A,Bnbattles(E,T,T A,B)

P(AD=ad, GD=gd, ID=id|H =h) = 1+nbattles(ad,gd,id,h)

|AD|⇥|GD|⇥|ID|+P

AD,GD,IDnbattles(AD,GD,ID,h)

P(H=h|HP =hp) = |H|+1+nPbattles(h,hp)

Hnbattles(H,hp)

Questions

8i2regions P(Ai|ei, ti, tai) 8i2regions P(Hi|adi, gdi, idi) P(A, H|F ullyObserved)