0

I wrote an Alpha-Beta pruning from Wikipedia. I am trying to write a connect-four AI. The function should return column number, then my main function makes a move.

1 Answers1

3

Your problem is in this line I believe:

if(temp[i][column-1] == '0')

temp is an int array. You should compare just 0. '0' means the character 0, which Java will interpret as an integer (48). Anyways, you should use this:

if(temp[i][column-1] == 0)
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
  • 1
    I would go a step farther, this code have never compiled. – Ralph Dec 16 '12 at 17:10
  • That's right, java and it's type safe features... Edited appropriately. – PearsonArtPhoto Dec 16 '12 at 17:11
  • Java will actually let you do direct comparisons/assignments between ints and chars because chars are really just ints interpreted in a special way. See the Character class javadocs for details. Btw, I'm not saying your answer is wrong on the whole, just pointing out that small mistake. – Mansoor Siddiqui Dec 16 '12 at 17:20
  • code is working now but it's returns column number only 1 and 2. is this problem in minimax or my evalution function? – John Smith Dec 16 '12 at 17:23