So I am trying to make a memory game with an AI that chooses cards after my turn and when you find pair of cards that matches, it deletes and moves it to the side.
I am having ARRAY OUT OF BOUNDS on my code
if someone could help that would be great.
data folder on google drive --> hereDrive
import java.lang.Integer;
int alarm=-1;
ArrayList <Integer> mem =new ArrayList<Integer>(10);
ArrayList <Integer> AIpairs=new ArrayList<Integer>(12);
PImage[] cardPic = new PImage[13];
int[] card;// -1= empty 1-12 fromcardPic
boolean[] faceUp; // true= face false= back
int level=3; //1=easy 2=med 3=hard
int turn=0; //0-init 1=player 2=AI
int cols;
int cw;
int ch;
PImage wall, MENU;
int [] hand = new int[2];
int Count = 0;
int maxMem;
int scene =1;
void setup()
{
size(1080, 720);
for ( int i=1; i<14; i++)
{
wall=loadImage("wall.jpg");
MENU=loadImage("MENU.jpg");
cardPic[i-1] =loadImage("KIRENCOPIED ("+i+").png");
}
}
void draw()
{
if (scene==1)
{
if (turn==0)
initGrid();
if (turn==2 && alarm==-1)
{
AITurn();
}
showGrid();
if (alarm==0)
{
checkMatch();
}
if (alarm >0 )
alarm--;
}
}
void initGrid()
{
maxMem= level*2+1;
mem.clear();
AIpairs.clear();
cols=3+level;
cw=200-level*30;
ch=250-level*35;
println(turn);
card= new int[4*(level+3)];
for (int i=0; i<card.length; i++)
card[i]=i/2+1;
faceUp= new boolean[card.length];
////////////
for (int i=0; i<faceUp.length; i++)
faceUp[i]= false;
////////////////
for (int i=0; i<hand.length; i++)
hand[i]= -1;
turn=2; ////////////////////////////////////////TURN =====================2
shuffleIt();
}
//////////////////////////////
void shuffleIt()
{ //shuffle card[] - pick random index and swap and sawap value
int r1, r2, temp;
for (int i=0; i<card.length*2; i++)
{
r1= int(random(card.length));
r2= int(random(card.length));
temp = card[r1];
card[r1] = card[r2];
card[r2] = temp;
}
}
void showGrid()
{
image(wall, 0, 0, width, height);
for (int i=0; i<card.length; i++)
///////////C = colloum and R = row///
{ /////////////////gap//side
int c =i%cols*(cw+12)+50;
int r =i/cols*(ch+12)+30;
if (card [i]>0)
{
if (faceUp[i])
image(cardPic[card[i]], c, r, cw, ch);
else image(cardPic[0], c, r, cw, ch);
}
}
for (int i=0; i<AIpairs.size(); i++)
{
image(cardPic[AIpairs.get(i)], 900, 20+i*ch/2, cw, ch); ///////// ARRAY OUT OF bOUNDS
}
}
void mouseClicked()
{
if (turn==1&& turn==2)
{
for (int i=0; i<card.length; i++)
{
int c =i%cols*(cw+12)+50;
int r =i/cols*(ch+12)+30;
if (card[i]>0 && !faceUp[i]
&& mouseX> c && mouseX< c+cw &&
mouseY>r && mouseY< r+ch)
{
hand[Count]=i;
Count++;//////
faceUp[i]=true;
if (Count==2)
checkMatch();
}
}
}
}
void checkMatch()
{
// if same remove
if (card[hand[0]] == card [hand[1]])//////////////////////////////////CHANGE VALUE
{
if (turn==2)
AIpairs.add(hand[0]);
/////////////////////////////////////
card[hand[0]] =-1;
card[hand[1]] =-1;
} else
{
faceUp[hand[0]] =false;
faceUp[hand[1]] =false;
}
//else flip back
Count = 0;
alarm=-1;
}////
void AITurn()
{
boolean found = false;
/// add to mem if hand exists
for (int i=0; i<hand.length; i++)
if ( hand[i]>0 && card[hand [i]] >0)
mem.add(hand[i]);
// remove from mem cards that dont exist
for (int i=0; i<mem.size(); i++)
{
println("i "+i+" hand[0] "+hand[0]+" mem.get(i) "+mem.get(i) );
if (card[mem.get(i)]<0)
{
mem.remove(i);
i--;
}
}
//trip mem limit
while (mem.size()> maxMem)
{
mem.remove(0);
}
// 2 cards match in mem
// pick 1 card random other form memory
hand[0]= int(random(card.length));
while (card[hand[0]]<0)
hand[0] =int(random(card.length));
for (int i=0; i<mem.size() && !found; i++)////////////found
{
if ( hand[0] !=mem.get(i) ) {
println("same "+ card[hand[0]] +" ?==? "+card[mem.get(i)] );
if ( card[hand[0]] == card[mem.get(i)] ) {
hand[1]=mem.get(i);
}
}
}
// pick both cards random
if (!found)
{
hand[1] =int(random(card.length));
while (card[hand[1]]< 0||hand[0] == hand[1])
hand[1] =int(random(card.length));
}
faceUp[hand[0]] =true;
faceUp[hand[1]] =true;
alarm=1;// WAith
if (scene ==0)
{
image(MENU, 0, 0);
}
}
Here is the console read
I think changing the for loop is messing with the memory and makes the AI moves really bad
also i am updating the code as we go, i can also attach the data folder if that makes it easy
i 3 hand[0] 19 mem.get(i) 20
i 4 hand[0] 19 mem.get(i) 3
i 5 hand[0] 19 mem.get(i) 20
i 6 hand[0] 19 mem.get(i) 19
i 7 hand[0] 19 mem.get(i) 19
i 8 hand[0] 19 mem.get(i) 14
same 1 ?==? 2
same 1 ?==? 6
same 1 ?==? 12
same 1 ?==? 6
same 1 ?==? 9
same 1 ?==? 9
same 1 ?==? 5
i 0 hand[0] 7 mem.get(i) 23
i 1 hand[0] 7 mem.get(i) 20
i 2 hand[0] 7 mem.get(i) 3
i 3 hand[0] 7 mem.get(i) 20
i 4 hand[0] 7 mem.get(i) 19
i 5 hand[0] 7 mem.get(i) 19
i 6 hand[0] 7 mem.get(i) 14
i 7 hand[0] 7 mem.get(i) 7
i 8 hand[0] 7 mem.get(i) 3
same 7 ?==? 12
same 7 ?==? 6
same 7 ?==? 9
same 7 ?==? 9
same 7 ?==? 5
same 7 ?==? 1
same 7 ?==? 12
i 0 hand[0] 11 mem.get(i) 3
i 1 hand[0] 11 mem.get(i) 20
i 2 hand[0] 11 mem.get(i) 19
i 3 hand[0] 11 mem.get(i) 19
i 4 hand[0] 11 mem.get(i) 14
i 5 hand[0] 11 mem.get(i) 7
i 6 hand[0] 11 mem.get(i) 3
i 7 hand[0] 11 mem.get(i) 11
i 8 hand[0] 11 mem.get(i) 8
same 10 ?==? 9
same 10 ?==? 9
same 10 ?==? 5
same 10 ?==? 1
same 10 ?==? 12
same 10 ?==? 7
same 10 ?==? 4
i 0 hand[0] 16 mem.get(i) 19
i 1 hand[0] 16 mem.get(i) 19
i 2 hand[0] 16 mem.get(i) 14
i 3 hand[0] 16 mem.get(i) 7
i 4 hand[0] 16 mem.get(i) 3
i 5 hand[0] 16 mem.get(i) 11
i 6 hand[0] 16 mem.get(i) 8
i 7 hand[0] 16 mem.get(i) 16
i 8 hand[0] 16 mem.get(i) 8
same 9 ?==? 5
same 9 ?==? 1
same 9 ?==? 12
same 9 ?==? 7
same 9 ?==? 4
same 9 ?==? 10
same 9 ?==? 4
i 0 hand[0] 9 mem.get(i) 14
i 1 hand[0] 9 mem.get(i) 7
i 2 hand[0] 9 mem.get(i) 3
i 3 hand[0] 9 mem.get(i) 11
i 4 hand[0] 9 mem.get(i) 8
i 5 hand[0] 9 mem.get(i) 16
i 6 hand[0] 9 mem.get(i) 8
i 7 hand[0] 9 mem.get(i) 9
same 1 ?==? 12
same 1 ?==? 7
same 1 ?==? 4
same 1 ?==? 10
same 1 ?==? 4
same 1 ?==? 9
i 0 hand[0] 7 mem.get(i) 7
i 1 hand[0] 7 mem.get(i) 3
i 2 hand[0] 7 mem.get(i) 11
i 3 hand[0] 7 mem.get(i) 8
i 4 hand[0] 7 mem.get(i) 16
i 5 hand[0] 7 mem.get(i) 8
i 6 hand[0] 7 mem.get(i) 9
i 7 hand[0] 7 mem.get(i) 7
i 8 hand[0] 7 mem.get(i) 20
same 1 ?==? 7
same 1 ?==? 4
same 1 ?==? 10
same 1 ?==? 4
same 1 ?==? 9
same 1 ?==? 1
same 1 ?==? 6
i 0 hand[0] 18 mem.get(i) 11
i 1 hand[0] 18 mem.get(i) 8
i 2 hand[0] 18 mem.get(i) 16
i 3 hand[0] 18 mem.get(i) 8
i 4 hand[0] 18 mem.get(i) 9
i 5 hand[0] 18 mem.get(i) 7
i 6 hand[0] 18 mem.get(i) 20
i 7 hand[0] 18 mem.get(i) 18
i 8 hand[0] 18 mem.get(i) 20
same 10 ?==? 10
same 10 ?==? 4
same 10 ?==? 9
same 10 ?==? 1
same 10 ?==? 6
same 10 ?==? 1
same 10 ?==? 6
i 0 hand[0] 5 mem.get(i) 16
i 1 hand[0] 5 mem.get(i) 8
i 2 hand[0] 5 mem.get(i) 9
i 3 hand[0] 5 mem.get(i) 7
i 4 hand[0] 5 mem.get(i) 20
i 5 hand[0] 5 mem.get(i) 18
i 6 hand[0] 5 mem.get(i) 20
i 7 hand[0] 5 mem.get(i) 5
i 8 hand[0] 5 mem.get(i) 11
same 1 ?==? 9
same 1 ?==? 6
same 1 ?==? 1
same 1 ?==? 6
same 1 ?==? 10
same 1 ?==? 7
i 0 hand[0] 7 mem.get(i) 9
i 1 hand[0] 7 mem.get(i) 7
i 2 hand[0] 7 mem.get(i) 20
i 3 hand[0] 7 mem.get(i) 18
i 4 hand[0] 7 mem.get(i) 20
i 5 hand[0] 7 mem.get(i) 5
i 6 hand[0] 7 mem.get(i) 11
i 7 hand[0] 7 mem.get(i) 7
i 8 hand[0] 7 mem.get(i) 10
same 9 ?==? 6
same 9 ?==? 1
same 9 ?==? 6
same 9 ?==? 10
same 9 ?==? 7
same 9 ?==? 1
same 9 ?==? 6
i 0 hand[0] 19 mem.get(i) 20
i 1 hand[0] 19 mem.get(i) 18
i 2 hand[0] 19 mem.get(i) 20
i 3 hand[0] 19 mem.get(i) 5
i 4 hand[0] 19 mem.get(i) 11
i 5 hand[0] 19 mem.get(i) 7
i 6 hand[0] 19 mem.get(i) 10
i 7 hand[0] 19 mem.get(i) 19
i 8 hand[0] 19 mem.get(i) 8
same 12 ?==? 6
same 12 ?==? 10
same 12 ?==? 7
same 12 ?==? 1
same 12 ?==? 6
same 12 ?==? 9
same 12 ?==? 4
i 0 hand[0] 3 mem.get(i) 20
i 1 hand[0] 3 mem.get(i) 5
i 2 hand[0] 3 mem.get(i) 11
i 3 hand[0] 3 mem.get(i) 7
i 4 hand[0] 3 mem.get(i) 10
i 5 hand[0] 3 mem.get(i) 19
i 6 hand[0] 3 mem.get(i) 8
i 7 hand[0] 3 mem.get(i) 3
i 8 hand[0] 3 mem.get(i) 12
same 7 ?==? 1
same 7 ?==? 6
same 7 ?==? 9
same 7 ?==? 4
same 7 ?==? 12
same 7 ?==? 8
i 0 hand[0] 11 mem.get(i) 11
i 1 hand[0] 11 mem.get(i) 7
i 2 hand[0] 11 mem.get(i) 10
i 3 hand[0] 11 mem.get(i) 19
i 4 hand[0] 11 mem.get(i) 8
i 5 hand[0] 11 mem.get(i) 3
i 6 hand[0] 11 mem.get(i) 12
i 7 hand[0] 11 mem.get(i) 11
i 8 hand[0] 11 mem.get(i) 14
same 3 ?==? 6
same 3 ?==? 9
same 3 ?==? 4
same 3 ?==? 12
same 3 ?==? 8
same 3 ?==? 7
same 3 ?==? 5
i 0 hand[0] 21 mem.get(i) 10
i 1 hand[0] 21 mem.get(i) 19
i 2 hand[0] 21 mem.get(i) 8
i 3 hand[0] 21 mem.get(i) 3
i 4 hand[0] 21 mem.get(i) 12
i 5 hand[0] 21 mem.get(i) 11
i 6 hand[0] 21 mem.get(i) 14
i 7 hand[0] 21 mem.get(i) 21
i 8 hand[0] 21 mem.get(i) 23
same 9 ?==? 4
same 9 ?==? 12
same 9 ?==? 8
same 9 ?==? 7
same 9 ?==? 5
same 9 ?==? 3
same 9 ?==? 2
i 0 hand[0] 19 mem.get(i) 8
i 1 hand[0] 19 mem.get(i) 3
i 2 hand[0] 19 mem.get(i) 12
i 3 hand[0] 19 mem.get(i) 11
i 4 hand[0] 19 mem.get(i) 14
i 5 hand[0] 19 mem.get(i) 21
i 6 hand[0] 19 mem.get(i) 23
i 7 hand[0] 19 mem.get(i) 19
i 8 hand[0] 19 mem.get(i) 6
same 11 ?==? 8
same 11 ?==? 7
same 11 ?==? 5
same 11 ?==? 3
same 11 ?==? 2
same 11 ?==? 9
same 11 ?==? 4
i 0 hand[0] 15 mem.get(i) 12
i 1 hand[0] 15 mem.get(i) 11
i 2 hand[0] 15 mem.get(i) 14
i 3 hand[0] 15 mem.get(i) 21
i 4 hand[0] 15 mem.get(i) 23
i 5 hand[0] 15 mem.get(i) 19
i 6 hand[0] 15 mem.get(i) 6
i 7 hand[0] 15 mem.get(i) 15
i 8 hand[0] 15 mem.get(i) 4
same 3 ?==? 5
same 3 ?==? 2
same 3 ?==? 9
same 3 ?==? 4
same 3 ?==? 11
same 3 ?==? 5
i 0 hand[0] 21 mem.get(i) 14
i 1 hand[0] 21 mem.get(i) 21
i 2 hand[0] 21 mem.get(i) 23
i 3 hand[0] 21 mem.get(i) 19
i 4 hand[0] 21 mem.get(i) 6
i 5 hand[0] 21 mem.get(i) 15
i 6 hand[0] 21 mem.get(i) 4
i 7 hand[0] 21 mem.get(i) 21
i 8 hand[0] 21 mem.get(i) 1
same 6 ?==? 2
same 6 ?==? 9
same 6 ?==? 4
same 6 ?==? 11
same 6 ?==? 5
same 6 ?==? 3
same 6 ?==? 7
i 0 hand[0] 10 mem.get(i) 23
i 1 hand[0] 10 mem.get(i) 19
i 2 hand[0] 10 mem.get(i) 6
i 3 hand[0] 10 mem.get(i) 15
i 4 hand[0] 10 mem.get(i) 4
i 5 hand[0] 10 mem.get(i) 21
i 6 hand[0] 10 mem.get(i) 1
i 7 hand[0] 10 mem.get(i) 10
i 8 hand[0] 10 mem.get(i) 13
same 12 ?==? 4
same 12 ?==? 11
same 12 ?==? 5
same 12 ?==? 3
same 12 ?==? 7
same 12 ?==? 6
same 12 ?==? 2
i 0 hand[0] 3 mem.get(i) 6
i 1 hand[0] 3 mem.get(i) 15
i 2 hand[0] 3 mem.get(i) 4
i 3 hand[0] 3 mem.get(i) 21
i 4 hand[0] 3 mem.get(i) 1
i 5 hand[0] 3 mem.get(i) 10
i 6 hand[0] 3 mem.get(i) 13
i 7 hand[0] 3 mem.get(i) 3
same 11 ?==? 11
same 11 ?==? 5
same 11 ?==? 3
same 11 ?==? 7
same 11 ?==? 6
same 11 ?==? 2
same 11 ?==? 12
i 0 hand[0] 0 mem.get(i) 15
i 1 hand[0] 0 mem.get(i) 4
i 2 hand[0] 0 mem.get(i) 21
i 3 hand[0] 0 mem.get(i) 1
i 4 hand[0] 0 mem.get(i) 10
i 5 hand[0] 0 mem.get(i) 13
i 6 hand[0] 0 mem.get(i) 3
i 7 hand[0] 0 mem.get(i) 23
same 7 ?==? 5
same 7 ?==? 3
same 7 ?==? 6
same 7 ?==? 2
same 7 ?==? 12
same 7 ?==? 2
i 0 hand[0] 1 mem.get(i) 4
i 1 hand[0] 1 mem.get(i) 21
i 2 hand[0] 1 mem.get(i) 1
i 3 hand[0] 1 mem.get(i) 10
i 4 hand[0] 1 mem.get(i) 13
i 5 hand[0] 1 mem.get(i) 3
i 6 hand[0] 1 mem.get(i) 23
i 7 hand[0] 1 mem.get(i) 1
i 8 hand[0] 1 mem.get(i) 13
same 10 ?==? 7
same 10 ?==? 6
same 10 ?==? 2
same 10 ?==? 12
same 10 ?==? 2
same 10 ?==? 7
same 10 ?==? 2
i 0 hand[0] 16 mem.get(i) 1
i 1 hand[0] 16 mem.get(i) 10
i 2 hand[0] 16 mem.get(i) 13
i 3 hand[0] 16 mem.get(i) 3
i 4 hand[0] 16 mem.get(i) 23
i 5 hand[0] 16 mem.get(i) 1
i 6 hand[0] 16 mem.get(i) 13
i 7 hand[0] 16 mem.get(i) 16
i 8 hand[0] 16 mem.get(i) 3
same 1 ?==? 2
same 1 ?==? 12
same 1 ?==? 2
same 1 ?==? 7
same 1 ?==? 2
same 1 ?==? 10
same 1 ?==? 12
i 0 hand[0] 18 mem.get(i) 13
i 1 hand[0] 18 mem.get(i) 3
i 2 hand[0] 18 mem.get(i) 23
i 3 hand[0] 18 mem.get(i) 1
i 4 hand[0] 18 mem.get(i) 13
i 5 hand[0] 18 mem.get(i) 16
i 6 hand[0] 18 mem.get(i) 3
i 7 hand[0] 18 mem.get(i) 18
i 8 hand[0] 18 mem.get(i) 12
same 6 ?==? 2
same 6 ?==? 7
same 6 ?==? 2
same 6 ?==? 10
same 6 ?==? 12
same 6 ?==? 1
same 6 ?==? 8
i 0 hand[0] 10 mem.get(i) 23
i 1 hand[0] 10 mem.get(i) 1
i 2 hand[0] 10 mem.get(i) 13
i 3 hand[0] 10 mem.get(i) 16
i 4 hand[0] 10 mem.get(i) 3
i 5 hand[0] 10 mem.get(i) 18
i 6 hand[0] 10 mem.get(i) 12
i 7 hand[0] 10 mem.get(i) 10
i 8 hand[0] 10 mem.get(i) 13
same 4 ?==? 2
same 4 ?==? 10
same 4 ?==? 12
same 4 ?==? 1
same 4 ?==? 8
same 4 ?==? 6
same 4 ?==? 2
i 0 hand[0] 8 mem.get(i) 13
i 1 hand[0] 8 mem.get(i) 16
i 2 hand[0] 8 mem.get(i) 3
i 3 hand[0] 8 mem.get(i) 18
i 4 hand[0] 8 mem.get(i) 12
i 5 hand[0] 8 mem.get(i) 10
i 6 hand[0] 8 mem.get(i) 13
i 7 hand[0] 8 mem.get(i) 8
i 8 hand[0] 8 mem.get(i) 3
same 4 ?==? 12
same 4 ?==? 1
same 4 ?==? 8
same 4 ?==? 6
same 4 ?==? 2
same 4 ?==? 4
same 4 ?==? 12
i 0 hand[0] 6 mem.get(i) 3
i 1 hand[0] 6 mem.get(i) 18
i 2 hand[0] 6 mem.get(i) 12
i 3 hand[0] 6 mem.get(i) 10
i 4 hand[0] 6 mem.get(i) 13
i 5 hand[0] 6 mem.get(i) 8
i 6 hand[0] 6 mem.get(i) 3
i 7 hand[0] 6 mem.get(i) 6
i 8 hand[0] 6 mem.get(i) 10
same 7 ?==? 8
same 7 ?==? 6
same 7 ?==? 2
same 7 ?==? 4
same 7 ?==? 12
same 7 ?==? 4
same 7 ?==? 6
i 0 hand[0] 11 mem.get(i) 12
i 1 hand[0] 11 mem.get(i) 10
i 2 hand[0] 11 mem.get(i) 13
i 3 hand[0] 11 mem.get(i) 8
i 4 hand[0] 11 mem.get(i) 3
i 5 hand[0] 11 mem.get(i) 6
i 6 hand[0] 11 mem.get(i) 10
i 7 hand[0] 11 mem.get(i) 11
i 8 hand[0] 11 mem.get(i) 3
same 7 ?==? 2
same 7 ?==? 4
same 7 ?==? 12
same 7 ?==? 4
same 7 ?==? 6
same 7 ?==? 12
i 0 hand[0] 11 mem.get(i) 13
i 1 hand[0] 11 mem.get(i) 8
i 2 hand[0] 11 mem.get(i) 3
i 3 hand[0] 11 mem.get(i) 6
i 4 hand[0] 11 mem.get(i) 10
i 5 hand[0] 11 mem.get(i) 11
i 6 hand[0] 11 mem.get(i) 3
i 7 hand[0] 11 mem.get(i) 11
i 8 hand[0] 11 mem.get(i) 14
same 8 ?==? 12
same 8 ?==? 4
same 8 ?==? 6
same 8 ?==? 7
same 8 ?==? 12
same 8 ?==? 7
same 8 ?==? 5
i 0 hand[0] 12 mem.get(i) 3
i 1 hand[0] 12 mem.get(i) 6
i 2 hand[0] 12 mem.get(i) 10
i 3 hand[0] 12 mem.get(i) 11
i 4 hand[0] 12 mem.get(i) 3
i 5 hand[0] 12 mem.get(i) 11
i 6 hand[0] 12 mem.get(i) 14
i 7 hand[0] 12 mem.get(i) 12
i 8 hand[0] 12 mem.get(i) 9
same 8 ?==? 6
same 8 ?==? 7
same 8 ?==? 12
same 8 ?==? 7
same 8 ?==? 5
same 8 ?==? 9
i 0 hand[0] 12 mem.get(i) 10
i 1 hand[0] 12 mem.get(i) 11
i 2 hand[0] 12 mem.get(i) 3
i 3 hand[0] 12 mem.get(i) 11
i 4 hand[0] 12 mem.get(i) 14
i 5 hand[0] 12 mem.get(i) 12
i 6 hand[0] 12 mem.get(i) 9
i 7 hand[0] 12 mem.get(i) 12
i 8 hand[0] 12 mem.get(i) 15
same 10 ?==? 12
same 10 ?==? 7
same 10 ?==? 5
same 10 ?==? 8
same 10 ?==? 9
same 10 ?==? 8
same 10 ?==? 11
i 0 hand[0] 16 mem.get(i) 3
i 1 hand[0] 16 mem.get(i) 11
i 2 hand[0] 16 mem.get(i) 14
i 3 hand[0] 16 mem.get(i) 12
i 4 hand[0] 16 mem.get(i) 9
i 5 hand[0] 16 mem.get(i) 12
i 6 hand[0] 16 mem.get(i) 15
i 7 hand[0] 16 mem.get(i) 16
i 8 hand[0] 16 mem.get(i) 22
same 10 ?==? 5
same 10 ?==? 8
same 10 ?==? 9
same 10 ?==? 8
same 10 ?==? 11
same 10 ?==? 10
same 10 ?==? 8
i 0 hand[0] 5 mem.get(i) 14
i 1 hand[0] 5 mem.get(i) 12
i 2 hand[0] 5 mem.get(i) 9
i 3 hand[0] 5 mem.get(i) 12
i 4 hand[0] 5 mem.get(i) 15
i 5 hand[0] 5 mem.get(i) 16
i 6 hand[0] 5 mem.get(i) 22
i 7 hand[0] 5 mem.get(i) 5
i 8 hand[0] 5 mem.get(i) 2
same 5 ?==? 9
same 5 ?==? 8
same 5 ?==? 11
same 5 ?==? 10
same 5 ?==? 8
same 5 ?==? 10
same 5 ?==? 3
i 0 hand[0] 14 mem.get(i) 9
i 1 hand[0] 14 mem.get(i) 12
i 2 hand[0] 14 mem.get(i) 15
i 3 hand[0] 14 mem.get(i) 16
i 4 hand[0] 14 mem.get(i) 22
i 5 hand[0] 14 mem.get(i) 5
i 6 hand[0] 14 mem.get(i) 2
same 11 ?==? 9
same 11 ?==? 8
same 11 ?==? 11
same 11 ?==? 10
same 11 ?==? 8
same 11 ?==? 10
same 11 ?==? 3
ArrayIndexOutOfBoundsException: 14