public static void main(String ... args) throws AWTException, InterruptedException {

        TetrisSensor sensor = new TetrisSensor();
        Point p = sensor.getBoardPosition();
        Point [][] points = sensor.getGridPointArray(p);


        if (p != null) {
            int width = 0;
            int height = 0;

            for (Point [] array : points ) {
                for (Point point : array) {
                    point.x -= p.x;
                    point.y -= p.y;
                    if (point.x > width) {
                        width = point.x;
                    }
                    if (point.y > height) {
                        height = point.y;
                    }
                }
            }

            //make sure the game has focus. This should be moved
            Robot r = sensor.getRobot();
            r.setAutoDelay(50);
            r.mouseMove(p.x + 50, p.y + 100);
            r.waitForIdle();
            r.mousePress(InputEvent.BUTTON1_MASK);
            r.waitForIdle();
            r.mouseRelease(InputEvent.BUTTON1_MASK);
            Rectangle rectangle = new Rectangle(p.x, p.y, width + 1, height + 1);

            while (true) {
                //long start = -System.currentTimeMillis();
                r.waitForIdle();
                sensor = new TetrisSensor(points, rectangle, r);
                //System.out.println("Made sensor in: " + ((start + System.currentTimeMillis()) + "ms"));
                //Get piece and move instructions
                ArrayList<Integer> keyPresses = getKeyPresses(sensor, p, points); 
                if (keyPresses != null) {
                    System.out.println(keyPresses);
                }
                //start = -System.currentTimeMillis();
                doMoves(r, keyPresses);

                if (keyPresses != null) {
                    if (keyPresses.contains(KeyEvent.VK_SPACE)) {
                        pieceNumber++;
                    }
                }
                //System.out.println("Moved pieces in: " + ((start + System.currentTimeMillis()) + "ms"));
            }
        } else {
            System.out.println("Didn't find board.");
        }
    }