can someone help me to frame this code I do not know howto frame it.
In python
Develop a program that follows the rules of Farkle as described.On program start-up, it shall display the rules to the user as readfrom a text file submitted with the program. The user can then setup the game by entering the number of players. Any number below twoshall ask the user to add more players. Once gameplay has startedbased on the game rules, there are a few main pieces to address.Rolling the die should be performed by randomly generating the sideof the die displayed for each of the six using a random numbergenerator. After each player’s roll, calculate the score for theroll based on the user’s selection for scoring. Validate that thescoring option applies to the dice and determine if a subsequentrole is allowed. Continue playing until a player reaches 10,000points. Display a message to the game winner.
Farkle is a dice game that is multi-player with aminimum of two players, And the maximum will be sixplayers (User has to choose). The goal isto reach 10,000 points first. This article statesthe rules of Farkle as follows:
Points table :
5’s = 50 points
1’s= 100 points
1,1,1 = 300 points
2,2,2 = 200 points
3,3,3 = 300 points
4,4,4 = 400 points
5,5,5 = 500 points
6,6,6 = 600 points
Four of a Kind = 1,000 points
Five of a Kind = 2,000 points
Six of a Kind = 3,000 points
A Straight of 1-6 = 1,500 points
Three Pairs = 1,500 points
Four of a Kind + a Pair = 1,500
Two sets of Three of a Kind = 2,500
The Play
● The first player rolls all six dice at the same time and setsaside any “point dice” (1’s, 5’s, or three of a kind) that appear.At this point, the player has the option to continue to roll theremaining dice to collect even more points, or stop and keep anypoints acquired.
● A Farkle occurs when the dice are rolled and no point diceappear. At this point the player loses all the point dice he/she/ithas collected during that turn, and the play passes to the playerto the left. No points are recorded for that player’s turn.
● If a player decides not to risk rolling a Farkle thenhe/she/it can stop rolling and the play passes to the player to theleft. Any points collected during that turn are then recorded.
● If, in the course of one turn, all six dice become point diceand are set aside, the player must roll all six dice at least onemore time, before stopping and keeping the points collected.
Entering the Game
● In order for a player to initially enter the game, (and recordpoints), he/she must continue to roll until at least 500points are collected during one turn. Once the playerofficially enters the game, the points are recorded and that playermay stop rolling at any time during future turns. Sometimes itmight take many turns before a player can get started.
● Secret Strategy: All point dice do not have to be set aside.If you roll a 1 and a 5, sometimes it may be strategic to keep the1 and roll the 5 again with the rest of the non-point dice. Thismay give you a better chance of rolling a three of a kind. But, atleast one point die must be set aside after each roll.
Winning
In order to win, a player must get 10,000 pointsrecorded.
————————————————————————————————————————————————————————
So far I have done some code but not getting output,someone has to do some correction in it.
Please see the code below
————————————————————————————————————————————————————————
—————————————————————————————————————————————————————
import random
def throwdice(l):
g = []
for x in l:
if(x==0):
g.append(random.randint(1,6))
else:
g.append(x)
return g
def evaluate(l):
s = 0
c = [l.count(x) for x in range(1,7)]
if 4 in c:
s = 1000
elif 5 in c:
s = 2000
elif 6 in c:
s = 3000
elif c == [1,1,1,1,1,1] or c.count(2)==3 or (4 in c and 2 inc):
s = 1500
elif c.count(3)==2:
s = 2500
elif c.count(3)==1:
x = c.index(3)
s = (x+1)*100
if x==0:
s = 300
if c[0]<3:
s = s+100*c[0]
if c[4]<3:
s = s+50*c[4]
return s
def play():
n = 0
print(“Lets play Farkle”)
print(”’
Farkle is a dice game that is multiplayer (2 to 6 gamers)!
Whoever reaches 10000 points first wins
Rules:
5s : 50 points
1s : 100 points
2,2,2 : 200 points
3,3,3 : 300 points
4,4,4 : 400 points
5,5,5 : 500 points
6,6,6 : 600 points
Four of a kind : 1000 points
Five of a kind : 2000 points
Six of a kind : 3000 points
A straight 1 to 6 : 1500 points
Four of a kind + Pair: 1500 points
Two sets of Three of a Kind = 2500
”’)
while n<2 or n>6:
n = int(input(“Enter no. of players: “))
score = [0]*n
while True:
for i in range(n):
print(“Chance goes to player”+str(i+1))
l = [0,0,0,0,0,0]
while True:
l = throwdice(l)
e = evaluate(l)
print(l)
if e==0:
score[i]=0
print(“Farkle”)
break
else:
print(“Score in current throw: “+str(e))
ch=0
while ch!=1 and ch!=2:
ch = int(input(“Enter 1 to rethrow or 2 to pass “))
if ch==1:
c = [l.count(x) for x in range(1,7)]
m=-1
if 3 in c:
m = c.index(3)
for x in range(1,6):
if x!=m or x!=5:
l[x]=0
if 0 not in l:
print(“You have to pass”)
score[i] = score[i]+e
print(“You score is: “+str(score[i]))
print(“Scoreboard “+str(score))
break
elif ch==2:
score[i] = score[i]+e
print(“You score is: “+str(score[i]))
print(“Scoreboard “+str(score))
break
if score[i]>=10000:
print(“Player”+str(i+1)+” is the winner”)
ch = ‘n’
while ch!=’y’ and ch!=’n’:
ch = input(“Want to play again? (y/n) “)[0].lower()
if ch==’y’:
score = [0]*n
break
elif ch==’n’:
print(“Thanks for playing”)
return
play()
Expert Answer
Answer to can someone help me to frame this code I do not know how to frame it. In python Develop a program that follows the rules…