We have over 10,000 published online slot reviews many with free slot demo games. All separated by slot software.
Part 3
Due:
Wednesday, November 29 @ 8:00 AM 8:00 PM
We are giving you a little more time to make up for the missedopportunities to visit office hours during Thanksgiving week. Also,the class on Monday, November 20 will be devoted to homework Q & A, socome prepared with questions!
Repository Link:
ssh://ubit@timberlake.cse.buffalo.edu/projects/CSE115/Repositories/Fall2017/HW2_Part3
Use the link above and follow the same procedure as you have for the coding exercises in lab. (https://www.youtube.com/watch?v=hiij77tpDM4) Remember to replace 'ubit' in the above URI with your UBIT name,
Estimated Time:
8 hours (over two weeks) for basic functionality (4 points)? hours (over two weeks) for extra credit functionality (2 points)
Description
In this part of Word Play we will bolt on a graphical user interface to the game. The repository contains a runnable JAR file name DEMO.jar. If you double-click on this in the package explorer it will run a solution that shows you what the finished product should look and behave like.
It is important that you run the demo and explore its behavior - for example, there is an extra panel that provides feedback to the player when a guess is submitted. Your submission must provide that feedback too. Note that this functionality may require you do add code beyond that which is sketched through the various stubbed out methods provided to you.
4 proficiency points
Build the game to the same level of functionality and performance asthe provided demo. There will be autograding for these proficiencypoints.
2 extra-credit proficiency points
If your submission scores 4 points on autograding you may make asubmission for manual grading of additional functionality. Each extracredit item succesfully completed will earn 0.5 additional proficiencypoints.
- Configuration file
- Enhance the game so that, on startup,it reads data from a JSON file named 'HW2.config', appearing as asibling of the dictionaries folder on the file system:minWordLength - the minimum length of any of the words the playerneeds to find. Regardless of the value in the configuration file, theminimum word length must never be less than 3 and can never be largerthan the maximum word length. If no minimum word length is specifiedin the file the default value is 3.maxWordLength - the maximum length of any of the words the playerneeds to find. Regardless of the value in the configuration file, themaximum word length must never be less than the mimimum word length.If no maximum word length is specified in the file the default valueis 7.fontSize - the font sized use for all text in the user interface. Ifno default value is specified then 44 is used.maxWordPerTurn - the maximum number of words to put in the list ofwords the user has to guess. This provides an upper bound.Regardless of the value in the configuration file, the maximum numberof words per turn must be no less than 5. If, for a given seed word,the number of possible words is greater than maxWordsPerTurn, the gamemust populate _wordToFind with the specified maximum number of words.If not default value is specified then the maximum number of words isunlimited.
- High scores
- Implement a version of the game in which eachword found counts for as many points as there are letters in the word. On startup,the game reads data from a JSON file named 'HW2.scores', appearing as asibling of the dictionaries folder on the file system. Here's a sample structure for this file:At the end of the player's turn, their score is the total points forthe all words they found. Keep a file (JSON again) of the top tenhigh scores. At the start of each game have the user specify a namefor themselves. Load and display any scores in the high score file ina separate JPanel in the user interface. Add a 'resign' button sothat a player can end a turn before finding all the words. At the ofa player's turn add their name and their score to the high score fileif their score was among the top ten. Drop any scores past the tenthbest score from the file. Allow ties, so that all players whoachieved one of the top ten scores will be listed (see the two namesfor the score 188 in the example, above).
- Timed play
- Implement a version of the game in which theplayer has a limited amount of time to find words. Seethe SwingTimer documentation for help on how to use a timer to trigger anevent. Allow 60 seconds for a player to complete their turn. Thetime left must be displayed prominently in the Graphical UserInterface.
- Levels
- Implement a version of the game in which, once alevel is completed, a new level is presented to the user. A playerneed not find all the words on a level to advance; a player advancesto the next level if they find at least one of the maximum lengthwords.
Testing
We again provide a Driver class that you can use for some manual testing of your code.
Submission
Submit a jar file of your project under Word Play - Part 3 on AutoLab. Remember to check the correct boxes in the jar file export dialog.
Autograding for the basic part of the assignment (the first 4 points) will be available on AutoLab no later than Wednesday November 15.
If you score 4 points on the autograded portion of this homework you can make a separate jar file submission under Word Play - Part 3 - extra on AutoLab. There is no autograding of the extra credit. Instead, it will be manually graded. This will take time. Be patient.
Goals
Upon successful completion of this lab, you should be able to understand and write programs using while
(indefinite) loops.
Setup and Practice
Setup
- If your lab machine was not started in MacOS when you went to use it, reboot it to MacOS.
- Follow these procedures to mount your blue home-directory on the local machine and create a PyCharm project (call it Lab06). You will use PyCharm in the next part, but, it is important that you set up your project now so that if you run into any issue, we can resolve them quickly.
Practice
Answer Questions 1–7 in your Moodle writeup. You can use the the Online Python 3 tutor to help, but you should try to answer the questions on your own first.
Introduction to while loops
Enter the following Python code into the Online Python Tutor, and use the tutor to step through this loop to understand what is happening:
- Aswer Questions 8–10 in Moodle about the above code.
Part A: Basic while loops: the Collatz sequence
For this part of the lab, you will begin with a program that asks the user to enter a sequence of values and tells the user if each value is even or odd. You will then modify that program to do a more complex task: to generate the terms of a famous numerical sequence, called the Collatz sequence.
- Start by choosing a positive integer N
- If N is 1, stop.
- Otherwise, based on the value of N, generate the next term:
- If N is odd, the next term is 3N+1.
- If N is even, the next term is N / 2.
- Repeat with the new value of N.
You will write a program that allows the user to choose the value of N, and we will generate all the subsequent terms of the sequence.
Instructions
Review the above steps for how the Collatz sequence is produced, working through the following example, where the initial value for N is 6:
Make sure you understand the mechanics of how the above output was generated, given the starting value of 6.
- Answer Question 11 in your writeup.
Fun fact: it has not been mathematically proven that the Collatz sequence will always reach 1 and terminate. However, no one has yet found a value of N that fails to eventually reach 1. The Collatz conjecture states the unproven belief that every sequence ends in 1. The comic xkcd humorously summarizes this conjecture as:
- Create a new Python source code file named lab06a.py, substituting your name for the italicized text:
- Run your program using various input values, and be sure that it accurately reports whether the user's inputs are even or odd.
- Modify this code, to begin computing the Collatz sequence, per the below pseudocode:
Note: you should use integer division (
//
) instead of floating-point division (/
) so that the values appear as integers.For example:
or: - To generate all the terms in the sequence, you will need a
while
loop. To practice while loop conditions, answer Question 12 in your writeup. - Put your if/else statements and your print statement inside a
while
loop:The
while
loop condition should evaluate toTrue
until you have finished the sequence, and then it should becomeFalse
. Remember that the sequence ends when N reaches 1. The condition does not need to be long and involved — it can be very short.Note: If you accidentally write an infinite loop, you can press Ctrl-C to force-quit your program.
- Test your program using the following sample input/output sequences:
- Demo.When your code is correct, call an instructor over to demo your program.
Note: This week, you will demo Parts A and C, but you will only submit your Part C code. Computing the Collatz sequence was just a simple, non-trivial task to practice using a while loop.
- Continue to Part B.
Part B: Find the largest power of 2 less than a number
Any positive integer can be written as the sum of a series of terms, where each term is the number 2 raised to some power. For example:
Notice how the exponent of each term is less than that of its predecessor.
You will write a program to read an integer and decompose it into such a series. Here is an example of how your final program might be used:
You will write your program in two phases: the first in Part B, and the second in Part C.
In the Part B phase, your program only reads an integer i_num and finds the largest n such that 2n ≤ i_num. You can assume that i_num is always a positive integer. Here is how your program will interact with the user by the end of this phase:
Note that 210 is 1024, and 211 is 2048. The user's number, 1234, lies in between these two values. Therefore, 10 is the largest positive integer such that 2n ≤ i_num.
Here are a few more examples:
Instructions
- Create a new Python source code file named lab06b.py:
Read the above pseudo-code carefully, and decide on an appropriate initial value for
n
. This will also determine the initial value oftwo_to_n
. - Before you write any code, answer Question 13 in your writeup.This question asks you to trace the values of
n
andtwo_to_n
as the program processes the input 17. Just reason using pen and paper right now. After you understand the algorithm on paper, write the Python code to replace the pseudocode. To help you test your program, here are some example input/output sequences:
- Example 1
- Example 2
- Example 3
- Example 4
- Example 5
- When your program matches all of these examples, continue to Part C.
Cse 115 Lab 8 Slot Machine Machines
Part C: Write a number as the sum of powers of 2
This is the second phase, where you complete the full program described in Part B to express a positive integer as the sum of powers of 2.
Cse 115 Lab 8 Slot Machine Manual
Read the instructions carefully, and be sure you understand what youare doing at each step. Ask the lab instructors for help if you need it.
Instructions
Create a new Python source file named lab06c.py:
Before you translate the pseudocode to Python, answer Question 14 in yourwriteup. This question asks you to trace this algorithm for each iteration of the outer loop, assuming user input
i_num
is 23.Once you have understood the algorithm, translate it to Python. If youneed help adapting code from Part B, ask an instructor.
At this point, test your program on the following sample input:
There are two major changes left to make, which the rest of these steps will walk you through:
- All of the powers of 2 need to print on the same line.
- The printed terms should be separated by ' + '.
First, to have all of these values print on the same line, add
end='
to the end of your print statement. For example:Now, your program is probably printing the following:
Next, you should add spaces and plus signs between the terms byinserting this print statement somewhere in your code:
Now, your program should be printing the following:
You should figure out how to get rid of the final '
+
' at the end. Hint: put your print statement inside some conditional statement.When you succeed, your output should look like this:
Demo.When you program matches the final, target behavior, demo your program for an instructor.
- Make sure that your docstring is up-to-date.
- Continue to the next part to submit your program.
Assignment Submission
Cse 115 Lab 8 Slot Machines
Instructions
Cse 115 Lab 8 Slot Machine For Sale
- Answer the last question (#15) in your Moodle writeup. Review your answers, and then click the 'Next' button at the bottom of the quiz. Once you do that, you should see a 'Summary of Attempt' screen.
- Click the 'Submit all and finish' button.Warning: You must hit 'Submit all and finish' so that your writeup can be graded! It is not submitted until you do this.Once you have submitted your quiz, you should see something similar to this at the top of your Moodle window. The important part is that the State shows up as Finished.
Please leave this tab open in your browser. - Click on the 'Lab 6 code' link in Moodle and open in a new tab. Follow the instructions to upload your source code (lab06c.py) for Lab06. You could either browse for your code or, using a finder window, drag and drop your lab06c.py from your cs115/Lab06 folder to Moodle. You should subsequently see a dialog box which indicates 'Submission Status' as 'Submitted for grading'. Leave this tab open in your browser.
- With these confirmation pages open in your browser, you may call an instructor over to verify that you have completed every part of the lab. Otherwise, you are done!