Skip to content
← Back to Community
how to make it move position?
Profile icon
[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:

Screen Shot 2020-04-18 at 1.29.13 PM

how do I change the position?

Answered by lynnlo [earned 5 cycles]
View Answer
Voters
Profile icon
DraydenAdams
Profile icon
UmidQulameliyev
Profile icon
ToxicBarnacles
Profile icon
lynnlo
Comments
hotnewtop
Profile icon
[deleted]
Profile icon
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.

Profile icon
[deleted]
Profile icon
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.

Profile icon
[deleted]

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

Profile icon
[deleted]
Profile icon
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.

Profile icon
[deleted]

@tharlynnhtetong ok thanks!

Profile icon
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.

Profile icon
[deleted]

@tharlynnhtetong ok and THANKS!!!!!!

Profile icon
[deleted]

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

Profile icon
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.

Profile icon
[deleted]

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

Profile icon
[deleted]

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

Profile icon
[deleted]

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

Profile icon
lynnlo

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

Profile icon
[deleted]

@tharlynnhtetong Yes but where do you put it?

Profile icon
lynnlo

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

Profile icon
[deleted]

@tharlynnhtetong OK Thanks!!