Development of Two Player Dice Rolling Game

4296 words (17 pages) Essay in Information Technology

23/09/19 Information Technology Reference this

Disclaimer: This work has been submitted by a student. This is not an example of the work produced by our Essay Writing Service. You can view samples of our professional work here.

Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UK Essays.

Decomposition of problem:

The task at hand is to create a two player dice rolling game, with 5 rounds, scoring system, user authentication when logging in and a Top 5 leaderboard for the post-game sequence. There are various scoring mechanics and rulings that need to be implemented, such as if the score from the rolls is even, an additional 10 points are added to the final score. The scores of each player are to be displayed after each round and the winner to be decided after 5 rounds. If the player’s scores are equal after 5 rounds, a “Sudden Death” round is initiated, whereby each player has one die to roll the higher score. The round repeats until a winner emerges.

This is the basic overview of the task given, however I have decided to expand upon the idea. In addition to the two player mode, known as “PvP”, a one player gamemode called “PvC” is to be added, to appeal to the class of gamers who prefer to play alone. To account for the extra gamemode, a menu system is to also be implemented, which shall display the title of the game and give the user three options: PvP, PvC, and Leaderboards. The leaderboards accessed from the menu will differ from the post-game leaderboard, as it will display every score recorded, not just the top 5.

To accomplish this task, I have set up some key success criteria which, if followed correctly, should produce a well-functioning, appealing and efficient game:

Success Criteria:

  1. Easy to use UI
  2. UI is colourful and appealing to the user
  3. Game Instructions concise and clear
  4. Gameplay mechanics function normally
  5. Scoring system mechanics function normally
  6. “Sudden Death” round loops efficiently
  7. Rounds counter functioning normally
  8. Username validation blocks/allows appropriate names
  9. Leaderboards can be updated and function normally
  10. Leaderboards can be viewed at any time from the menu screen
  11. Menu screen gives option of PvC, PvP and the full leaderboard

Design

General overview of how the game should run

1.)    Login

START

MENU LOAD IN

USERSELECT gamemode

IMPORT transition

IMPORT gamemode

 INPUT playername1

 IF playername = VALID

  INPUT playername2

  IF playername2 = VALID

   LOAD transition

   LOAD round 

  ELSE

   RESTART PROGRAM FROM MENU 

 ELSE

RESTART PROGRAM FROM MENU

 END

2.)    Rounds

START

roundcount = 1

ROUND()

SELECT randomnumber1 FROM RANGE 1-6

SELECT randomnumber2 FROM RANGE 1-6

ADD randomnumber1 + randomnumber2

STORE player1score

SELECT randomnumber3 FROM RANGE 1-6

SELECT randomnumber4 FROM RANGE 1-6

ADD randomnumber3 + randomnumber4

STORE player2score

ADD roundcount + 1

IF roundcount = 5:

  IF player1score > player2score:  

   PRINT player1winmessage

   EXPORT playername + player1score TO CSV

   LOAD menu

  ELIF player2score > player1score

   PRINT player2winmessage

   EXPORT playername2 + player2score TO CSV

   LOAD menu

  ELSE

   LOAD suddendeathround

ELSE

  RESTART

3.)    Sudden Death

START

suddendeath()

score1 = 0

score2 = 0

SELECT randomnumber1 FROM RANGE 1-6

ADD score1 + randomnumber1

SELECT randomnumber2 FROM RANGE 1-6

ADD score2 + randomnumber2

IF score1 > score2

 PRINT player1winmessage

 EXPORT playername + score1 + player1score TO CSV

 LOAD menu

ELIF score2 > score1

 PRINT player2winmessage

 EXPORT playername2 + score2 + player2score TO CSV

 LOAD menu

 ELSE

  RESTART suddendeath()

END

Test design

Test

What am I testing?

What data will I use?

Normal/Boundary/Erroneous?

Expected Result

1

Scoring system

Integer values

Normal testing is the only necessary method required to test this function, as any user input is accepted and integer values are randomly generated

When the user presses the ‘enter’ key, when prompted, the system should randomly select a number from the range specified earlier, and output that selected value, then prompt a second ‘enter’ press to do the same thing. The values are then added and evaluated. If the resultant score is even, a bonus of 10 is added. If the final score is odd, a deduction of 5 is awarded. If both rolls are equal, a random bonus score is added, up to 6.

2

Menu system

String values

Normal and erroneous testing will be suitable for testing this system. There are only 3 options to choose from, normal testing will test whether the options take the user to the correct gamemode, and erroneous testing will test the error message for any invalid responses

The menu is to display the title card, “DICEICLES” as coloured ASCII art, as well as an options board, which displays the three available options: PvC, PvP, and leaderboards access. The menu screen should also display a prompt for the user to select which gamemode they would like to select, by typing either 1, 2 or 3. Once the input has been passed, the system should load the correct transition to the desired gamemode, if the input is valid. Invalid inputs display an error message, and the game restarts, after a transition. The menu should also be colour formatted in the blue-blue theme of the game

My tests:

3

Transitions

String, integer, timers

