国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

代寫CS 8編程、代做Python語言程序

時間:2023-12-12  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯


CS 8: Introduction to Computer Science

Fall 2023 Final Project

Due Tuesday, December 12, 11:59PM (California time)

In the game Yahtzee, players try to get particular combinations of five six-sided dice. For

a given turn, they can make up to three rolls: on the first roll, they roll all five dice; on

the second roll, they can choose to re-roll none, any, or all of the dice again; and on the

third roll, they again can choose to re-roll none, any, or all of the dice again. The best

outcome for a given turn is to get what’s called a Yahtzee, in which all five dice have the

same value on them. It doesn’t matter what that value is, just that they are all the same.

Here is an example. For the first roll, say a player gets:

2 4 1 6 4

Let’s say they choose not to re-roll the two dice that were 4’s, but they do re-roll the dice

that were 2, 1, and 6, giving new values for those three dice:

4 3 4

So at this point, after their second roll, the five dice are:

4 4 3 4 4

(Here I’m keeping the dice “in order”: the dice which was previously a 2 is now a 4, the

dice that was previously a 1 is now a 3, and the dice that was previously a 6 is now a 4.

The dice that were previously 4’s stay as 4’s.) For the player’s third roll, they choose to

only re-roll the dice that is a 3, and let’s say it comes up 4. So after the third roll, the

five dice are:

4 4 4 4 4

They all are the same! Yahtzee!

In this final project, you will write Python code to calculate the probability that a player

will get a Yahtzee on a given turn using the following strategy: You always try to get a

Yahtzee with the highest dice value for which you have the largest number of matching

dice. So if your dice are

4 2 4 5 2

you would keep the 4’s, and re-roll the 2’s and the 5.

There is also a related game called Tenzi, in which each player has ten 6-sided dice. On

the first roll, they roll all ten dice. On the second and all subsequent rolls they can choose

1

to re-roll none, any, or all of the dice again. They keep rolling until all ten dice have the

same value on them - a Tenzi! In this final project, you’ll also write Python code to keep

track of how many rolls it takes in order to get a Tenzi.

Please use the following code in order to generate a random integer 1,2,3,4,5, or 6:

import random

def rollDice():

return random.randrange(1,7)

Your main program should prompt the user to either play Yahtzee (by inputting Y), play

Tenzi (by inputting T), or quit (by inputting anything else). This prompt should continue

to be appear until the user quits. If the choice is Y, the user should be prompted to input

the number of trials to simulate for the Monte Carlo simulation and the number of dice

to use. The following should be printed to the shell:

Probability of Yahtzee with X dice: y.yyyy

where X is the number of dice which the user input, and y.yyyy is the probability of

getting a Yahtzee. Use four decimals for printing the probability. If the choice is T, the

user should be prompted to input the number of trials to simulate and the number of dice

to use. The following should be printed to the shell:

Rolls to get a Tenzi with X dice:

{1: Y, 2: Y, 3: Y, 4: Y, 5: Y, 6: Y, 7: Y, 8: Y, 9: Y, 10: Y, ’more than 10’ : Y}

where X is the number of dice which the user input, and the Y’s are the number of times

in the set of trials that it took that many rolls to get a Tenzi.

The following gives an example of running your code:

Note that the numbers you get may differ from these, but this should at least give a good

idea of what you should obtain from your code.

2

You’ll turn in a single Python program called yahtzee.py which includes the code given

above for simulating a dice roll, the main program as described above, and the following functions. Please be sure to include appropriate docstrings and comments for each

function.

• firstRoll : This should take an integer numDice as an input parameter which

tells how many dice you’re using in your game (this will be 5 for Yahtzee and 10

for Tenzi, but your function should be written for a general value for numDice),

and returns a list of length numDice of random integers each obtained by calling

rollDice. For example, the call

firstRoll(5)

will return a list such as

[2,4,1,6,4]

• newRoll : This should take the list diceList and an integer choice as input

parameters. Here diceList is a list of dice rolls, such as [2,4,1,6,4], and choice

