• No se han encontrado resultados

CONNECTFOURis another game wherel pieces are placed on n = wh cells of the game board, so that it has an exponential search space as well. Nevertheless, we can find a variable ordering, so that a superset of

4.3. POLYNOMIAL AND EXPONENTIAL BOUNDS FOR CONNECT FOUR 33

Figure 4.12: The CONNECTFOURdomain. Here, the red player has achieved a line of four pieces and thus won the game.

Bi coi

cr i

Figure 4.13: Replacement of a node from the BDD for the GRIPPERdomain by two nodes denoting that celli is occupied (co

i) and the occupying piece is red (c r

i) for the CONNECTFOURdomain. Solid arrows

represent high edges, dashed arrows represent low edges.

the reachable states can be represented by a number of polynomial sized BDDs (one for each BFS layer) if we continue after a terminal state has been reached, i. e., if we omit the check for termination. In this case, the superset contains all those states that can be reached by placing the pieces somewhere on the board and activating gravity only afterward.

Lemma 4.4 (Polynomial bound for CONNECTFOURwithout termination and delayed gravity). For CON-

NECT FOURthere is a binary state encoding and an associated variable ordering for which the BDD size for representing all the states withl pieces on the board is polynomial in n = wh, with w being the width andh the height of the board, if we do not cut off the search after a terminal state and if we use gravity only in layerl, not the previous ones.

Proof. We use2n + 1 bits to encode a state in CONNECTFOUR, two for each cell (red / yellow / none) and one for the active player. If we organize the variables in a column-wise manner, we need to calculate the conjunction of three polynomial sized BDDs.

Two BDDs are similar to the one in Figure 4.7 we used for the GRIPPERdomain. The first represents the fact that we haveb =l

2 red pieces on the board, the second one that we have b =  l

2 yellow pieces

on the board. In this game the cells can also be empty, so that we need to replace each node by two, the first one distinguishing between the cases that a cell is empty or not and the second one between the colors. If the cell is empty, we insert an edge to a node for the next cell; if it is not, we distinguish between the two colors (cf. Figure 4.13 for red pieces; for yellow pieces, the low and high edges of the lower node are swapped). Due to the replacement of each cell by two BDD nodes, each BDD has a size of O(2ln) = O (ln).

The third BDD represents the gravity, i. e., the fact that all pieces are located at the bottom of the columns. For this the column-wise variable ordering is important. Starting at the lowest cell of a column, if one is empty, all the following cells of this column are necessarily empty as well. If one is not empty, the others can still be empty or not. Thus, in this BDD it is only relevant if a cell is occupied, so that the actual color of a piece occupying it does not matter, which keeps the BDD smaller. All in all, we need at most two BDD nodes for each cell, resulting in a total of O(2wh) = O (wh) = O (n) BDD nodes (cf. Figure 4.14).

34 CHAPTER 4. LIMITS AND POSSIBILITIES OF BDDS co 2 co 3 co h−1 0 1 co 1 co 2 co 3 co h−1 co h co n co h+1 co h+2 coh+2 co h+3 coh+3 co n−1 con−1 . . . .. . ... . . . .. . ...

Figure 4.14: BDD for representing the fact that all pieces are located at the bottom in the CONNECTFOUR

domain. Each node co

i represents the decision for celli if it is occupied. Dashed edges stand for empty

cells, solid ones for occupied cells.

Calculating the conjunction of two BDDs of sizes s1 ands2 results in a new BDD of size at most

O (s1s2), so that the conjunction of three polynomial sized BDDs is still polynomial. In this case, the total

BDD for each layerl is of size Ol2n3. As l is at most n we arrive at a total size of at most O n5 BDD

nodes for each layer. Storing each layer in a separate BDD results inn BDDs of that size, so that overall we need On6 BDD nodes to store the desired superset of reachable states.

Unfortunately, Lemma 4.4 does not help much in analyzing the size of the BDD for representing the precise set of reachable states in a layer l. A way for representing this set we can envision is to use the BDD for the preceding layer, so that gravity is not delayed. This brings the disadvantage that we have to somehow combine the BDDs of all the layers, which will lead to an exponential blowup of the BDDs’ sizes, as for the last layer we have to combine the BDDs of alln layers.

Nevertheless, we can use a part of the proof of the lemma for proving that the BDDs for representing the precise sets of reachable states for all layersl of a k-in-a-row game without gravity, such as GOMOKU, are of polynomial size.

Lemma 4.5 (Polynomial bound fork-in-a-row games without gravity and without termination). There is a binary state encoding and an associated variable ordering for which the BDD size for representing the precise set of reachable states withl pieces on the board of a k-in-a-row game without gravity is polynomial inn = wh if we do not cut off the search after a terminal state.

Proof. The proof is actually the same as in Lemma 4.4, but we do not need the third BDD for the gravity. This way each layer’s BDD consists of at most On4 nodes and the total sum of nodes required to represent all the layers of reachable states in separate BDDs is bounded by On5.

4.3. POLYNOMIAL AND EXPONENTIAL BOUNDS FOR CONNECT FOUR 35