# [Tutor] Help with Dice game

Lifeng Lin phillifeng at gmail.com
Tue Nov 11 01:15:53 CET 2014

```I am not familiar with the game, but maybe using "offense += 1" and
"defense += 1" to replace the corresponding "continue" would help?

On Mon, Nov 10, 2014 at 2:57 PM, <coryloghry at yahoo.com.dmarc.invalid> wrote:

>  Hello, I can not for the life of me figure out where I have gone wrong.
> I wrote the following code as a simulation for the table top game x-wing.
> It basically simulates dice rolls but the issue is the fact that every time
> I choose a number of dice to roll, they all hit.  None of them ever miss.
> Thank You.
>
> import random
> print("X-wing dice simulator")
> x = int(input("How many dice will the offensive player be rolling?\n"))
> y = int(input("How many dice will the defensive player be rolling?\n"))
> hits = 0
> crits = 0
> dodges = 0
> offense = 0
> defense = 0
> while offense < x:
>     odie = random.randint(1,8)
>     if odie <= 4:
>         hits = hits + 1
>         offense = offense + 1
>     if odie == 4:
>         crits = crits + 1
>         offense = offense + 1
>     else:
>         continue
> while defense < y:
>     ddie = random.randint(1,8)
>     if ddie <= 3:
>         dodges = dodges + 1
>         defense = defense + 1
>     else:
>         continue
> print("The offensive player lands", hits,"hits and", crits,"crits\n")
> print("The defensive player dodges", dodges, "hits\n")
> print("The offensive player deals", int((hits + crits) - dodges), "to the
> defensive player")
>
>
>
> Sent from Windows Mail
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141110/431434fd/attachment-0001.html>
```

More information about the Tutor mailing list