SRL Archive - Help and Support

Accurate DDTM's


NKN

2012-09-21 20:36:11

function SetDDTM(tolerance:integer): Integer;
var
dtmMainPoint: TDTMPointDef;
BlackListedColors:Array [0..2] of Integer;
dtmSubPoints: Array [0..2] of TDTMPointDef;
TempTDTM: TDTM;
SB : TBox;
TP,TP1 : TPoint;
i:integer;
begin
SB := IntToBox(MMCX - 5,MMCY- 5,MMCX + 5,MMCY + 5);
for i := 0 to 2 do
BlackListedColors[i] := 1;
repeat
TP.x := randomRange(SB.X1,SB.X2);
TP.y := randomRange(SB.y1,SB.y2);
until(not(PointInBox(TP,IntToBox(625,133 - 50,629,137 - 50))))

dtmMainPoint.x := TP.x;
dtmMainPoint.y := TP.y;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := GetColor(TP.x,TP.y);
BlackListedColors[0] := GetColor(TP.x,TP.y);
dtmMainPoint.Tolerance := 5;
SMART_DrawDot(True,TP,clPurple);
repeat
TP1.x := TP.x + randomrange(-15,15);
TP1.y := TP.y + randomrange(-15,15);

dtmSubPoints[0].x := TP1.x;
dtmSubPoints[0].y := TP1.y;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := GetColor(TP1.x,TP1.y);
BlackListedColors[1] := GetColor(TP.x,TP.y);
dtmSubPoints[0].Tolerance := tolerance;
writeln('111');
until(not(dtmSubPoints[0].Color = BlackListedColors[0]));
for i := 0 to High(BlackListedColors) - 1 do
begin
TP1.x := TP.x - randomrange(-5,15);
TP1.y := TP.y - randomrange(-5,15);
SMART_DrawDot(False,TP1,clPurple);

dtmSubPoints[1].x := TP1.x;
dtmSubPoints[1].y := TP1.y;
dtmSubPoints[1].AreaSize := 0;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := GetColor(TP1.x,TP1.y);
BlackListedColors[2] := GetColor(TP1.x,TP1.y);
dtmSubPoints[1].Tolerance := tolerance;
if(not(dtmSubPoints[1].Color = BlackListedColors[i])) then
Continue;
if(dtmSubPoints[1].Color = BlackListedColors[i]) then
repeat
writeln('222');
writeln(BlackListedColors[i]);
TP1.x := TP.x - randomrange(-5,15);
TP1.y := TP.y - randomrange(-5,15);
SMART_DrawDot(False,TP1,clPurple);

dtmSubPoints[1].x := TP1.x;
dtmSubPoints[1].y := TP1.y;
dtmSubPoints[1].AreaSize := 0;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := GetColor(TP1.x,TP1.y);
BlackListedColors[2] := GetColor(TP1.x,TP1.y);
dtmSubPoints[1].Tolerance := tolerance;
until(not(dtmSubPoints[1].Color = BlackListedColors[i]))
end;
for i := 0 to High(BlackListedColors) do
begin
TP1.x := TP.x - randomrange(-15,15);
TP1.y := TP.y - randomrange(-15,15);
SMART_DrawDot(False,TP1,clPurple);

dtmSubPoints[2].x := TP1.x;
dtmSubPoints[2].y := TP1.y;
dtmSubPoints[2].AreaSize := 0;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := GetColor(TP1.x,TP1.y);
dtmSubPoints[2].Tolerance := tolerance;
if(dtmSubPoints[2].Color = BlackListedColors[i]) then
repeat
TP1.x := TP.x - randomrange(-15,15);
TP1.y := TP.y - randomrange(-15,15);
SMART_DrawDot(False,TP1,clPurple);

dtmSubPoints[2].x := TP1.x;
dtmSubPoints[2].y := TP1.y;
dtmSubPoints[2].AreaSize := 0;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := GetColor(TP1.x,TP1.y);
dtmSubPoints[2].Tolerance := tolerance;
until(not(dtmSubPoints[2].Color = BlackListedColors[i]))
end;
SMART_DrawDot(False,TP1,clPurple);


TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

That's my DDTM code, but I'm having trouble getting it to be accurate. D:
What should I set the tolerance to, or change in the points, or even findDTMRotated(), what should the parameters be for that?

I've been trying for two days, and it keeps messing up, no matter what I do. :(

Runaway

2012-09-21 21:25:21

I changed it around a bit, hope you don't mind :pinch:


