精華區beta NTUBA92 關於我們 聯絡資訊
Homework #3 Write a function that will help a player - draw as many cards as possible - but stay within the risk level limit (but there is still a chance to go over!) Then produce the following table of statistics. Hands #1 #2 #3 … #8 %Busted Risk 0.9 18 15 23 … 14 37.50 0.8 … … 0.1 Remember to reset the player every time and shuffle the cards between risk levels. What are your observations of the simulation results? -------------------- Teaching assistants hours: Friday 6pm - 7pm at 3rd floor computer room 7pm - 8pm, if there are still students with questions Monday 6pm - 7pm at 3rd floor computer room 7pm - 8pm, if there are still students with questions ------------ A help for your homework. Stepwise refinement for Homework#3 The purpose of stepwise refinement is to state our approach to resolving a problem in levels of details from a high conceptual level to the low detailed levels in such a way that we can be sure how to turn the details into program codes. Here is an example for our homework assignment. Level 1 1. generate one line of statistics for one particular risk level. 2. for risk levels from 0.9 to 0.1, call step 1. (The idea is: if we know how to do one line, we should be able to generate the table by doing the same thing a few times using a loop.) Level 2 1.1 shuffle the cards. 1.2 generate one hand. 1.3 generate seven more hands similarly. That is, do 1.2 in a loop. 1.3 computed %busted (Step 2 at level 1 is obvious and therefore no further refinement is needed.) Level 3 1.2.1 reset player. 1.2.2 get max number of cards for the player. 1.2.3 print player's point. 1.2.4 record busted or not. Level 4 1.2.2.1 while player is not busted and the risk is acceptable to the player, get a card for the player (until the condition no longer holds). (This is the function required by this homework. This function can be placed outside of the class. By doing so, you don't need to modify both deck and BJPlayer classes at all!) -- ㄏㄏ....請別把這篇當真.... 我只是在賺我的小惡魔的奶粉費~ :P -- ※ 發信站: 批踢踢實業坊(ptt.twbbs.org) ◆ From: olf.m7.ntu.edu.tw