I'm currently trying to complete a basic auto-bilger for puzzle pirates. Unfortunately, my matching tile finder isn't able to get past the 1st funtion I've made. ATM it's a bit badly coded, but the basic outlines are there and I've gone through it a few times, but still can't see to find out what's stopping it.
Tile Identifier (Works)
SCAR Code:
Function CheckTile(a,b:Integer):Integer;
Begin
Result:=0;
a:=(a*45)+XStart+65;
b:=(b*45)+YStart+110;
For i:=1 To 5 Do
Begin
If(FindColorTolerance(x,y,tile[i],a,b,a+5,b+5,10)) Then Result:=i;
End
Writeln('Identified Tile, now going to check for matching tile');
End;
Tile Matcher (Looks for a tile that could end in a 3 of a kind)
SCAR Code:
Function CheckMatch(c,d:Integer):Integer;
Begin
Result:=0;
z:=CheckTile(c,d);
c:=(c*45)+XStart+20;
d:=(d*45)+YStart+20;
If(z>0) Then
Begin
If(FindcolorTolerance(x,y,tile[z],c,d-90,c+5,d-85,10)) Then Result:=1;
If(FindcolorTolerance(x,y,tile[z],c,d+90,c+5,d+95,10)) Then Result:=2;
If(FindcolorTolerance(x,y,tile[z],c-45,d,c-40,d+5,10)) Then Result:=3;
If(FindcolorTolerance(x,y,tile[z],c+45,d,c+50,d+5,10)) Then Result:=4;
End
If(Result>0) Then Writeln('Found a matching tile, now going to check for a move');
If(Result=0) Then Writeln('No matching tiles, going onto next');
End;
Move Checker (Final check to see if a move can be made)
SCAR Code:
Function CheckMove(e,f:Integer):Integer;
Begin
Result:=0;
w:=CheckMatch(e,f);
e:=(e*45)+XStart+20;
f:=(f*45)+YStart+20;
If(w>0) Then
Begin
If(w=1) Then
Begin
If(FindcolorTolerance(x,y,tile[z],e-45,f-45,e-40,f-40,10)) Then Result:=1;
If(FindcolorTolerance(x,y,tile[z],e+45,f-45,e-40,f+50,10)) Then Result:=2;
End
If(w=2) Then
Begin
If(FindcolorTolerance(x,y,tile[z],e-45,f+45,e-40,f+50,10)) Then Result:=3;
If(FindcolorTolerance(x,y,tile[z],e+45,f+45,e+50,f+50,10)) Then Result:=4;
End
If(w=3) Then
Begin
If(FindColorTolerance(x,y,tile[z],e-135,f,e-130,f+5,10)) Then Result:=5;
End
If(w=4) Then
Begin
If(FindColorTolerance(x,y,tile[z],e+135,f,e+140,f+5,10)) Then Result:=6;
End
End
If(Result>0) Then Writeln('Move found, yay');
If(Result=0) Then Writeln('No moves, onto next one');
End;
These are my functions I use and the only other important thing in the script is my procedure which just generates x and y values for the move and interpreting CheckMove's result into a tile to move. If you need any other part of the script, you just have to ask and also you can just ask for any other info that can prove useful to help me getting this working