Hi folks.
I am making a game where you have to build buildings on a map, to gather resources. The map is a 2D-grid of squares. The squares can be different types, like Gras, Forest and water. Each square has an item in an 2D-array with all the information that is stored to that field. The game also has a computer-player, where im making the AI now.

The record with the fieldinfo:
TSquare = record
Typ: string; //What terrain the square is ('Wather', 'Forest', 'Mountain', 'Gras').
Building: TBuilding; //Information about the building.
end;

TBuilding = record.
public
Typ: string; //What kind of building it is ('Farm', 'Mill', 'Bakery', 'Marketplace' etc.).
//Some other things here
end;

My problem / Question:
Now i want to make is a function where you give in a string and a TPoint, where the string is the landscape which the procedure has to find the nearest from, and the TPoint is the field where the mainbuilding/storage-area is. Is there a simple way to do this? Are there any examples on how to do this in pascal?

I use lazarus V. 0.9.30 and windows XP.

Thanks for help.