is an integer corresponding to the dice value that you’re hoping to get a Yahtzee

with, such as 4. This should return a new list for which all dice which are not equal

to choice are re-rolled. For example, the call

newRoll([2,4,1,6,4],4)

will return a list such as

[4,4,3,4,4]

As in the example above, here the dice which was previously a 2 is now a 4, the

dice that was previously a 1 is now a 3, and the dice that was previously a 6 is now

a 4. The dice that were previously 4’s stay as 4’s.

• createDiceDict : This should take the list diceList as an input parameter, and

return a dictionary for which the keys are the possible roll values 1, 2, 3, 4, 5,

and 6, and the values are the number of times that roll value appears in the list.

For example, the call

createDiceDict([2,4,1,6,4])

will return the dictionary

{1:1, 2:1, 3:0, 4:2, 5:0, 6:1}

3

This captures that the value 1 appears once in the list, the value 2 appears once in

the list, the value 4 appears twice in the list, the value 6 appears once in the list,

and the values 3 and 5 don’t appear in the list.

• mostFrequent : This should take diceDict as an input parameter, which is a

dictionary as generated by the function createDiceDict. This should return the

highest dice value for which you have the largest number of matching dice. For

example, the call

mostFrequent({1:1, 2:1, 3:0, 4:2, 5:0, 6:1})

should return the value 4, because the dictionary encodes that the value 4 appeared

most frequently. Note that the call

mostFrequent({1:0, 2:2, 3:0, 4:2, 5:1, 6:0})

should also return the value 4, because we’re using the strategy that you always

try to get a Yahtzee with the highest dice value for which you have the largest

number of matching dice. This would be the dictionary corresponding to the list

[4,2,4,5,2].

• probabilityYahtzee : This should take integers numTrials and numDice as input

parameters. It will perform a Monte Carlo simulation of numTrials turns in which a

player tries to get all of the numDice dice to match. In each turn, the player will do a

first roll, a second roll if needed, and a third roll if needed. It should return the probability of getting all dice to match in one turn, calcuated from the Monte Carlo simulation. Note that in the game Yahtzee there are five dice, but your function should

be general enough to work for any positive integer value for numDice. Your function

should make calls to the functions firstRoll, newRoll, createDiceDict, and

mostFrequent as needed.

• rollsToGetTenzi : This should take integers numTrials and numDice as input

parameters. It will perform a simulation of numTrials trials to keep track of how

many rolls it takes in order for all of the numDice dice to match. It should return a dictionary whose keys are the numbers of rolls that this takes, specifically,

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and ’more than 10’, and whose values are the

number of times in the numTrials simulations that it took that many rolls. Note

here that if, in a given trial, after 10 rolls the dice do not all match, that trial

should be recorded as ’more than 10’. Note that in Tenzi there are ten dice, but

your function should be general enough to work for any positive integer value for

numDice. Your function should make calls to the functions firstRoll, newRoll,

createDiceDict, and mostFrequent as needed.

The functions firstRoll, newRoll, createDiceDict, and mostFrequent are worth 10

points each. The functions probabilityYahtzee and rollsToGetTenzi, and the main

program are worth 20 points each.

4

Academic Honesty Agreement

This project is open book, open notes. However, all work submitted must be your

own. By submitting these programs, you are asserting that all work on this project is

yours alone; that you did not use ChatGPT, Copilot, or similar AI bots; and that you

will not provide any information to anyone else working on the project. In addition, you

are agreeing that you will not discuss any part of this project with anyone. You are

not allowed to post any information about this project on the internet at any time, either

before or after the due date. Discussing any aspect of this project with anyone constitutes

a violation of the academic integrity agreement for CS8 and would result in an F in the

course.

Please note that you may ask questions about this project to the Professor, the TAs,

and the ULA’s, but we may answer in a limited way because we want to assess your

請加QQ:99515681 或郵箱:99515681@qq.com   WX:codehelp

