SRL Archive - News and General

any ideas to solve box


ruler

2006-11-04 03:23:51



import java.awt.Rectangle;
import java.io.IOException;

import impsoft.ibot.Areas;
import impsoft.ibot.Info;

import impsoft.ibot.managers.BitMapManger;
import impsoft.ibot.methods.Menu;
import impsoft.ibot.methods.RGB;
import impsoft.ibot.methods.Random;
import impsoft.ibot.methods.XY;

public class StrangeBox extends Random {
private short[][][] box;

private XY matches[];

public String author = "ruler,pups";

public boolean startUp() {
if (theBot.loggedIn) {
if (box == null) {
box = loadBitmap("bitmaps/strangebox.bmp");
}
if (getTab() == Info.TAB_INVENTORY) {
matches = findXYs(getColorArray2d(), Areas.INVENTORY, null,
box, null, 30, 5, 5, 5);
if (matches.length > 0) {
return true;
}
}
}
setNextCheck(3000);
return false;
}

public XY findText(String text) {
return findGameScreenText(text, Areas.GAME, new RGB(187, 185, 73), 3,
3, 3);
}

public String shapes[] = { "Pentagon", "Circle", "Square", "Star",
"Triangle" };

public void random() throws InterruptedException {
for (int i = 0; i < matches.length; i++) {
mouseClickRight(new Rectangle(matches[i].x, matches[i].y,
box.length, box[0].length));
Menu menu = getMenu(Areas.INVENTORY, 2000);
if (menu != null) {
boolean success = menu.selectContains("Open");
if (success) {
while (true) {
sleep(3000);
if (findText("What") != null) {
int shapeIndex = -1;
for (int shp = 0; shp < shapes.length; shp++) {
if (findText("" + shapes[shp]) != null) {
shapeIndex = shp;
break;
}
}
if (shapeIndex != -1) {
int options[] = new int[3];
int found = 0;
for (int num = 0; num < 10; num++) {
if (findText("" + num) != null) {
options[found] = num;
found++;
if (found == 3)
break;
}
}
if (found == 3) {
log("Which number is the "
+ shapes[shapeIndex]);
for (int option = 0; option < options.length; option++) {
log(" " + options[option]);
}
// TODO
}
} else {
log("Could not determine the shape to find");
}
} else if (findText("Which") != null) {
int numerToFind = -1;
for (int num = 0; num < 10; num++) {
if (findText("" + num) != null) {
numerToFind = num;
break;
}
}
if (numerToFind != -1) {
int options[] = new int[3];
int found = 0;
for (int shp = 0; shp < shapes.length; shp++) {
if (findText("" + shapes[shp]) != null) {
options[found] = shp;
found++;
if (found == 3)
break;
}
}
if (found == 3) {
log("Which shape has a " + numerToFind);
for (int option = 0; option < options.length; option++) {
log(" " + shapes[options[option]]);
}
XY center = new XY(239, 137);
log("test START");
int count = 0;
int tests = 50;
long time = System.currentTimeMillis();
while (true) {
sleep(50);
getColorArray2d(0);// reresh color
// array
if (findRGBXYs(getColorArray2d(),
new Rectangle(182, 45, 1, 180),
null, new RGB(16579837,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(getColorArray2d(),
new Rectangle(342, 45, 1, 180),
null, new RGB(16579837,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(getColorArray2d(),
new Rectangle(172, 55, 177, 1),
null, new RGB(16579837,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(
getColorArray2d(),
new Rectangle(172, 215, 177, 1),
null, new RGB(16579837,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(getColorArray2d(),
new Rectangle(182, 45, 1, 180),
null, new RGB(12764106,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(getColorArray2d(),
new Rectangle(342, 45, 1, 180),
null, new RGB(12764106,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(getColorArray2d(),
new Rectangle(172, 55, 177, 1),
null, new RGB(12764106,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
if (findRGBXYs(
getColorArray2d(),
new Rectangle(172, 215, 1, 180),
null, new RGB(12764106,
RGB.COLOR_TYPE_SCAR),
1, 5, 5, 5).length > 0) {
continue;
}
count++;
if (count >= tests)
break;
}
log("Took "
+ (System.currentTimeMillis() - time)
+ " ms to complete pup's pre-function "
+ tests + " times");
try {
BitMapManger
.write(
theBot.theBitMapManger
.getBufferedImage(10),
"./QQQ"
+ System
.currentTimeMillis()
+ ".bmp");
} catch (IllegalArgumentException e) {
exception(e);
} catch (IOException e) {
exception(e);
}
log("test STOP");
}
} else {
log("Could not determine the number to find");
}
}
}
}
}
log("Found boxes at | X " + matches[i].x + " | Y " + matches[i].y);
}

log("Box Found Kill Bot");
shutDown();
}
}
I can get a frame that pup's algothrim defines as a possible flat one about every 400ms.

The algothrim takes about 20ms to test for couting the refresh of the color arrays and i do it every 50ms.

I saved some of the frames to my hard drive and about 1 out of 3 looked absolutly flat.

So mebe a valid frame at least every 2 seconds at the min.

I was thinking to define which shape by how many lines. Working on counting the area.

The number ocr will be a hard me thinks.

Do they ever interchange 6 and 9 ?

Looking for any suggestions.

lardmaster

2006-11-04 11:09:46

well, i can help you on one thing :) 6 and 9 are different by the period after them!

WT-Fakawi

2006-11-04 12:49:58

AFAIK the box has been updated. Now the 6 and the 9 do not appear in one box! Please verify.

bobert5696

2006-11-04 12:58:48

i have never seen a 6 or 9 in the same box, hopefully i get one today, ill let it turn into like 50, and look through them to see if i do get one with both a 6 or 9

lardmaster

2006-11-04 13:09:17

i have gotten a box w/ 6 and nine, but maybe its changed!

ruler

2006-11-04 20:58:36

My current idea is to find the biggest piece of white. That i can do. Take the area of the white. That i can do.

Then i know the shape in theory. (lol)

Now for the orc.

I was thinking of taking every point in the number and comparing it to the other numbers, find the 2 points that are furtest away from each other in terms of distance transversed while staying the the letter.

ex:

*xx
x
ox
x
*xx

to get from * to * every X is tranversed and added to the distance. The o is not transvered but it is added

Distance = 8;
dx = 4, dy =0

So now in theory we have a better idea of how the number is aligned.

The rest i am stilling thinking about.

Any suggestions? any critisms?

YoHoJo

2006-11-04 21:43:17

i believe its possible for both of them to appear int he same box
they are underlined so i shouldn't be too much of a problem (for a real player)

bobert5696

2006-11-05 00:08:35

to rulers last post, i think that would work pretty good if you got that working :)