April 12th, 2013, 01:56 PM
Diagonal grid algorithm (for tic-tac-toe-like program)
NOTE: this code is within an actionPerformed block, which uses a nested for loop to iterate through the entire 19x19 grid to find which button fired the source. i and j correspond to buttonArray[i][j]. Also, the character array is simply a record of the buttonArray's contents.
EDIT: wow, great example of copy+pasting gone wrong. I'm an idiot (I just set l to <0, so of course an if l>=0 block won't execute).
I'm still getting the math wrong for the second diagonal algorithm (BL-TR), which is what I was struggling with the most before getting the previous errors, so any help on that is appreciated too lol. Sorry this is my second topic this week that was just me being an idiot and solving a couple hours later (end of term is a stressful time for students i suppose).
BL-TR @ pastebin /dL6WTH76 (tic-tac-toe but 19x19 grid and requires 5 in a row to win)