I am trying to write a prolog program that can find the tiles that are completely surrounded by b or w in a 2D-array.
For example, given a dataset like this:
[
[b, w, +, +],
[w, +, w, b],
[+, w, b, +],
[+, +, +, b],
]
It would return another Variable containing:
[
[-, -, -, -],
[-, w, -, -],
[-, -, -, b],
[-, -, -, -],
]
That is, it replaced all the + which were completely surrounded with b with a b, and the same for those surrounded by a w, and replaced everything else with a -.
Can anyone give any ideas on how to build a program to do this?
This might help: it takes the representation you gave, and gives back a list whose elements are each of the form [ColumnIndex, RowIndex, Value]. You can then use member to find an element at a particular row/column.