$GREEDを作ってみた

#作ってみてどうだった？

別に難しいことはしておらず、むしろ単純なほどだったのですがバグ潰しが大変でした。
今までのコーディング経験の中で、…一番簡単だったと思います。まぁそもそも完成させたものが少ないので。

$GREEDのルールについてはプログラムと関係ないので、割愛します。

#コード

```Python
import random

def game_set():
	number_of_player = ""

	while not isinstance(number_of_player,int):
		i = input("プレイヤー数:")
		if len(i)==0:
			continue
		if len(set(tuple(i)) - {"0","1","2","3","4","5","6","7","8","9"}):
			print("数字を入力してください。")			
		else:
			number_of_player = int(i)

	player_names = []
	for i in range(number_of_player):
		n = input("PL" + str(i+1) + "のプレイヤー名:")
		if n == "":
			n = "PL" + str(i+1)
		player_names.append(n)

	player_point_dates = {name:0 for name in player_names}
	return player_names,player_point_dates

def roll(number_of_dice):
	return [random.randint(1,6) for i in range(number_of_dice)]

def search_role(rolled_dice):
	#role (six of a kind,$GREeD,DDDD,$$$,GGG,RRR,EEE,eee,D,G)
	roles = [0,0,0,0,0,0,0,0,0,0]
	roll=[0,0,0,0,0,0]
	for i in rolled_dice:
		roll[i-1] += 1
	
	if len(set(rolled_dice)) == 1 and len(rolled_dice) == 6:
		roles[0] += 1
	elif len(set(rolled_dice)) == 6:
		roles[1] += 1
	else:
		roles[4] = roll[1]//3
		roles[9] = roll[1]%3
		roles[2] = roll[5]//4
		roles[8] = roll[5]%4
		roles[3] = roll[0]//3
		roles[5] = roll[2]//3
		roles[6] = roll[3]//3
		roles[7] = roll[4]//3
	role = sum(roles)
	return role,roles

def one_round(PL="",point = 0):
	#six of a kind
	#$GREeD
	
	#DDDD #$$$ #GGG #RRR #EEE #eee #D #G
	PL = PL + ":"

	name_of_role = ("six of a kind","$GREeD","DDDD","$$$","GGG","RRR","EEE","eee","D","G")
	dice_of_role = (6,6,4,3,3,3,3,3,1,1)
	point_of_role = (5000,1000,1000,600,500,400,300,300,100,50)
	
	dice = 6
	conv = {1:"$",2:"G",3:"R",4:"E",5:"e",6:"D"}
	vnoc = {"$":1,"G":2,"R":3,"E":4,"e":5,"D":6}
	while True:
		dice_roll = roll(dice)
		print(PL," ".join([conv[i] for i in dice_roll]))
		role,roles = search_role(dice_roll)

		if not role:#Break?
			print(PL,"GREED OUT")
			print(PL,"0")
			print(PL,"break!")
			input("=====oh!=====")
			break


		if dice == sum([i1 * i2 for i1,i2 in zip(dice_of_role,roles)]):#all?
			print(PL,"role:"," ".join([" ".join([i2]*i1) for i1,i2 in zip(roles,name_of_role)]))
			print(PL,"again!")
			point += sum([i1 * i2 for i1,i2 in zip(point_of_role,roles)])
			input(PL + " total: " + str(point)+"pt")
			print("=====")
			continue


		get = input(PL + " get:")
		if get == "all":
			point += sum([i1 * i2 for i1,i2 in zip(point_of_role,roles)])
			dice -= sum([i1 * i2 for i1,i2 in zip(dice_of_role,roles)])
			input(PL + " total: " + str(point)+"pt")
			print("=====")
		else:
			get = [vnoc[i] for i in get if i in ("$","G","R","E","e","D")][:7]
			get_ = []
			for i in get:
				if i in dice_roll:
					dice_roll.remove(i)
					get_.append(i)
			role,roles = search_role(get_)
			if role:
				point += sum([i1 * i2 for i1,i2 in zip(point_of_role,roles)])
				dice -= sum([i1 * i2 for i1,i2 in zip(dice_of_role,roles)])
			input(PL + " total:" + str(point)+"pt")
			print("=====")


		while True:
			again = input(str(PL) + " roll dice again?(y/n):")
			if again in ["y","n"]:
				break
			else:
				print(PL,"write \"n\" or \"y\".")
		print("-----")
		if again == "n":
			break

	return point

def main():
	PLname,PLpoint = game_set()
	BREAK = None
	while True:
		for i in PLname:
			if i == BREAK:
				return PLname,PLpoint
			PLpoint[i] = one_round(i,PLpoint[i])
			
			print("==== player points ====")
			print(" ".join([":".join([str(i) for i in i]) for i in tuple(PLpoint.items())]))
			print("=======================")

			BREAK = ([i for i in tuple(PLpoint.keys()) if PLpoint[i] > 5000]+[None])[0]
	return PLpoint
main()
```

#main()関数は何のため？

自分でもわかりません…