Ask coding questions

← Back to all posts
how to make it move position?
[deleted]

when ever I roll a number for example 5 I want it ti look like this:

p1's board [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
p2's board [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]

but it shows this instead:

how do I change the position?

Answered by lynnlo [earned 5 cycles]
View Answer
Voters
UmidQulameliyev
ToxicBarnacles
lynnlo
Comments
hotnewtop
[deleted]

@tharlynnhtetong why does it have this?

lynnlo

@blackjkl
Player two has no 1 values because you've set it to 2.
Replace p2board[p2board.index(1)] = 0 with p2board[p2board.index(2)] = 0 and p2board[p2r] = 1 with p2board[p2r] = 2.

[deleted]
lynnlo

@tharlynnhtetong
If you don't know what I'm doing, I'm finding the 1 in the list and setting it to 0 then I'm finding the place of the role and setting to 1 or 2 depending on the player.

[deleted]

@blackjkl one more thing, how do you make the most recent position change to a 0?

[deleted]

@tharlynnhtetong but it says this:

lynnlo

@blackjkl p1board[p1board.index(1)] = 0 should already have changed it.

Edit : I've looked at the code and it does not use function loops I'll reply with a better answer soon.

[deleted]

@tharlynnhtetong ok thanks!

lynnlo

@blackjkl

The lines p1board[0] = p1board[int(str(p1r))] + p1board[0] and p2board[0] = p2board[int(str(p2r))] + p2board[0] are setting the first instance of the list to 1 and two respectively. Remove those to get the desired output.

[deleted]

@tharlynnhtetong ok and THANKS!!!!!!

[deleted]

@tharlynnhtetong one more another thing, how do you make it repeat until someone wins?

lynnlo

@blackjkl replace if p1board == p1board[20]: slowprint("p1 wins!!!") elif p2board == p2board[20]: slowprint("p2 wins!!")
with if 1 == p1board[20]: slowprint("p1 wins!!!") elif 2 == p2board[20]: slowprint("p2 wins!!")

You seem to be new at python. You should learn the language fully with online resources. There are many free site that can help you out with python, just search "learn python" in google and you'll find a lot of resources.

[deleted]

@tharlynnhtetong ok I will but it still the same thing. WHY?

[deleted]

@blackjkl you no answer. ok I wait for someone to answer

[deleted]

@blackjkl and why do you like? it isn't that good

lynnlo

Do p1board[p1board.index(1)] = 0 and p1board[p1r] = 1.

[deleted]

@tharlynnhtetong Yes but where do you put it?

lynnlo

@blackjkl
After Player 1 rolls and before the scores are shown.

[deleted]

@tharlynnhtetong OK Thanks!!