Don't you want to swap the two tiles? You are swapping 2 new integers that happen to hold the tile values.
Get rid of those 2 extra integers and simply use the tiles themselves in your swap code.
Let's say I wanted to swap 2 values:
int hold = firstValue;
firstValue = secondValue;
secondValue = hold;
In your case
board[d-1][d-3] so simply use that (and not a copy of it like you are currently doing) etc.
So, why can't you swap the integers one_spot and two_spot that you created? Here's why.
Think about your program's memory. You've declared a global array called
board and then populated the values in the array. That array lives in memory.
Now, you declare an integer called
one_spot. That integer also lives in memory (at its own address). You then assign the value of
one_spot to the value of
board[d-3][d-2]. So if board[d-3][d-2] is
1, then one_spot will now equal
1. But it's still stored at its own place in memory. It has no connection to the board. Now you do the same with
two_spot. Now you have 2 integers both stored in memory. If you swap them, you are swapping the values at those 2 addresses. The board array is untouched. This is why you need to swap the board tiles themselves and not the copies you've made.
Later on in the course, you'll learn more about memory management and pointers and at that stage, this might become clearer.
In addition, looks like you are printing the board? Your
init() function should only be setting the initial values of the tiles. The
draw() function then prints the board to the screen.