Bones (sometimes called Farkle) is a multi-player game using 5 dice. Exact rules may vary, but this version scores 50 points for a 5, 100 points for a 1. Three of a kind scores 100 times the dice value (for example, three 3's is 300 points), and three 1's is 1000 points. Four of a kind scores twice the points as three of a kind. Five of a kind is rare, but doubles the points again (for example, three 2's is 200 points, four 2's is 400 points, and five 2's is 800 points. Straights are 1000 points. If you score with all the dice, you may roll all five dice again. First player to reach 1000 points wins.
""" Bones 1.1 - Written by Tom Fangrow, 5/1/2026 """
""" This python program playes the Bones dice game. """
""" Run the program when it's the computer's turn. """
""" It rolls 3 dice if score is less than 550. """
""" It never rolls two dice. """
import random
roll = [] # lists are a feature of Python, not a global variable
score = 0
standing_score = 550 # do not roll if score is higher than this
number_of_dice = 5
played = False
turn_end = False
def roll_dice(n):
""" this function rolls n six-sided dice """
global number_of_dice
roll.clear()
print("rolling", n, "dice")
for i in range(n):
roll.append(random.randint(1, 6)) # both ends included!
print(roll)
def check_straight():
""" This function checks for straights """
global score
global turn_end
global played
straight1 = [1, 2, 3, 4, 5]
straight2 = [2, 3, 4, 5, 6]
roll.sort()
if(roll == straight1 or roll == straight2):
print("I got a straight!")
played = True
score += 1000
print("Score =", score)
def check_five_of_a_kind():
""" This function checks for five of a kind. """
""" Chances are, it will never be called! """
global score
global turn_end
global number_of_dice
global played
for i in roll: # check dice in roll, not every possibility
if(roll.count(i) == 5):
n = i # remember the value of i
print("Five of a kind!")
print("Keeping five {n}\'s")
for j in range(5):
roll.remove(n)
number_of_dice -= 5
played = True
if(n == 1):
print("3000 Points!")
score += 3000
else:
score += 3 * n * 100
print("Score =", score)
def check_four_of_a_kind():
""" This function checks for four of a kind """
global score
global turn_end
global number_of_dice
global played
for i in roll: # check dice in roll, not every possibility
if(roll.count(i) == 4):
n = i # remember the value of i
print("Four of a kind!")
print(f"Keeping four {n}\'s")
for j in range(4):
roll.remove(n)
number_of_dice -= 4
played = True
if(n == 1):
print("2000 Points!")
score += 2000
else:
score += 2 * n * 100
print("Score =", score)
def check_three_of_a_kind():
""" This function checks for three of a kind """
global score
global turn_end
global number_of_dice
global played
for i in roll: # check dice in roll, not every possibility
if(roll.count(i) == 3):
n = i # remember the value of i
print("Three of a kind!")
print(f"Keeping three {n}\'s")
for j in range(3):
roll.remove(n)
number_of_dice -= 3
played = True
if(n == 1):
print("1000 Points!")
score += 1000
else:
score += n * 100
print("Score =", score)
def check_ones():
""" This function checks for ones """
global score
global turn_end
global number_of_dice
global played
if(roll.count(1)):
print("Keeping a 1")
roll.remove(1)
number_of_dice -= 1
played = True
score += 100
print("Score =", score)
def check_fives():
""" This function checks for fives """
global score
global turn_end
global number_of_dice
global played
if(roll.count(5)):
print("Keeping a 5")
roll.remove(5)
number_of_dice -= 1
played = True
score += 50
print("Score =", score)
""" This is the main program """
while(not turn_end and number_of_dice > 2 and score < standing_score):
roll_dice(number_of_dice)
played = False
if(number_of_dice == 5):
check_five_of_a_kind()
check_straight()
if(number_of_dice >= 4):
check_four_of_a_kind()
if(number_of_dice >= 3):
check_three_of_a_kind()
if(not played):
check_ones()
if(not played):
check_fives()
""" Manage the last two dice """
if(number_of_dice <= 2):
if(roll.count(1)):
print("Keeping a 1")
roll.remove(1)
number_of_dice -= 1
score += 100
print("Score =", score)
if(roll.count(1)):
print("Keeping a 1")
roll.remove(1)
number_of_dice -= 1
score += 100
print("Score =", score)
if(roll.count(5)):
print("Keeping a 5")
roll.remove(5)
number_of_dice -= 1
score += 50
print("Score =", score)
if(roll.count(5)):
print("Keeping a 5")
roll.remove(5)
number_of_dice -= 1
score += 50
print("Score =", score)
if(number_of_dice <= 0): # if all dice used
number_of_dice = 5
if(not played):
print("I boned out!")
turn_end = True
Back to Tom Fangrow's Home Page