Boundary and normal testing are applicable to this module. Normal testing will test how well the transition is animated, whereas boundary testing, which is automatic in this case, will test whether the animation ceases at the correct time, and successfully loads the gamemode post-animation. Erroneous testing is inapplicable due to lack of user input.

When a gamemode/the leaderboard is selected by the user in the menu, instead of the gamemode being directly imported and shown to the user, an animated “loading” transition screen should appear for about 4 seconds, or three cycles of the animation, which is the word “loading” being displayed letter by letter until it completes the word, then takes away a letter from the start of the word until there is nothing left. Once that process has occurred 3 times, the desired gamemode should appear. The transition should also appear colour formatted, using the blue-blue theme of the game.

4

Rounds system

Integer

Normal and boundary testing are suitable for testing this system. Normal testing will test the efficiency of the round transitions, whether the scores are updated per round, and if the turns are functioning properly, i.e. two turns per player per round. Boundary testing will test if the rounds stop at the end of round 5 and then evaluate if a “Sudden Death” round is required.

Once the game has been started, the variable “roundcount” should be set to 1, signalling the start of the first round. The round should progress with each player receiving two turns each (or just the one player if playing PvC). Once the turns have ceased and the total score has been evaluated for that round, the “roundcount” variable should increment by 1, progressing to the next round, where the process repeats. After “roundcount” has reached 6, this shows the 5 rounds have passed, and “breaks the cycle”, prompting the system to compare the scores of each player/ the player to the AI. If the scores are equal, then a “Sudden Death” round ensues until a winner is crowned.

 

5

Leaderboard updates/viewing

String, integer

Normal testing is the only suitable method, as there is nothing to directly input within a range of values, due to it being a storage system for player scores. The testing comes in to how it sorts the data, how the data is displayed, and how the data is added to the leaderboard itself.

Once all 5 rounds have passed, and a winner is decided through either points or sudden death, the name and final score of the winning player is exported to an external .csv file (if the AI wins in PvC, nothing is exported). The csv sorts the player into the list by score, and the “Top 5 Scorers” is to be displayed during the post-game sequence. Then the user is taken back to the menu

However, the leaderboard can be viewed via the menu screen. This is accessible by typing the designated option in the menu prompt. This will take the user to the global leaderboard, where they can view every score submitted. Once finished, there is a prompt at the bottom to take the user back to the menu.

The leaderboard will also follow the blue-blue colour scheme

6

Login verification

String, array lists

Normal and erroneous testing are suitable methods for this system. Normal testing will test if any valid names are rejected, and erroneous testing will test if any invalid names are accepted.

Once the gamemode is selected, the user is prompted to enter in a username. Once entered, the system checks it against the list of verified users. If the name is on the list, then the system allows access to the game. If the name is not present, the system sends the user back to the menu with an error message. This process is done once for the PvC gamemode and twice for the PvP gamemode.

My test screenshots:

Figure 1.1.1) Scoring: When the total is odd, the game subtracts 5 from that total.

Figure 1.1.2) Scoring: When the total is even, the game adds 10 to the total

 

 

Figure 1.2.1) Menu

Figure 1.3.1) Transition: This transition is displayed when moving between gamemodes/leaderboards/menu.

 

 

Figure 1.4.1.) Rounds: This transition screen is displayed between rounds. With the number changing per round, obviously. (Round 1 transition)

Figure 1.4.2.) Rounds: This transition screen is displayed between rounds. With the number changing per round. (Round 2 transition)

 

 

Figure 1.5.1) Leaderboards. Shows the name and score of previous winners, and orders based on score and if the game went to sudden death or not. Games that go to sudden death are placed lower, as score through that round adds to the total score, therefore would bias the result towards longer games which are a random occurrence.

 

Figure 6.1) Verification: If the name matches a name in the list, then it is accepted and allowed access

 

Figure 6.2) Verification: If the name doesn’t match a name in the list, then it is denied and not allowed access

Development

My Final program code:

 

 

 

 

 

Figure 2.1, Above) Menu Screen: The user is presented with the printed title card and 3 options, of which the user can choose between by typing the corresponding number at the prompt.

Figure 2.2.1, Above) PvP Mode: This is the initial preparation for the game before it starts, it imports the necessary functions, and sets up for the verification system

 

 

Figure 2.2.2, Above)


b

Testing

 

My tests:

Test

What am I testing?

Expected result

Pass/Fail

Do I need to change my program? If so, how?

1

Application of gamerules using IF/ELSE/OR statements (attempt 1)

Odd total scores for that round should have 5 subtracted, even total scores should have 10 added, and a double should add 10 in addition to a third roll

FAIL

The issue may lie with the amount of consecutive OR statements. The program may be getting confused, so I shall try to separate the OR statements

2

Application of gamerules using IF/ELSE/OR statements (attempt 2)

Odd total scores for that round should have 5 subtracted, even total scores should have 10 added, and a double should add 10 in addition to a third roll

FAIL

Although the OR statements are now separated, the system is still confusing odd and even values. A new method is required

3

Application of gamerules using “modulo”

Odd total scores for that round should have 5 subtracted, even total scores should have 10 added, and a double should add 10 in addition to a third roll

