# Need help with moving pawn piece on board

**URL:** <https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170>\
**Category:** Questions about Thunkable X\
**Created:** [May 30, 2021, 6:22am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170 "2021-05-30T06:22:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 30, 2021, 6:22am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/1 "2021-05-30T06:22:38Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/1/31fcf234828ad8c12bfda412a71670a89c780630.png)  
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:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/b/8bc5aee91f9bc1b51b7ca4c31833a36be2f3cde0.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/d/cd6f141d4414dfbaadad8290eb1c4c6e86306c1a.png)

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

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 30, 2021, 6:59am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/2 "2021-05-30T06:59:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 30, 2021, 7:04am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/3 "2021-05-30T07:04:01Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 30, 2021, 7:35am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/4 "2021-05-30T07:35:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 30, 2021, 7:40am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/5 "2021-05-30T07:40:04Z")

</div>

But wouldn’t I be moving backwards from 100?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 30, 2021, 7:42am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/6 "2021-05-30T07:42:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 30, 2021, 7:43am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/7 "2021-05-30T07:43:25Z")

</div>

Yeah, it does.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/2/222e4fbf39ef39753c2f12d5cd968a47b059fac6.jpeg)

Exactly like this image I found on the web.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 30, 2021, 7:45am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/8 "2021-05-30T07:45:40Z")

</div>

Okay then my suggestion should work.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 30, 2021, 7:46am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/9 "2021-05-30T07:46:47Z")

</div>

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.**

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 30, 2021, 9:51am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/10 "2021-05-30T09:51:13Z")

</div>

Cool project!

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 30, 2021, 11:09am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/11 "2021-05-30T11:09:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 31, 2021, 4:54am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/12 "2021-05-31T04:54:01Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/2/222e4fbf39ef39753c2f12d5cd968a47b059fac6.jpeg)

This is what my table looks like:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/f/4f67b25520c14b8fea6824d95661c231081eb8c3.png)  
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:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/e/ae55534ee86b9e94cf2230abc4b85419661f8cd5.png)

Yet, I am unable to get the cells in their correct positions.  
For example:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/d/3dd1484867caccefd900ba4ee7e201397b1291d9.png)  
In this row, I have created a snake which should start at button 4, which is 97. But when I live test,

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/4/c43dffe8169bc8ec2dd545c7ca9a578eb0b14415.png)

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 31, 2021, 5:07am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/13 "2021-05-31T05:07:40Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 31, 2021, 5:09am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/14 "2021-05-31T05:09:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 31, 2021, 5:09am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/15 "2021-05-31T05:09:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 31, 2021, 5:11am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/16 "2021-05-31T05:11:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 31, 2021, 5:13am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/17 "2021-05-31T05:13:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 31, 2021, 5:14am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/18 "2021-05-31T05:14:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 31, 2021, 5:17am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/19 "2021-05-31T05:17:37Z")

</div>

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:

 ![Screen Shot 2021-05-30 at 10.14.56 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/2/02d96e35fbec08482fb4cfd2ec47a6c4148803e4.png)

If you look back at [this post](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/4), 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.

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [May 31, 2021, 5:19am UTC](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170/20 "2021-05-31T05:19:33Z")

</div>

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

[Next page](https://community.thunkable.com/t/need-help-with-moving-pawn-piece-on-board/1316170.md?page=2)
