0

I'm basically writing a bot for the game Bejeweled.
Everything works, however it appears to be a bit slow.. and I'm guessing it has to do with the way I'm gathering data for the program to use.

Essentially, I take a screenshot, open that file, and grab the RGB'S, add them to an arraylist, and use them.

Is there a better way to gather the data?
It seems like this is not the most efficient way.
Here is my method:

public void fetchBoard()  {
		int xvalue = 347;
		int yvalue = 406;
		int colornumber = 0;
		colorlist.clear();
		try {
			captureScreen("file");
		} catch (Exception e1) {
			e1.printStackTrace();
		}

		File inputFile = new File("file");
		BufferedImage image = null;
		try {
			image = ImageIO.read(inputFile);
		} catch (IOException e) {
			e.printStackTrace();
		}
		for(int y=1;y<=8;y++)
		{
			for(int x=1;x<=8;x++)
			{
				colorlist.add(new Cell(xvalue,yvalue,(x-1),(y-1),image.getRGB(xvalue, yvalue)));
				xvalue+=40;
				colornumber++;
			}
			xvalue = 347;
			yvalue +=40;
		}
	}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by JamesCherrill
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.