I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making
Every row in your 2D array is placed end to end in your 1D array. i
gives which row you are in, and j
gives the column (how far into that row). so if you are in the ith
row, you need to place i
complete rows end to end, then append j
more onto that to get your single array index.
So it will be something like
singleDimIndex = array[0].length * i + j