Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
有趣的终端骰子游戏_创想鸟

有趣的终端骰子游戏

有趣的终端骰子游戏

这是早期项目之一。在编程方面,我仍在掌握各种元素。

这是一个有趣的骰子游戏,是我根据kindom come deliverence的骰子游戏制作的。我仅在终端中创建它。主要是因为我仍在尝试掌握 open gl 和其他图形输入。

非常欢迎任何反馈。

import random# menu to welcome the playerdef menu():    print("""    Welcome to dicen      Would you like to: n         1. Review the rule, n         2. play a new game n         3. review scoring of dice n         """)    try:        menu_choice = input("")    except EOFError:        print("No input received. Please run the program in an interactive environment.")        return    if menu_choice == "1":        print_rules()    elif menu_choice == "2":        new_game()    elif menu_choice == "3":        print_scroing_values()        second_meu()    else:        print("Invalid choice please choose again")        second_meu()#second menu to allow for a alteration of languagedef second_meu():    print("""  What would you like to do now?      Would you like to: n         1. Review the rule, n         2. play a new game n         3. review scoring of dice n         """)    menu_choice = input("Please enter your choice: ")    if menu_choice == "1":        print_rules()    elif menu_choice == "2":        new_game()    elif menu_choice == "3":        print_scroing_values()        second_meu()    else:        print("Invalid choice please choose again")        second_meu()#explantion of rulesdef print_rules():    print("""  A player's turn always begins by throwing all six dice. The player then selects and set aside scoring dice, and at least one die must always be set aside. Then the player can throw the remaining dice again and the situation repeats. n  Scoring combinations are counted only for the current throw, not the entire turn.n  The key element of the game is that if a throw does not produce a single scoring die, then the player's turn is over and all points scored up to that throw are forfeit. It is then the opposing player's turn to throw. n  For that reason, it's best to end your turn before the risk that not a single die will score gets too high. Sometimes it's better not to set aside all the scoring dice you you've thrown, so you stand a better chance of scoring higher on the next throw.nn  """)    second_meu()#and the scroing systemdef print_scroing_values():    print("""Scoring is as follows:    - a single 1 is worth 100 points; n    - a single 5 is worth 50 points; n    - three of a kind is worth 100 points multiplied by the given number, e.g. three 4s are worth 400 points; n    - three 1s are worth 1,000 points;n    - four or more of a kind is worth double the points of three of a kind, so four 4s are worth 800 points, five 4s are worth 1,600 points etc.n    - full straight 1-6 is worth 1500 points.n    - partial straight 1-5 is worth 500 points.n    - partial straight 2-6 is worth 750 points.nn """)# This die clas allows funtionality to roll a six sided dice and output the value.class die:    def __init__(self):        self.value = 0    def __repr__(self):        return f"{self.value}"    def roll(self):        self.value = random.randint(1, 6)#here is where the class objects are created and organised into a list for ease of use.die1 = die()die2 = die()die3 = die()die4 = die()die5 = die()die6 = die()dice = [die1, die2, die3, die4, die5, die6]#player class hold the dice values, the player name a method for rolling all 6 dice at one and rerolling specific dice.class player:    def __init__(self, name, dice_list, score=4000):        self.name = name        self.score = score        self.dice_list = dice_list    def deduct_score(self, deduction):        self.score -= deduction        return self.score    def roll_d6(self):        roll_string: str = ""                  #this funtion rolls all the dice coverts them to string and labels them 1 to 6 producing eg 1: 6, 2: 6, 3: 1, 4: 2, 5: 3, 6: 2        i = 1        for die in dice:            die.roll()            data = die.value            str_data = str(data)            str_i = str(i)            roll_string += str_i + ": " + str_data + ", "            i += 1        return roll_string    def print_d6(self):                                     #just print the values        roll_string: str = ""        i = 1        for die in dice:            data = die.value            str_data = str(data)            str_i = str(i)            roll_string += str_i + ": " + str_data + ", "            i += 1        return roll_string    def re_roll(self, index):                         #re rolls dice speficed        index-=1        dice[index].roll()        return dice[index].value#This is the main game loop it has a lot of moving parts. Take your time reviewing.def new_game():    print("Hi so what is your name?n")    human_name = input("")    human_player = player(human_name, dice, 4000)   #creating objects for both human and computer players in the player class    print("who do you wish to play against?")    computer_name = input("")    computer_player = player(computer_name, dice, 4000)    play = True    while (play):        print("""ok here is your roll:     you roll a: """)        print(human_player.roll_d6())     #use of the player class function roll_d6 to give a string of rolled dice        print("Time to score you dice")        total_dice_score = possible_to_score(human_player.dice_list)   #this function is below and check to see if any of the dice can score        print(total_dice_score)        print("Whould you like to re-roll you any dice? Y/N")  #allowing the player a chance to re roll dice        lroll = input("")        roll = lroll.upper()        if (roll == "Y"):            dice_choice(human_player)        #print(dice)        print("Time to score you dice")        total_dice_score = possible_to_score(dice)        print(total_dice_score)        human_player.deduct_score(total_dice_score)        print(f"Your score is now {human_player.score}")        print(f"Ok it's {computer_player.name} go they rolled")        print(computer_player.roll_d6())        print("They scored:")        total_dice_score = possible_to_score(dice)        print(total_dice_score)        computer_player.deduct_score(total_dice_score)        print(f"{computer_player.name} score is now {computer_player.score}")        input("")        if human_player.score <= 0 or computer_player.score <= 0:            if human_player.score  dice_score:            dice_score = temp_dice_score    if (isone_to_five == True):        temp_dice_score = 500        if temp_dice_score > dice_score:            dice_score = temp_dice_score    if (istwo_to_six == True):        temp_dice_score = 600        if temp_dice_score > dice_score:            dice_score = temp_dice_score    return dice_scoredef one(counts):    if counts[0] >= 1:        return True    else:        return Falsedef five(counts):    if counts[4] >= 1:        return True    else:        return Falsedef three_of_kind(counts):    if 3 in counts:        return True, counts.index(3)    else:        return False, Nonedef four_of_kind(counts):    if 4 in counts:        return True, counts.index    else:        return False, Nonedef five_of_kind(counts):    if 5 in counts:        return True, counts.index    else:        return False, Nonedef six_of_kind(counts):    if 6 in counts:        return True, counts.index    else:        return False, Nonedef full_straight(counts):    if all(value == 1 for value in counts):        return True    else:        return Falsedef one_to_five(counts):    if counts[0] <= 1 & counts[1] <= 1 & counts[2] <= 1 & counts[3] <= 1 & counts[4] <= 1:        return True    else:        return Falsedef two_to_six(counts):    if counts[1] <= 1 & counts[2] <= 1 & counts[3] <= 1 & counts[4] <= 1 & counts[5] <= 1:        return True    else:        return Falsedef count(dice):                   #dice is a alis for eaither human_player.dice_list or computer_player.dice_list which would look like [1, 2, 3, 4, 5, 6] with random numbers beteen 1 and 6 in each index.    value_counts = count_values(dice)    num_ones = value_counts[1]         #the job of this to take the 1: prefix to all the counts to leave behind only the count itself    num_twos = value_counts[2]    num_threes = value_counts[3]    num_fours = value_counts[4]    num_fives = value_counts[5]    num_sixes = value_counts[6]    numbers_list = [num_ones, num_twos, num_threes, num_fours, num_fives, num_sixes]    return numbers_list   #this goes back to new gamedef count_values(dice_list):    counts = {i: 0 for i in range(1, 7)}     #this created this {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0}    for die in dice_list:        counts[die.value] += 1 #assins each of the dice to a value in numerical order eg of output {1: 1, 2: 1, 3: 2, 4: 1, 5: 1, 6: 0}    return countsdef dice_choice(player):    #alis for human_player    rolling = True    print("Please type the dice you want to re-roll after each choice press enter. When you finish type exit and press enter.")    while (rolling):        player_input = input("")        if player_input.isdigit():                     #checks is the input is a number            number = int(player_input)            if 1 <= number <= 6:                        #checks if it falls between 1 and 6                player.re_roll(number)                         #rolls the dice specified            else:                print("Invalid entry must be a value between 1 and 6")        elif player_input == "exit":            print(f"Your new values are: {player.print_d6()} .")              #outputs the results            rolling = False        else:            print("invalid entry must be a number or exit, please try again.")menu()