PASS

The system is now functional

 

 

 

Test

What am I testing?

Expected result

Pass/Fail

Do I need to change my program?  If so, how?

1

Menu links to other external modules using “open(“file.py”)

Transfer user to external file and run the contents

FAIL

Find a different solution to the file import

2

Menu links to other external modules using “import file”

Transfer user to external file and run the contents

PASS

Function works normally, possible changes could include animated transitions, although this may hinder game performance

3

Animated transitions work efficiently and can transport user to different modes

Transfer user to transition screen for 3 seconds then to expected gamemode

PASS

No changes required, game performance exceptional

 

 

 

 

 

 

 

 

 

Test

What am I testing?

Expected result

Pass/Fail

Do I need to change my program?  If so, how?

1

Coloured transitions between mode changes

Transition appears in correct colour format, animates correctly, then transfers the user to the desired gamemode

PASS

System works effectively, no changes required

 

 

Test

What am I testing?

Expected result

Pass/Fail

Do I need to change my program?  If so, how?

1

Round counter and post-5-round rules

Once all five rounds have passed, the system should check the final scores, and decide whether a winner is crowned or if a sudden death round is necessary

PASS

The system is inefficient, due to the copy-paste of the rounds. I could use a while loop or set the round as a function to be called. This would decrease the line count significantly and make my program more efficient

2

Round progression using while loop

Once the variable “roundcount” has reached 6, the system should check the final scores, and decide whether a winner is crowned or if a sudden death round is necessary

FAIL

The system works, however the previously implemented transitions cannot be re-implemented, or else the same transition would play over and over again

 

 

 

 

 

 

Test

What am I testing?

Expected result

Pass/Fail

Do I need to change my program?  If so, how?

1

Leaderboards updates: adding new players

Once the game has ended, the winners credentials are stored and exported to a .csv.

PASS

Next leaderboard function is to display the top 5 when prompted

2

Sorting exported users

The winner of the game, once exported, should be sorted into position by score

3

Leaderboard: displayed when prompted

After the winners’ credentials have been exported and stored, the game should display the top 5 scores

 

 

 

My test screenshots: Menu and menu functionality:

 

Figure 1: my first attempt at linking the gamemodes to the menu. It failed.

Test 1: I tried to open the external file using a similar method to opening CSV files. However, due to .py and .csv files having different properties, as expected, the file would not open as intended.

Test 2: After researching a different method, I found that the issue could be easily resolved by using the “import” function. With this, when the user types in the option they want, for example “1”, the menu imports the selected gamemode from the file tree and runs the code within that file. For the purpose of this test, when I selected option “1”, the expected output was a cleared screen with “success 2” printed. This would show that the file has been successfully imported and executed in place of the menu. The expected output was achieved, as seen in figure 5. When option “2” was selected, the expected output would be the screen would be cleared and would then display “SUCCESS”. This was also achieved. Option “3” clears the screen and displays “success 1, and 2, and 3” on successive lines. This shows that the CSV has been imported and is displaying information correctly.

Figure 2, above: program code

Figure 3: menu with error encountered with my first attempt at linking multiple files.

Figure 5: result of running the code with the variable “gamemode” equalling “3” (Initial menu Test)

Figure 4: outcome of running the code with the variable “gamemode” equalling “1” (Initial menu Test)

 

Evaluation

              Evaluate how successful your program was.  You may find it useful to refer back to your tests

              You should reflect on any new skills you have developed

 

This section should be approximately 200-500 words.

 

How successful was my program?

My program was a huge success in terms of functionality, design and potential customer appeal. Every module for every function worked as intended, after some tweaking from the initial attempts, they run smoothly (although held back by the platform the program is being run on, some transitions are skipped/run for too long. This is not an issue with my actual work, as the bugs are random.), and look well-presented and colourful, despite Codio’s UI limitations.

 Success criteria Review:

  1. UI is clean and easy to use and read
  2. UI is colourful and appealing to the user
  3. Gameplay Mechanics simple and easy to learn
  4. Gameplay mechanics function normally
  5. Scoring system mechanics function normally
  6. “Sudden Death” rounds loop efficiently
  7. Rounds counter functioning normally
  8. Username validation blocks/allows appropriate names
  9. Leaderboards can be updated and function normally
  10. Leaderboards can be viewed at any time from the menu screen
  11. Menu screen does give option of PvC, PvP and the full leaderboard

 

 

 

What new skills have I developed?

 

Bibliography

References:

  • Apc, “How can I make one python file run another? [duplicate]”, [2011], “https://stackoverflow.com/questions/7974849/how-can-i-make-one-python-file-run-another” , Date Visited: 5/10/18
  • Patorjk, “Text to ASCII art converter”, [Date Unspecified], “http://patorjk.com/software/taag/”, Dates Visited: 3/10/18, 5/10/18, 9/10/18

Cite This Work

To export a reference to this article please select a referencing stye below:

Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.
Reference Copied to Clipboard.

Related Services

View all

DMCA / Removal Request

If you are the original writer of this essay and no longer wish to have the essay published on the UK Essays website then please: