JS211_Towers of HanoiCircleCI

Austin Coding Academy

JavaScript 211 Project: Towers of Hanoi

Overview

  • Towers of Hanoi is a simple logic game involving three stacks. The first stack has four (or more) blocks, each one bigger than the next, stacked like a pyramid. The point of the game is to move the blocks from one stack and arrange them in the same order into another stack, but never placing a larger block onto a smaller block. You can play the game here to get an idea.

Your checkpoint is really a terminal app; which is what you'll be graded on. However, you should push to use the DOM and create a GUI for this game.

Checklist

  1. 20pts - Code Plan - Include this in a README.md file in your folder with comments in your code
  2. 10pts - Move Blocks - User can move "blocks" from column to column
  3. 20pts - Illegal Moves - Prevents larger blocks from stacking on smaller blocks
  4. 20pts - Notifies winner - When all the blocks are stacked into column 2 or 1 the user is alerted they won!
  5. 20pts - Minimum 3 Unit Tests - Should be attached to your file the same way Tic, Tac, Toe, PigLatin or Rock Paper Scissors is done.
  6. 10pts - Graphical User Interface - Take this game out of the terminal by adding a User Interface that uses towersOfHanoi() function in index.js.
  • Extended Practice Bonus!!
    • Keeps count of moves as player plays games
    • Sound Effects
    • Peaceful Background
    • Vertical columns
    • Proportional Stones/tokens

Example

Dissect the following game to get an insight on how to build Towers of Hanoi with a GUI

Instructions

  1. Once you understand the game, whiteboard the logic.
  2. Create a list of steps your app need to do.
  3. Translate to psuedo code.
  4. Translate to JavaScript on paper
  5. Write 3 tests for the app.
  6. Build Towers of Hanoi, so it passes all the tests.
  7. Create a new branch called " checkpoint-1 "
  8. Build toward the tests.
  9. Use the starter code below:

Follow-up Video

<iframe src="https://player.vimeo.com/video/339373348" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>

Getting Started

  1. Fork and Clone Towers of Hanoi Repo
  2. Ensure you have installed all dependencies/packages: npm i
  3. Look at the Unit Test, see what is being called, passed as input arguments, and what the expected result are.
  4. Ensure you know how to run the unit test:
    • npm test main.js
  5. Use a whiteboard to work out a solution to building the Pig Latin program
  6. Translate the broad ideas to psuedo code
  7. Convert the psuedo code to real JavaScript Code
  8. Type into your text editor the JavaScript code you've come up with one step at a time
  9. Work through your bugs.
  10. Use node main.js to run the game.
  11. Achieve green checks for each of your unit tests.

Hints

  1. Run your unit tests first!!
  2. Use repl.it to write the solution code first. (its a faster environment vs using the node main.js command over and over again.)
  3. Read the comments in main.js
  4. Push yourself further.
  5. Look at your hints!
  6. Clone, setup, testing, and running instructions for all projects is below

Cloning Your Project

  1. Click the 'Fork' button (choose your account if prompted).

  2. Copy HTTPS URL from your forked repository

  3. In your terminal/gitBash/CommandPrompt navigate (using cd) into a directory where you want to start keeping your repositories. (/jsDevFolder)

  4. Clone your new repository by typing git clone <forked clone URL> (the HTTPS URL you copied above) Forking a repository

  5. Now go into the new directory by using cd project-repo

  6. Add the base repository as an upstream git remote add upstream https://github.com/AustinCodingAcademy/<PROJECT-REPO>.git

  7. Check the configuration of your remotes with git remote -v, it should look very similar to this (except it'll be YOUR username)

$ git remote -v

origin  git@github.com:username/javascript-workbook.git (fetch)
origin  git@github.com:username/javascript-workbook.git (push)
upstream    git@github.com:AustinCodingAcademy/javascript-workbook.git (fetch)
upstream    git@github.com:AustinCodingAcademy/javascript-workbook.git (push)

Setup

  1. From your project directory, run npm i to tell NPM to install all the node modules we use in this class (see package.json)

  2. Use your textEditor (VS Code) to change your files.

  3. When you're finished git status, stage your file git add ., commit your changes git commit -m "functions working", and push to GitHub git push

    git status
    git add .
    git commit -m "Initial Commit"
    git push origin gh-pages
  4. Now go to your forked repository on GitHub (at https://github.com/your-username/javascript-workbook). A little yellow box should have popped up asking you to make a Pull Request. Click to review.

  5. Click "Create Pull Request"

  6. Every time you make a change and push to GitHub, this PR will automatically update. No need to do it more than once.

Get latest workbook updates

  1. To get the latest code/homework/test updates, be sure to have a "clean working directory" by committing or removing all of your changes. You check for a "clean working environment" by running git status and making sure no files show up.

  2. Run git pull upstream gh-pages

Contributing workflow

Running the apps

Simply run node path/to/file.js

example node 01week/rockPaperScissors.js

Running Tests

Tests are a great way to make sure you code works the way you planned it would, and to make sure you don't break something in the future. We will be using them to test our understanding of the lesson. It's also our main way to assign grades for an assignment.

To run a the tests on a file run npm test path/to/file.js, etc.

Running the Linter

Simply run npm run lint

Running the Server

  1. Run npm start
  2. To break out of the server, press ctrl + c