以上就是有趣的终端骰子游戏的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1352791.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
如何获取 PySide6 源代码?
上一篇 2025年12月13日 17:07:59
如何利用 RAM 加速视频处理中的图像帧处理?
下一篇 2025年12月13日 17:08:13

相关推荐

  • Gemini如何接入数据分析 Gemini大数据处理接口

    Gemini如何接入数据分析 Gemini大数据处理接口Gemini如何接入数据分析 Gemini大数据处理接口Gemini如何接入数据分析 Gemini大数据处理接口Gemini如何接入数据分析 Gemini大数据处理接口

    本文将详细介绍如何将 Gemini 的数据分析能力接入到大数据处理流程中,并提供具体的操作步骤,帮助您更有效地利用 Gemini 进行数据洞察和分析。 ☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜ 数据接入基础准备 在开始接入之前,您需要对…

    2026年9月28日 • 用户投稿
    000
  • 计算JSON驱动的问卷调查的可能路径数:Java递归实现

    计算JSON驱动的问卷调查的可能路径数:Java递归实现计算JSON驱动的问卷调查的可能路径数:Java递归实现计算JSON驱动的问卷调查的可能路径数:Java递归实现计算JSON驱动的问卷调查的可能路径数:Java递归实现

    本文旨在提供一种使用Java和递归算法,计算基于JSON配置的问卷调查中所有可能的路径数量的解决方案。我们将深入探讨如何解析JSON结构,并使用递归函数遍历所有可能的答案分支,最终计算出完成问卷调查的不同方式的总数。此外,还将讨论在设计此类问卷调查逻辑时的一些注意事项。 理解JSON问卷结构 首先,…

    2026年9月28日 • 用户投稿
    000
  • 小红书如何利用话题标签增加曝光 小红书热门标签的使用秘诀

    小红书如何利用话题标签增加曝光 小红书热门标签的使用秘诀小红书如何利用话题标签增加曝光 小红书热门标签的使用秘诀小红书如何利用话题标签增加曝光 小红书热门标签的使用秘诀小红书如何利用话题标签增加曝光 小红书热门标签的使用秘诀

    选择与内容高度相关的标签,如分享美白精华心得时使用#美白精华、#淡斑等精准标签,提升平台推荐准确性;2. 结合热门标签与长尾标签,如在使用#美白精华的同时添加#敏感肌美白精华、#学生党美白精华,平衡流量与竞争;3. 积极使用品牌或官方活动标签,如参与#我的夏日穿搭挑战赛时带上官方标签,增加曝光与活动…

    2026年9月28日 • 用户投稿
    000
  • 多模态AI如何处理雷达数据 多模态AI信号处理技术方案

    多模态AI如何处理雷达数据 多模态AI信号处理技术方案多模态AI如何处理雷达数据 多模态AI信号处理技术方案多模态AI如何处理雷达数据 多模态AI信号处理技术方案多模态AI如何处理雷达数据 多模态AI信号处理技术方案

    本文将详细介绍多模态AI如何处理雷达数据,并提供一套信号处理技术方案,帮助您理解并学习如何利用多模态AI的强大能力来解析复杂的雷达信号。我们将从数据预处理开始,逐步深入到特征提取、模型构建以及最终的雷达信号分析与应用,旨在为您提供一个清晰的学习路径。 ☞☞☞AI 智能聊天, 问答助手, AI 智能搜…

    2026年9月28日 • 用户投稿
    000
  • 解决Microsoft Graph API中获取用户活动时的429限流错误

    本文旨在深入探讨Microsoft Graph API在获取用户近期活动时可能遇到的429“请求过多”限流错误。我们将分析该错误产生的原因,提供导致问题的代码示例,并详细阐述如何通过理解Graph API的限流机制、实现指数退避重试以及优化API调用策略来有效应对和避免此类错误,从而构建更稳定可靠的…

    2026年9月28日
    000
  • 2025年精选免费将图片生成视频的AI工具前十强

    2025年推荐的免费图片转视频AI工具包括RunwayML Gen-2、Pika Labs、Kaiber、Synthesia IO、DeepMotion Animate 3D、Movavi Slideshow Maker、Kapwing、VEED.IO、Simplified和Designs.AI,这…

    2026年9月28日
    000
  • VSCode如何实现代码实时性能监控 VSCode运行时性能分析工具的集成

    VSCode如何实现代码实时性能监控 VSCode运行时性能分析工具的集成VSCode如何实现代码实时性能监控 VSCode运行时性能分析工具的集成VSCode如何实现代码实时性能监控 VSCode运行时性能分析工具的集成VSCode如何实现代码实时性能监控 VSCode运行时性能分析工具的集成

    vscode中javascript/node.js代码性能分析的实践路径是通过在launch.json中配置”–inspect”或”–inspect-brk”参数启动调试模式,利用chrome devtools的performa…

    2026年9月28日 • 用户投稿
    000
  • OptaPlanner 过约束规划:虚拟值与空值变量的策略选择

    OptaPlanner 过约束规划:虚拟值与空值变量的策略选择OptaPlanner 过约束规划:虚拟值与空值变量的策略选择OptaPlanner 过约束规划:虚拟值与空值变量的策略选择OptaPlanner 过约束规划:虚拟值与空值变量的策略选择

    本文深入探讨OptaPlanner中处理过约束规划的两种核心策略:使用可空(nullable)规划变量和引入虚拟值。我们将对比这两种方法在资源分配、约束评估和问题归属方面的差异,并提供何时选择哪种策略的指导,帮助开发者根据实际业务需求构建高效且符合逻辑的解决方案。 理解过约束规划 在资源规划问题中,…

    2026年9月28日 • 用户投稿
    100
  • sublime怎么在ubuntu上通过apt-get安装_Ubuntu系统apt安装教程

    sublime怎么在ubuntu上通过apt-get安装_Ubuntu系统apt安装教程sublime怎么在ubuntu上通过apt-get安装_Ubuntu系统apt安装教程sublime怎么在ubuntu上通过apt-get安装_Ubuntu系统apt安装教程sublime怎么在ubuntu上通过apt-get安装_Ubuntu系统apt安装教程

    要通过APT在Ubuntu上安装Sublime Text,需先添加官方仓库并导入GPG密钥:使用wget或curl命令导入密钥,执行echo命令添加稳定版仓库源,运行sudo apt update更新包列表,最后执行sudo apt install sublime-text完成安装。安装后可通过su…

    2026年9月28日 • 用户投稿
    100
  • 豆包AI生成产品需求文档的技巧 快速梳理功能要点的指南

    豆包AI生成产品需求文档的技巧 快速梳理功能要点的指南豆包AI生成产品需求文档的技巧 快速梳理功能要点的指南豆包AI生成产品需求文档的技巧 快速梳理功能要点的指南豆包AI生成产品需求文档的技巧 快速梳理功能要点的指南

    写需求文档需明确目标用户与场景,如面向远程办公小团队的任务管理工具;分步骤提问细化功能模块,避免一次性输出整篇prd;结合模板结构引导ai生成格式化内容;最后人工审核确保逻辑闭环与业务适配。 ☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜ 写…

    2026年9月28日 • 用户投稿
    000
  • Claude可以解读脑部fMRI数据吗 Claude神经影像分析医学应用

    Claude可以解读脑部fMRI数据吗 Claude神经影像分析医学应用Claude可以解读脑部fMRI数据吗 Claude神经影像分析医学应用Claude可以解读脑部fMRI数据吗 Claude神经影像分析医学应用Claude可以解读脑部fMRI数据吗 Claude神经影像分析医学应用

    claude不能直接分析脑部fmri数据,1. 因为其设计用于文本处理而非图像分析;2. 医学影像需专业软件如fsl、spm或深度学习模型处理;3. claude可解释术语、梳理流程、推荐资源及辅助写代码;4. 在医学应用中ai模型专用于分类预测,而claude仅能作为助手;5. 研究人员可用其理清…

    2026年9月28日 • 用户投稿
    100
  • OptaPlanner 过约束规划:理解与应用虚拟值策略

    OptaPlanner 过约束规划:理解与应用虚拟值策略OptaPlanner 过约束规划:理解与应用虚拟值策略OptaPlanner 过约束规划:理解与应用虚拟值策略OptaPlanner 过约束规划:理解与应用虚拟值策略

    本文深入探讨OptaPlanner在处理过约束规划场景时的两种核心策略:利用nullable=true和引入“虚拟值”。我们将详细解析这两种方法的工作原理、适用场景、配置方式及约束设计,旨在帮助开发者根据实际业务需求,高效地解决资源不足问题,实现最优或次优的规划结果。 OptaPlanner 过约束…

    2026年9月28日 • 用户投稿
    100
  • 如何通过Elser AI Comics生成适合印刷的高分辨率漫画作品?

    如何通过Elser AI Comics生成适合印刷的高分辨率漫画作品?如何通过Elser AI Comics生成适合印刷的高分辨率漫画作品?如何通过Elser AI Comics生成适合印刷的高分辨率漫画作品?如何通过Elser AI Comics生成适合印刷的高分辨率漫画作品?

    要生成适合印刷的高分辨率漫画作品,关键在于调整elser ai comics的输出尺寸、dpi和细节控制。1. 设置画布尺寸为实际打印大小,并将dpi调至300;2. 使用超分工具提升清晰度而非直接拉伸;3. 选择适合印刷的风格并优化提示词以增强线条与背景清晰度;4. 分层输出人物、背景和特效以便后…

    2026年9月28日 • 用户投稿
    000
  • OptaPlanner 过约束规划:理解虚拟值与可空变量的策略选择

    OptaPlanner 过约束规划:理解虚拟值与可空变量的策略选择OptaPlanner 过约束规划:理解虚拟值与可空变量的策略选择OptaPlanner 过约束规划:理解虚拟值与可空变量的策略选择OptaPlanner 过约束规划:理解虚拟值与可空变量的策略选择

    本文深入探讨 OptaPlanner 中处理过约束规划的两种核心策略:使用可空规划变量(nullable=true)和引入虚拟值。我们将详细阐述这两种方法的适用场景、实现机制及其对解决方案的影响,并通过中等约束(Medium Constraint)的运用,帮助您根据实际业务需求选择最合适的规划策略,…

    2026年9月28日 • 用户投稿
    100
  • 想将 AI 汽车保养工具与豆包联用了解保养知识?详细步骤​

    想将 AI 汽车保养工具与豆包联用了解保养知识?详细步骤​想将 AI 汽车保养工具与豆包联用了解保养知识?详细步骤​想将 AI 汽车保养工具与豆包联用了解保养知识?详细步骤​想将 AI 汽车保养工具与豆包联用了解保养知识?详细步骤​

    想将 ai 汽车保养工具与豆包联用了解保养知识,可以按照以下步骤操作:1. 明确需求,如日常保养周期、故障码解读等;2. 使用豆包查询通用保养知识,例如更换机油周期或刹车片判断方法;3. 利用 ai 汽车保养工具进行个性化分析,输入 vin 码或行驶数据获取专属建议;4. 结合两者使用技巧,如记录问…

    2026年9月28日 • 用户投稿
    000
  • 使用 Java Map 聚合 List 中重复元素的数值

    使用 Java Map 聚合 List 中重复元素的数值使用 Java Map 聚合 List 中重复元素的数值使用 Java Map 聚合 List 中重复元素的数值使用 Java Map 聚合 List 中重复元素的数值

    本文介绍了如何使用 Java Map 结构有效地聚合 List 中具有相同类型(Type)的元素的数值,例如金额(Amount)和数量(Quantity)。通过将 List 转换为 Map,并利用 compute 方法或 Stream API 的 toMap 操作,可以避免手动循环和比较,从而简化代…

    2026年9月28日 • 用户投稿
    000
  • Java编程:计算用户输入字符串的词汇属性百分比

    Java编程:计算用户输入字符串的词汇属性百分比Java编程:计算用户输入字符串的词汇属性百分比Java编程:计算用户输入字符串的词汇属性百分比Java编程:计算用户输入字符串的词汇属性百分比

    本教程详细介绍了如何在Java中接收用户输入字符串,并利用正则表达式计算符合特定词汇属性(如纯字母单词、首字母大写单词)的字符串百分比。文章涵盖了输入验证、数据存储、正则表达式匹配以及模块化计数方法,旨在提供一个清晰、高效的解决方案。 1. 教程概述与核心挑战 在许多应用场景中,我们需要从用户那里获…

    2026年9月28日 • 用户投稿
    000
  • 豆包无需安装秒启动 豆包AI智能助手即时响应

    豆包无需安装秒启动 豆包AI智能助手即时响应豆包无需安装秒启动 豆包AI智能助手即时响应豆包无需安装秒启动 豆包AI智能助手即时响应豆包无需安装秒启动 豆包AI智能助手即时响应

    全民k歌:歌房舞台效果开启指南 腾讯出品的全民K歌,以其智能打分、修音、混音和专业音效等功能,深受K歌爱好者喜爱。本教程将详细指导您如何在全民K歌歌房中开启炫酷的舞台效果。 ☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜ 步骤: 打开全民K歌…

    2026年9月28日 • 用户投稿
    000
  • sublime怎么处理二进制或hex文件_Hex文件查看与编辑方法

    sublime怎么处理二进制或hex文件_Hex文件查看与编辑方法sublime怎么处理二进制或hex文件_Hex文件查看与编辑方法sublime怎么处理二进制或hex文件_Hex文件查看与编辑方法sublime怎么处理二进制或hex文件_Hex文件查看与编辑方法

    Sublime Text通过Hex Viewer插件可实现二进制文件的十六进制查看与编辑,提升轻量级处理效率,但需注意文件损坏、编码混淆等风险,适合小范围修改,复杂任务应使用010 Editor、HxD等专业工具。 Sublime Text本身并非设计用来直接处理二进制或十六进制文件,它本质上是一个…

    2026年9月28日 • 用户投稿
    400
  • Java中输入字符串单词百分比及特定模式识别教程

    Java中输入字符串单词百分比及特定模式识别教程Java中输入字符串单词百分比及特定模式识别教程Java中输入字符串单词百分比及特定模式识别教程Java中输入字符串单词百分比及特定模式识别教程

    本教程详细介绍了如何在Java中高效处理用户输入的字符串集合,并计算其中符合特定模式(如纯字母单词或以大写字母开头的单词)的字符串百分比。文章着重讲解了输入收集、正则表达式的应用、模块化计数方法的实现以及最终结果的展示,旨在帮助读者掌握字符串分析与处理的关键技巧。 在java应用程序开发中,经常需要…

    2026年9月28日 • 用户投稿
    000

发表回复

登录后才能评论
关注微信