掃一掃在手機打開當前頁
  • 上一篇:代做553.688 Computing for Applied 程序
  • 下一篇:CSCI1540代做、代寫C++設計編程
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    流體仿真外包多少錢_專業CFD分析代做_友商科技CAE仿真
    流體仿真外包多少錢_專業CFD分析代做_友商科
    CAE仿真分析代做公司 CFD流體仿真服務 管路流場仿真外包
    CAE仿真分析代做公司 CFD流體仿真服務 管路
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真技術服務
    流體CFD仿真分析_代做咨詢服務_Fluent 仿真
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲勞振動
    結構仿真分析服務_CAE代做咨詢外包_剛強度疲
    流體cfd仿真分析服務 7類仿真分析代做服務40個行業
    流體cfd仿真分析服務 7類仿真分析代做服務4
    超全面的拼多多電商運營技巧,多多開團助手,多多出評軟件徽y1698861
    超全面的拼多多電商運營技巧,多多開團助手
    CAE有限元仿真分析團隊,2026仿真代做咨詢服務平臺
    CAE有限元仿真分析團隊,2026仿真代做咨詢服
    釘釘簽到打卡位置修改神器,2026怎么修改定位在范圍內
    釘釘簽到打卡位置修改神器,2026怎么修改定
  • 短信驗證碼 豆包網頁版入口 破天一劍 目錄網 排行網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    国产人妻人伦精品_欧美一区二区三区图_亚洲欧洲久久_日韩美女av在线免费观看
    久久成年人免费电影| 久久精品成人一区二区三区蜜臀| 91精品国自产在线观看| 日韩最新在线视频| 色综合久久久久无码专区| 国产精品一区二区不卡视频| 国产精品露出视频| 欧美性大战久久久久| 国产成人av在线播放| 日韩一区二区高清视频| www.浪潮av.com| 中文字幕一区二区三区四区五区| 国产日韩三区| 九色91av视频| 国产精品自拍首页| 在线视频一二三区| 成人9ⅰ免费影视网站| 久久久久国产精品www| 国产日韩在线亚洲字幕中文| 欧美成人精品在线| 成人免费观看视频在线观看| 欧美激情极品视频| 成人亚洲综合色就1024| 一区二区在线观看网站| 99在线免费观看视频| 一区二区三区不卡在线| 99热成人精品热久久66| 亚洲欧美一区二区原创| 久久久免费看| 欧美一区1区三区3区公司| 久久久久在线观看| 日本10禁啪啪无遮挡免费一区二区| 日韩在线激情视频| 欧美做受777cos| 日韩亚洲欧美中文在线| 免费在线成人av| 精品中文字幕在线2019| 97人人模人人爽人人少妇| 午夜精品久久久久久久99黑人| 国产福利久久精品| 欧美亚洲国产免费| 精品久久一二三| 777午夜精品福利在线观看| 日本一道本久久| 日韩视频免费观看| 国产日韩欧美另类| 亚洲狠狠婷婷综合久久久| 国产厕所精品在线观看| 日本视频一区在线观看| 久久九九全国免费精品观看| 国产一区二区中文字幕免费看| 国产精品福利小视频| 91免费看国产| 日韩欧美亚洲日产国产| 国产精品久久久久久久久久免费| 国产精品永久免费在线| 日本黄网站色大片免费观看| 国产精品久久婷婷六月丁香| 高清欧美性猛交xxxx| 日韩欧美手机在线| 精品国产乱码久久久久久88av| 91高清免费在线观看| 黄色免费观看视频网站| 在线观看一区欧美| 久久久久久久久久久久久国产精品 | 欧美一级片免费播放| 久久精品国产v日韩v亚洲 | 国产欧美日韩91| 色中文字幕在线观看| 国产成人97精品免费看片| 国产原创精品| 性日韩欧美在线视频| 国产精品久久久久久久久久99| 91九色精品视频| 每日在线更新av| 日本网站免费在线观看| 麻豆国产va免费精品高清在线| 久久免费精品日本久久中文字幕| 国产欧美在线看| 欧美一区免费视频| 午夜精品区一区二区三| 国产精品国产福利国产秒拍| 久久国产精品视频在线观看| 国产欧美欧洲在线观看| 婷婷亚洲婷婷综合色香五月| 久久亚洲精品一区| 俺也去精品视频在线观看| 成人久久久久久久久| 欧美亚洲视频在线看网址| 亚洲中文字幕无码不卡电影| 国产精品视频久久| 国产高清一区视频| 国产精品一区二区三区不卡| 欧美精品久久久| 日本欧美视频在线观看| 一卡二卡3卡四卡高清精品视频| 久久精品小视频| 久久99精品久久久久久秒播放器| 91麻豆精品秘密入口| 国产主播欧美精品| 欧美日韩亚洲一区二区三区在线观看| 日韩在线综合网| 亚洲在线www| 欧美激情图片区| 欧美成年人在线观看| 国产成人精品在线视频| 久久国产欧美精品| 久久露脸国产精品| 福利视频一区二区三区四区| 国产欧美日韩综合精品| 国产在线精品二区| 免费99视频| 精品视频无码一区二区三区| 欧美亚洲黄色片| 人妻少妇精品久久| 日韩av色综合| 日本免费一级视频| 日韩av一区二区三区在线观看 | 欧美日韩黄色一级片| 日韩美女免费线视频| 日韩av免费在线播放| 亚洲精品欧美精品| 亚洲精品日韩成人| 亚洲精品一区二区三| 中文字幕一区二区三区最新| 萌白酱国产一区二区| 精品国产一区二区三区在线| 色综合久久悠悠| 欧美日本中文字幕| 一级黄色免费在线观看| 亚洲精品一区二区三区蜜桃久| 亚洲免费不卡| 欧美一区二区三区综合| 日韩福利一区二区三区| 欧美专区一二三| 僵尸世界大战2 在线播放| 国产中文字幕视频在线观看| 国产日本欧美一区二区三区在线| 国产伦精品一区二区三区四区视频_ | 国产精品视频永久免费播放| 国产精品美女午夜av| 国产精品夫妻激情| 中国丰满熟妇xxxx性| 亚洲国产一区二区三区在线播| 日日噜噜噜噜夜夜爽亚洲精品| 天堂资源在线亚洲资源| 日本a在线天堂| 日韩免费av一区二区三区| 欧美人与性禽动交精品| 国产一区二区三区乱码| 丰满爆乳一区二区三区| 久久天天狠狠| 久久精品视频中文字幕| 国产精品久久久久久久久久久久久久| 欧美激情区在线播放| 亚洲va欧美va在线观看| 日韩三级在线播放| 麻豆成人av| 91成人国产在线观看| 久久精品国产成人精品| 色综合视频网站| 日本一区视频在线播放| 国产综合久久久久| 68精品国产免费久久久久久婷婷 | 久久精品电影网站| 欧美精品一区二区三区国产精品| 亚洲精品欧美日韩| 欧美精品第三页| 国产精品一区二区三区在线 | 亚洲欧洲免费无码| 欧美另类一区| 91精品久久久久久久久久另类| 日韩视频欧美视频| 欧美激情网站在线观看| 日韩三级在线播放| 国产亚洲一区二区三区在线播放| 7777精品久久久久久| 国产精品美女无圣光视频| 在线视频一区观看| 欧洲熟妇精品视频| 国产免费一区二区三区在线能观看| 久热免费在线观看| 国产精品黄色av| 日本一级黄视频| 国产精品综合久久久| 九九热久久66| 一区二区三区欧美成人| 欧美亚洲视频一区二区| 99国产盗摄| 久久亚洲综合国产精品99麻豆精品福利 | 九九九久久国产免费| 日韩欧美国产免费| 粉嫩av一区二区三区天美传媒| 久久久国产91| 婷婷精品国产一区二区三区日韩 | 日本精品一区二区三区视频| 国产免费一区二区三区香蕉精 | 国产福利不卡| 久久99亚洲精品| 欧美 日韩 国产在线观看|