Fundamentals Lite
  • πŸš€Course Overview
  • Course Logistics
    • 🏫Course Methodology
      • 🧩Course Components
      • πŸ’¬Course Communication
    • πŸ’»Required Hardware and Software
      • ☝️Required Software 1
      • ✌️Required Software 2
      • πŸ‘Recommended Setup
    • πŸ“…Schedule
    • πŸ’‘Tips and Tricks
      • πŸ“’Coding Strategies
      • πŸ› οΈTooling Pro Tips
    • πŸŽ“Post-Course
      • πŸš€Upgrading to Paid Fundamentals
      • πŸš‚Bootcamp Admission Criteria
      • πŸ“ΉBootcamp Video Application
  • 1: Introduction
    • 1.1: What is Coding?
    • 1.2: Web Browsers
    • 1.3: Command Line
    • Additional Resources 1
  • 2: Basic Data Manipulation
    • 2.1: Operations
    • 2.2: Variables
    • 2.3: Our First Program
    • Additional Resources 2
  • 3: Structuring and Debugging Code
    • 3.1: Functions
    • 3.2: Errors
    • Additional Resources 3
  • 4: Conditional Logic
    • 4.1: Intro to Logic
    • 4.2: Pseudo-Code, Boolean OR
    • 4.3: Boolean AND, NOT
    • 4.4: Input Validation
    • Additional Resources 4
  • 5: Managing State and Input Validation
    • 5.1: Program Lifecycle and State
    • 5.2: Program State for Game Modes
    • Additional Resources 5
  • 6: Arrays and Iteration
    • 6.1: Arrays
    • 6.2: Loops
    • 6.3: Loops with Arrays
    • Additional Resources 6
  • 7: Version Control
    • 7.1: Git
    • Additional Resources 7
  • 8: GitHub
    • 8.1: Intro to GitHub
    • 8.2: GitHub Fork and Clone
    • 8.3: GitHub Pull Request
    • 8.4: GitHub Repo Browsing
    • 8.5: Deployment
    • Additional Resources 8
  • Homeworks
    • Day 2: Basic File and Data Manipulation
    • Day 3: Functions
    • Day 4: If Statements, Boolean Or, Boolean And
    • Day 5: Program State
    • Day 7: Loops
    • Day 8: Arrays and Loops
  • Projects
    • Project 1: Scissors Paper Stone
      • Project 1: Scissors Paper Stone (Part 1)
      • Project 1: Scissors Paper Stone (Part 2)
    • Project 2: Beat That!
Powered by GitBook
On this page
  • Introduction
  • Setup
  • Base
  • Requirements
  • Example
  • Walkthrough
  • Comfortable
  • Add some polish!
  • More Comfortable
  • Submit
  • Reference Solution
  1. Projects

Project 2: Beat That!

PreviousProject 1: Scissors Paper Stone (Part 2)

Last updated 2 years ago

Introduction

Create a version of the Beat That dice game, where players create the largest number they can by concatenating random dice roll digits. Read the rules for Beat That .

Have a look a some past student's project to visualise the game - and for inspiration :)

Setup

  1. Fork and Clone the .

Base

Requirements

  1. There are 2 players and players take turns.

  2. When a player clicks Submit, the game rolls 2 dice and shows the dice rolls, for example 3 and 6.

  3. The player picks the order of the dice they want. For example, if they wanted the number 63, they would specify that the 2nd dice goes first. You can choose how the player specifies dice order.

  4. After both players have rolled and chosen dice order, the player with the higher combined number wins.

Example

Player 1 rolls 2 dice with dice rolls 3 for Dice 1 and 6 for Dice 2.

Welcome Player 1.
You rolled 3 for Dice 1 and 6 for Dice 2.
Choose the order of the dice.

Player 1 can pick either Dice 1 or Dice 2 as the first numeral of the combined number.

Player 1, you chose Dice 2 first.
Your number is 63.
It is now Player 2's turn.

