Sample code for a game not doing as expected
<p>I am trying to turn over a piece if there is an opposite piece in between, and the spot is open.</p>

<p>It should check south (all pieces south of itself), if the next piece (besides itself) is opposite it's number (if I am player 1 with piece 2 next to me) then proceed until you hit another of my pieces. If you don't, then it is not a valid move.</p>

<p>Here is the algorithm (not working) Please let me know where the error is</p>

<p>Thanks</p>

<pre><code>private void checkSouth(Location point, int player) {
        //Loop through everything south
        boolean isthereAnOppositePlayer=false;

        int oppositePlayer=0;
        //Set opposite player
        if (player==1) {
            oppositePlayer=2;
        }else{
            oppositePlayer=1;
        }

        for (int i = point.getVertical(); i &lt; 8; i++) {

            //Create a location point with the current location being compared
            MyLocation locationBeingChecked= new MyLocation();
            locationBeingChecked.setHorizontal(point.getHorizontal());
            locationBeingChecked.setVertical(i);

            int value = board[locationBeingChecked.getVertical()][locationBeingChecked.getHorizontal()];

            //If the first checked is the opposite player
            if (value==oppositePlayer) {
                //Then potential to evaluate more
                isthereAnOppositePlayer=true;
            }
            //If it isn't an opposite player, then break
            if(!isthereAnOppositePlayer &amp;&amp; value!=0){
                break;
            }

            //If another of the player's piece found or 0, then end
            if (isthereAnOppositePlayer &amp;&amp; value==player || isthereAnOppositePlayer &amp;&amp; value==0) {
                break;
                //end   
            }

            //Add to number of players to flip
            if(isthereAnOppositePlayer &amp;&amp; value==oppositePlayer &amp;&amp; value!=0){
                //add to array
                addToPiecesToTurn(locationBeingChecked);
            }
        }
    }
</code></pre>