function SetDDTM(SubPoints, Tolerance: Integer): Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array of TDTMPointDef;
TempTDTM: TDTM;
BlackListedColors: TIntegerArray;
TPA: TPointArray;
Temp: TPoint;
i: Integer;
begin
SetLength(dtmSubPoints, SubPoints);
SetLength(TPA, SubPoints + 1);
SetLength(BlackListedColors, SubPoints + 1);

TPA[0] := Point(MSCX, MSCY);
dtmMainPoint.x := TPA[0].x;
dtmMainPoint.y := TPA[0].y;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := GetColor(TPA[0].x, TPA[0].y);
dtmMainPoint.Tolerance := 255; // Any color
BlackListedColors[0] := dtmMainPoint.Color;

for i := 0 to (Points - 1) do
begin
dtmSubPoints[i].Color := 1;
BlackListedColors[i + 1] := 1;

while InIntArray(BlackListedColors, dtmSubPoints[i].Color) or PointInTPA(Temp, TPA) do
begin
Temp.x := TPA[0].x + randomrange(-15, 15);
Temp.y := TPA[0].y + randomrange(-15, 15);
dtmSubPoints[i].x := Temp.x;
dtmSubPoints[i].y := Temp.y;
dtmSubPoints[i].AreaSize := 0;
dtmSubPoints[i].AreaShape := 0;
dtmSubPoints[i].Color := GetColor(Temp.x, Temp.y);
dtmSubPoints[i].Tolerance := Tolerance;
end;

BlackListedColors[i + 1] := dtmSubPoints[i].Color;
TPA[i] := Temp;
end;
SMART_DrawDotsEx(True, TPA, clPurple);

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

You had the main point set at 5 tolerance, which is much too low for the MM. I changed it to be a true midpoint with a tolerance of 255 (so the color is irrelevant). I'd also suggest that you use a tol of about 20-30 for the subpoints; whatever you find works best after some testing. The MM is tough to handle in CTS1 so you're probably going to end up using more points to make up for the high tolerance.

NKN

2012-09-21 21:29:44

From: Runaway
I changed it around a bit, hope you don't mind :pinch:


function SetDDTM(SubPoints, Tolerance: Integer): Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array of TDTMPointDef;
TempTDTM: TDTM;
BlackListedColors: TIntegerArray;
TPA: TPointArray;
Temp: TPoint;
i: Integer;
begin
SetLength(dtmSubPoints, SubPoints);
SetLength(TPA, SubPoints + 1);
SetLength(BlackListedColors, SubPoints + 1);

TPA[0] := Point(MSCX, MSCY);
dtmMainPoint.x := TPA[0].x;
dtmMainPoint.y := TPA[0].y;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := GetColor(TPA[0].x, TPA[0].y);
dtmMainPoint.Tolerance := 255; // Any color
BlackListedColors[0] := dtmMainPoint.Color;

for i := 0 to (Points - 1) do
begin
dtmSubPoints[i].Color := 1;
BlackListedColors[i + 1] := 1;
while InIntArray(BlackListedColors, dtmSubPoints[i].Color) or PointInTPA(Temp, TPA) do
begin
Temp.x := TPA[0].x + randomrange(-15, 15);
Temp.y := TPA[0].y + randomrange(-15, 15);
dtmSubPoints[i].x := Temp.x;
dtmSubPoints[i].y := Temp.y;
dtmSubPoints[i].AreaSize := 0;
dtmSubPoints[i].AreaShape := 0;
dtmSubPoints[i].Color := GetColor(Temp.x, Temp.y);
dtmSubPoints[i].Tolerance := Tolerance;
end;
BlackListedColors[i + 1] := dtmSubPoints[i].Color;
TPA[i] := Temp;
end;
SMART_DrawDotsEx(True, TPA, clPurple);

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

You had the main point set at 5 tolerance, which is much too low for the MM. I changed it to be a true midpoint with a tolerance of 255 (so the color is irrelevant). I'd also suggest that you use a tol of about 20-30 for the subpoints; whatever you find works best after some testing. The MM is tough to handle in CTS1 so you're probably going to end up using more points to make up for the high tolerance.


Cool, I'll test it and see how it works.

Edit: Not working for some reason, e.e I'll see if I can fix it.
Edit2: I derped, was changing point count, instead of tolerance. I had to randomize the MainPoint, so it wasn't on your character dot tho. D:
Edit3: Lol, last edit for now. Still isn't working, could it be the blacklisted colors?