Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MakeWay(Desk: ArrDesk; CurrX, CurrY: Integer): ArrDesk;
- var
- I, J, K: Integer;
- CurrNX, CurrNY, CurrCount: Integer;
- PossX, PossY, PossCount: Integer;
- begin
- PossX := 0;
- PossY := 0;
- CurrCount := 8;
- PossCount := 8;
- Desk[CurrX][CurrY] := 1;
- for I := 2 to 64 do
- begin
- for J := 0 to 7 do
- begin
- if (CurrX + Possible_moves[J][0] >= 0) and (CurrX + Possible_moves[J][0] < 8) and
- (CurrY + Possible_moves[J][1] >= 0) and (CurrY + Possible_moves[J][1] < 8)
- and (Desk[CurrX + Possible_moves[J][0]][CurrY + Possible_moves[J][1]] = 0) then
- begin
- CurrCount := 0;
- CurrNX := CurrX + Possible_moves[J][0];
- CurrNY := CurrY + Possible_moves[J][1];
- for K := 0 to 7 do
- begin
- if (CurrNX + Possible_moves[K][0] >= 0) and (CurrNX + Possible_moves[K][0] < 8) and
- (CurrNY + Possible_moves[K][1] >= 0) and (CurrNY + Possible_moves[K][1] < 8)
- and (Desk[CurrNX + Possible_moves[K][0]][CurrNY + Possible_moves[K][1]] = 0) then
- begin
- Inc(CurrCount);
- end;
- end;
- end;
- if PossCount > CurrCount then
- begin
- PossX := CurrNX;
- PossY := CurrNY;
- PossCount := CurrCount;
- end;
- end;
- CurrX := PossX;
- CurrY := PossY;
- CurrNX := 0;
- CurrNY := 0;
- CurrCount := 8;
- PossCount := 8;
- Desk[CurrX][CurrY] := I;
- end;
- MakeWay := Desk;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement