Need help with moving pawn piece on board

In a board game app I’m making (Shakes and Adders), I want to move the user’s pawn piece/playing counter by the number the player shakes (if the player shakes 3 then he/she moves from 1 to 4). But my board game’s layout is slightly different, and I’m using the create and clone blocks to make it. This is what my board looks like:


Because of this layout, ‘cell 1’ is actually referenced as the 91st cell, and 99 is referenced as the 2nd cell.

So, it doesn’t act as expected when I shake the dice.
Here’s my code:

Any suggestions on how to move the pawn/counter correctly?
Thanks

PS: I can share the project link in a PM if required.

The math for this is easy if the rows count like this:

100 99 … 92 91
90 89 … 82 81
80 79 … 72 71

But because you flipped every other row, I think it’s a bit trickier. Still possible but a challenge.

1 Like

I flipped every row so I got the snake-like moving effect that you get on Snakes and Ladders (oh, and I didn’t misspell my app name).

One way to do this, I think, is to create a list of the cell positions in the order you would reach them if traveling from 1 to 2 to 3, etc. all the way to 100:

91,92,93,94,95,96,97,98,99,100,90,89,87, etc.

You can do this with the make list from text with delimiter "," block.

When you start the game, you are at index=1 so you get list item #1’s value and use that for the cell number (91). When you shake and get a value, you take the current index (which would be 1 if you’re just starting the game) and add the shake value to it. Then you take the list item’s value at that new index.

Here’s an example. Let’s say you’re on #18 and you shake a 4. You should end up on #22, right? The way that would get calculated is to take the index where the player currently is (18) and add 4 to it to get an index of 22. Then you get the 22nd item from the list which is the value 72 and you move the pawn to that cell.

2 Likes

But wouldn’t I be moving backwards from 100?

Why? Doesn’t your game start with the pawn at the bottom-left cell that displays a 1?

1 Like

Yeah, it does.
image

Exactly like this image I found on the web.

Okay then my suggestion should work.

1 Like

I’m probably not understanding it well, but if I start at #91 (cell written as 1), then I gradually moved forward 10 steps, then how would I go to #101?

Edit: Really sorry, I got it now. Thanks for the help! I’ll try that and let you know if it works.

1 Like

Cool project!

1 Like

Thanks! I’ll share it once I’m done (if I’m ever done).

This is a question regarding the same app. If it’s alright to post it here, then cool, but if it’s not, I’ll create a new topic.

I needed to map out the positions of my snakes/ladders using a Data Table, specify the type (snake or ladder), the button position where they are (if there’s a snake at 99, then I write 2 in this area) and where they go to (if the snake at 99 goes to 1, then I write 91 in this area). I am 100% sure that my data is correct.
I referenced the start and end of snakes and ladders with this image:
image

This is what my table looks like:
image
and so on.

If a cell is the start of a ladder, I want to make it brown, and if it’s the head of a snake, I want to make it poisonous green.
This is my code for that:

Yet, I am unable to get the cells in their correct positions.
For example:
image
In this row, I have created a snake which should start at button 4, which is 97. But when I live test,

Do you have any idea on what the problem is?
Thanks!

My first thought is that if you used my method of a list, you already have the “step” numbers (1,2,3, etc.) as list item #s and the cell positions for each one (91, 92, 93, etc.) as list item values. So you would just make a second list for all of the chutes (snakes) and ladders. It would look like this:

item #     value
1           63
2            2
3            3
4           87
5            5
...        ...

Then, when you move to a new “step” such as #2, you check the second list to see where you should teleport to. Since it’s also 2, you don’t move anywhere and you take your next turn. (In this example, you don’t have to enter 2 and 3 and 5… you can leave those blank or make them all zero… it doesn’t really matter as long as you have a clear rule). When you move to step #4, you check the second list and since the 4th item’s value is 87, that’s where you move to next.

1 Like

That also lets you color code your snakes and ladders because you can just check to see if the value of an index (item #) in the first list is <, >, or = to the same indexed value in the second list. That will tell you if you’re moving up or down.

1 Like

That sounds great! Thanks for the detailed explanation. I’m trying that right now.

By item #, do you mean the text on that button, or the position of that button?

When I say “item #”, I’m referring to the list index. So the 18th item in the list has an index of 18. That’s its item #. But it’s also tied to the displayed number on your tiles.

1 Like

Ah, ok. So basically item # 3 would be 98?

No. Because tile 3 in your screenshot is the 93rd tile from the top-left. So it’s value should be 93 in the first list. Here’s how tile 1 works:

If you look back at this post, the 3rd value in the list is 93 because that’s where you find the 3 tile which is the 3rd step of your game if you start at the 1 tile.

1 Like

Ohhh I get it now! Thanks, the picture really helped!

1 Like