private int chainScores(Board b, int i, int depth) throws Exception {
        int ourMove = 0;
        int theirMove = 0;

        for (int chainLength = 4; chainLength > 1; chainLength--) {
            if(validMove(b, i) && b.willWin(i, chainLength, 1)) {
                ourMove += Math.pow(chainLength, 2);
            }
            
            if(validMove(b, i) && b.willWin(i, chainLength, -1)) {
                theirMove += Math.pow(chainLength, 2); 
            }
        }
        
        if (depth > 0) {
            int acc = 0;
            for (int col = 0; col < b.countCols(); col++) {
                for (int x = 0; x < b.countCols(); ++x) {
                    if(validMove(b, col)) {
                        acc += chainScores(b.withOpponentMove(col), x, depth - 1);
                    }
                }
            }
            
            return ourMove + theirMove + acc;
        } else {
            return ourMove + theirMove;
        }
    }