// has a rectangular window (visionW*visionH) // walking range per frame is a circle with radius "range" sclass G22Walker { int range; // how far we can walk in each frame double roundingPolicy = .9; // for making the range circle (between 0 and 1) int visionW, visionH; // window rectangle size (should be odd) Pt position; // current position (center), not null bool stuck; // can neither stay nor move anywhere for some reason int guessWork; // how many "optimal" new positions we chose from void move(BWImage image) { stuck = false; guessWork = 0; // How far can I move until I hit the image's borders Rect movement1 = shrinkRect(bounds(image), visionW, visionH); // How far can I walk in one frame Rect movement2 = rectAroundPt(position, range*2+1); Rect movement = intersectRects(movement1, movement2); if (empty(movement)) ret with set stuck; printVars(+movement); Rect r = window_uncropped(); for (movement) } Rect window_uncropped(Pt center default position) { ret rectAroundPt(center, visionW, visionH); } }