DDR爱好者之家 Design By 杰米
运行方法:
1. 打开python2 IDLE;
2. 输入 from craps import *
3. 按提示输入运行命令。例如,玩游戏就输入play();查看余额就输入check_bankroll();
自动玩看胜率就输入auto()
craps.py
import random point_set = False bet = 10 bankroll = 1000 sim_win = 0 sim_lose = 0 print """ Welcome to the 'Seven Star' casino! You are playing craps now, your started bankroll is '$1000', the started bet is '$10', command: play(): "Rolling the dices" check_bankroll(): "Checking your current balance" all_in(): Showing "hand" set_bet(): "Setting a new bet" game(): "Check your game status" auto(): "It can be played automatically for you until reach a specific bankroll" """ def roll(): d1 = random.randrange(1,7) d2 = random.randrange(1,7) print "You rolled", d1, "+", d2, "=", d1+d2 return d1 + d2 def play(): global point_set, bankroll, point global sim_win, sim_lose if bankroll < bet: print "Sorry, you can't play since you don't have enough money!" print """Do you wanna get more money""" choice = raw_input("") if choice == str(1): money = raw_input("How much do you wanna get") bankroll += int(money) print "Your current bankroll is: ", bankroll if choice == str(2): print "Thanks for playing! See you next time!" else: if not point_set: print print "New game. Your bet is: ", bet # for the first roll r = roll() if not point_set: if r in (7, 11): bankroll += bet sim_win += 1 print "Congratz! You Won! Your bankroll is: ", bankroll elif r in (2, 3, 12): bankroll -= bet sim_lose += 1 print "Oops! You lost! Your bankroll is: ", bankroll else: point = r point_set = True print "Your point is", "[", point, "]" # for subsequence rolls elif r == 7: bankroll -= bet sim_lose += 1 point_set = False print "You crapped out! Your bankroll is: ", bankroll elif r == point: bankroll += bet sim_win += 1 point_set = False print "You made your point! Your bankroll is: ", bankroll def set_bet(inp): global bet, bankroll, point_set print if point_set: print "WARNING!" print "The game has started, you will lose half of your bet if resetting your bet!" prompt = raw_input(""" 1: Yes, I am wanna reset my bet! 2: No, I don't wanna reset my bet! """) if prompt == "1": point_set = False bankroll -= bet/2 print "Forfeiting current bet. Your bankroll is: ", bankroll else: pass bet = int(inp) print "New bet size is: ", bet def all_in(): set_bet(bankroll) def check_bankroll(): global bet print "Your current balance is: ", bankroll def game(): total = sim_win + sim_lose percent = float(sim_win)/total * 100 print "So far, the games that you have been playing are: ", total print "Won ", sim_win print "Lost ", sim_lose print "Overall, you have %d%% to win!" %percent def auto(): game_status = True purpose = raw_input("How much are you gonna reach") while game_status: play() if bankroll == int(purpose) or bankroll == 0: game_status = False game()
以上所述就是本文的全部内容了,希望能够对大家学习Python有所帮助。
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
更新日志
2024年11月25日
2024年11月25日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]