Lines Matching defs:box
41 #include "box.h"
56 // Find the first closure, i.e. a box that has 3 edges
64 BOX box(y, x, b);
65 if (box.count() == 3) {
66 for (dir = BOX::first; dir < BOX::last; dir++)
67 if (!box.isset(dir))
69 b.abort("find_closure: 3 sided box[%zu,%zu] has no free sides",
84 BOX tbox(0, x, b);
85 ne += tbox.isset(BOX::top);
86 BOX bbox(b.ny() - 1, x, b);
87 ne += bbox.isset(BOX::bottom);
90 BOX lbox(y, 0, b);
91 ne += lbox.isset(BOX::left);
92 BOX rbox(y,_b.nx() - 1, b);
93 ne += rbox.isset(BOX::right);
127 * and the first box of the maximum closure in (x, y, dir)
155 // Find if a turn does not result in a capture on the given box
157 int ALGOR::try_good_turn(BOX& box, size_t y, size_t x, int& dir, BOARD& b)
159 // Sanity check; we must have a good box
160 if (box.count() >= 2)
161 b.abort("try_good_turn: box[%zu,%zu] has more than 2 sides occupied",
164 // Make sure we don't make a closure in an adjacent box.
166 RANDOM rd(BOX::last);
167 for (dir = rd(); dir < BOX::last; dir = rd())
168 if (!box.isset(dir)) {
169 size_t by = y + BOX::edges[dir].y;
170 size_t bx = x + BOX::edges[dir].x;
174 BOX nbox(by, bx, b);
193 BOX box(y, x, nb);
194 if (box.count() < 2 && try_good_turn(box, y, x, dir, nb))
201 // On a box with 2 edges, return the first or the last free edge, depending
203 int ALGOR::try_bad_turn(BOX& box, size_t& y, size_t& x, int& dir, BOARD& b,
206 if (4 - box.count() <= last)
208 y, x, last, box.count());
209 for (dir = BOX::first; dir < BOX::last; dir++)
210 if (!box.isset(dir)) {
219 // Find a box that has 2 edges and return the first free edge of that
220 // box or the last free edge of that box
227 BOX box(y, x, b);
228 if ((4 - box.count()) > last &&
229 try_bad_turn(box, y, x, dir, b, last))
304 // See if we can play an edge without giving the opponent a box