# Gameboard, next position on a path

I'm creating a game with a sort of 'Candy Land' mechanic, but with dice... Roll a dice, move piece as many spaces as the dice rolled. I need to get the player's current position and define its next position (pseudo :: nextpos = currentPos + 1; moveTo nextPos x diceRoll). I thought the best way would be defining the gameboard in an array, and nextPos would basically be the next key in the array, but I'm still unsure how to do that, or even if it's the best solution. Any guidance is appreciated.

Edit :: I'm using JavaScript in unity. The path traveled is linear, so where I'm really needing help is how to 'go to' the next position in an array from the current position. I'm not sure how to code 'this key in the array is the current position. this key + 1 is the next position, and the next position x diceroll is where the piece should move to'.

If the path is strictly linear, then an array would likely be a reasonable solution. If you need help with the details, let us know what language you're using, and what part of the implementation you need help with. (You can edit your original post and add this information.)

The path traveled is linear, so where I'm really needing help is how to 'go to' the next position in an array from the current position.

It's difficult to explain, but it should be very straightforward. In theory, each array variable holds a position on the game board, correct?

And each array space is numbered.

I'm pretty sure that all you have to do is, at the start, assign your game piece's position to, for instance, BoardSquare[0], where array slot 0 is the game board starting place (I'm also explaining in C# terms as I don't know Javascript, sorry about that). Also, keep a variable inside the game piece that "remembers" which board square array slot it's occupying. Let's say it's called myCurrentSquare.

From there, it's extremely simple. If you roll a 6, you'd tell the piece to move itself to BoardSquare[(myCurrentSquare + 6)]. It should then move to the 6th array vector.

Does that make sense?