Chess programming algorithm minimax to Alpha Beta I have written some code for alpha beta for Chess programming and not sure completely if that is the correct way to do it. Can someone please tell me if I implemented the alpha_beta properly?

public class Minimax{
    private boolean side;
    public static int depth;

    public Minimax(boolean inputSide, int inputDepth) {
        side = inputSide;
        depth = inputDepth;
    }

    public int[] getMoves(Board board, boolean white, int inputDepth, boolean check) {
        ArrayList&lt;int[]&gt; values = new ArrayList&lt;int[]&gt;();
        int initScore = board.getScore();
        boolean multipleMoves = false;
        ArrayList&lt;int[]&gt; multiple = new ArrayList&lt;int[]&gt;();
        if (white) {
            values.add(new int[]{-2000, 0, 0, 0, 0});
        }
        else {
            values.add(new int[]{2000, 0, 0, 0, 0});
        }
        int position = 0;
        if (inputDepth == depth) {
            int[] ret = {board.getScore(), 0, 0, 0, 0};
            return ret;
        }
        for (Pieces[] subPiece : board.getArray()) {
            for (Pieces piece : subPiece) {
                if (piece != null &amp;&amp; piece.white() == white) {
                    int[][] moves = piece.getMoves(board, false);
                    if (moves != null) {
                        for (int[] move : moves) {
                            Board newBoard = board.newBoard(move[0], move[1], move[2], move[3]);
                            if (newBoard != null) {
                                int score = getMoves(newBoard, !white, inputDepth + 1, newBoard.check(white))[0];
                                values.add(new int[]{score, move[0], move[1], move[2], move[3]});
                                if ((white &amp;&amp; score &gt; values.get(position)[0]) || (!white &amp;&amp; score &lt; values.get(position)[0])) {
                                    position = values.size() - 1;
                                    multipleMoves = false;
                                    multiple.clear();
                                }
                                else if (score == values.get(position)[0]) {
                                    multipleMoves = true;
                                    multiple.add(values.get(values.size() - 1));
                                    multiple.add(values.get(position));
                                }
                            }
                        }
                    }
                }
            }
        }
        if (values.size() == 1) {
            if (depth == 0) {
                return null;
            }
            else {
                if (white) {
                    return new int[]{-3000, 0, 0, 0, 0};
                }
                else {
                    return new int[]{3000, 0, 0, 0, 0};
                }
            }
        }
        if (multipleMoves &amp;&amp; multiple != null) {
            position = (int)((multiple.size() - 1) * Math.random() + 1);
            return multiple.get(position);
        }

        return values.get(position);
    }

    public int getDepth() {
            System.out.println(depth);
            return depth;

    }
}
A couple of things on top of what @tim already covered.

Use Random.nextInt instead of Math.random

Instead of this:


position = (int)((multiple.size() - 1) * Math.random() + 1);



you can write much simpler like this:

position = 1 + random.nextInt(multiple.size() - 1);


where random is an instance of Random, created for example in the constructor. Simpler isn't it?

Use interface types instead of implementations

Instead of:


    ArrayList&lt;int[]&gt; values = new ArrayList&lt;int[]&gt;();



This would be better:

    List&lt;int[]&gt; values = new ArrayList&lt;int[]&gt;();


(but not quite good enough, see the next item)

Define Abstract Data Types for your problem domain

An Abstract Data Type (ADT) is essentially a collection of data and  operations on that data.
In object oriented languages an ADT is usually modeled with a class,
where data is represented by member fields and the operations are represented by methods.

When I look at that ArrayList&lt;int[]&gt; in the previous point,
I've no idea what it stands for, 
what kind of logical object it represents,
and what the numbers in new int[]{-2000, 0, 0, 0, 0} and the other array initializations scattered in the code mean. 

If you have defined an ADT for this,
the code would become all the more readable.
Instead of new ArrayList&lt;int[]&gt;,
there might be new MinimaxValueSet().
Instead of values.add(new int[]{-2000, 0, 0, 0, 0}),
there might be valueSet.addNewSetWithScore(-2000),
where this helper method would fill in the repetitive zeros.

Don't print to the console

I suppose the println here was added for debugging:


public int getDepth() {
        System.out.println(depth);
        return depth;



It doesn't belong there and should be removed.
(I suggest to remove debugging code before pasting for code review,
it's just noise for reviewers.)