Player 1 picked Dice 2 as the 1st numeral and Dice 1 as the 2nd, thus generating the combined number 63. Player 2 then rolls 2 dice and tries to generate a number greater than 63.

Walkthrough

If you get stuck, or are unsure on how to start, Bryan will walk you through how to go from breaking down the problem to completion of the Base version of Beat That!

Comfortable

Add some polish!

#container {
  background-color: lightblue;
  margin: 40px auto;
  max-width: 800px;
  padding: 38px 31px;
}
...
<body>
    <h1 id="header">Fundamentals: Beat That! πŸš€</h1>
    <div id="container">
      <p>Hello! Welcome to Beat That! Click submit to start the game.</p>
      <p>Create a two-digit number by selecting the order of your dice rolls.</p>
      <p>The player with the highest number wins! Good luck!</p>
      <p>Input:</p>
      <input id="input-field" />
      <br />
      <button id="submit-button">Submit</button>
      <p>Output:</p>
      <div id="output-div"></div>
    </div>
...

Having fun making your game look good? Feel free to explore more HTML and CSS on your own! Here are some resources:

More Comfortable

Try implementing some, or a combination of, the following feature groups. Feel free to include any other additional features you think of.

Score

Keep score for each player. The score is the running sum of all numbers that player has generated so far. This means there is no permanent winner, only a temporary leader.

Leaderboard

When outputting game results in the output box, also output a leaderboard that lists the 2 players and their scores in decreasing order.

Lowest Combined Number Mode

Add a game mode such that the player with the lowest combined number is the winner.

Auto-Generate Combined Number

Update the game to auto-generate the highest (or lowest) combined number from dice rolls. For example, for dice rolls [6, 3] in Lowest Combined Number mode, the game would auto-generate the combined number 36.

Variable Number of Dice

  1. Create a new version of Beat That that rolls two or more dice per player.

  2. At the beginning of each round, ask the players how many dice they would like to play with. Both players will roll the same number of dice each round.

  3. Store each player's dice rolls in an array. When each player rolls dice, use a loop to place n dice roll values in that player's array, where n is the number of dice the players specified at the beginning of the round. Output each player's dice roll values.

  4. Auto-generate the optimal combined number based on each player's dice rolls to determine the winner of that round.

Variable Number of Players

Allow more than 2 players at a time to play Beat That. At the beginning of the game, ask how many players would like to play. For a variable number of players, feel free to output the leaderboard in any order, because implementing the leaderboard in decreasing order requires advanced logic.

Knockout Mode

Create a mode where if there are more than 2 players, the game can match players against each other 1 at a time until there is 1 final winner. For example, if there are 4 players, the game might first match players 1 and 2. If player 1 wins, the game might then match players 1 and 3. The winner of that match would then play player 4, and the winner of that final round would be the ultimate winner.

Submit

Reference Solution

Please only refer to the reference solution after you have attempted the project. Note that there are many ways to implement the project and the reference solution is only 1 way.

Your game is working as intended, now it's time to make it look good! We'll edit index.html to personalise our game. If needed, review on how to edit HTML.

At line 29 of index.html, try changing background-color: pink; to background-color: lightblue; or any of your choice!

Add 1 or more after line 64 with instructions on how to play Beat That! It can look something like this:

FreeCodeCamp's and basic

W3School's CSS and .

Congrats on finishing! If you would like Rocket to review your code and share individual feedback, please join the paid version of our Fundamentals course by emailing and letting us know you would like to transfer. If you plan to join Rocket’s Bootcamp, we highly recommend joining paid Fundamentals. Thank you!

(includes Score, Leaderboard, and Lowest Combined Number Mode)

here
Base
Comfortable
Super Comfortable
Fundamentals Beat That! repo
1.2 Web Browsers
colour
paragraphs
basic HTML
CSS tutorials
Tutorial
Reference
jill@rocketacademy.co
Base
Auto-Generate Combined Number
Variable Number of Dice
Variable Number of Players
Knockout mode