I work in grid-universe - objects exist only in integer locations in a two-dimensional matrix.
Some terms:
A square is a discrete location. Each square has int x and int y coordinates, and no two squares have the same x and y pairs.
Adjacent: square X is adjacent to another square Y if the difference in their x or y coordinates is not greater than 1. Simply put, all the squares at once in N, NE, E, SE, S, SW, W and NW are adjacent.
Legend:
'?' - Unknown Traversibility
'X' - Non Traversable Square
'O' - Building (Non Traversable)
' ' - Traversable Square
Problem:
Given the following general situation:
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? O O ? ? ?
? ? ? O O ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ?
where the builder is located next to one of the four buildings, I want to build two buildings so that they both have a common neighboring square that also adjoins at least one of the four existing buildings, and this common neighboring square is not blocked.
:
X X X X X X X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X X X X X X X
X X X O O X X X X X X O O X X X X X X O O X X X
X X X O O X X X X X X O O X X X X X O O O X X X
X X X O X X X O X X X X
O O X X X O X X X X X X X X
X X X X X X X X X X X
, 3 , , :
X X X X X X X X X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X X X X X X X X
X X X X X X X X X X O X X X X X O X
X X X O O X X X X X O O O X X X O O O X X
X X X O O X X X X X O O X X X X O O X X
X X X X X X X X X X X X X X
X X X O O X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X X X
, ?
: .
EDIT: , , . , .