Homework 01

Due: 2016-09-15T23:59:59

Introduction

Civilization is a turn-based strategy game centered around founding and building a civilization. More commonly referred to as Sid Meier’s Civilization, the game has been around since 1991 and has since developed somewhat of a cult following. This semester we are going to be implementing our own version of this game for your homework assignments and by the end of the semester you will have a working game you can show off to your friends! If you are not familiar with Civilization, there is a free version that you can play in order to get familiar with the game.

This assignment will get you ramped up on Java syntax and the basics of the language. This project will:

Problem Description

Civilization is a turn-based strategy game revolving around moving units around a map to conquer other civilizations to reach the highest point in the technology tree. For this first assignment we will focus on creating a small command line version of the game that interacts with a player.

Before we begin..

We will be using git for homework submissions. Git is a Version Control System. I highly suggest you learn how to use git through either here, here, or by doing your own research and reading. We outline step by step how to get everything set up below for you.

Do not change your username on github. It should remain your GT username as was given to you by the institute. For example, I changed my email a long tim ago to be tjhartman@gatech.edu, but my github account name is still thartman3. If you change your name you will just be making everyone’s lives more difficult this semester. So just don’t do it.

Setting up a Git Repository

Before you start coding, you need to do a little bit of set up in order to be able to turn your homework in through git.

In your web browser…

  1. First and foremost, if you do not have git installed, you need to install it.
  2. Once you have it installed, go to github.gatech.edu and login with your GT credentials.
  3. When you reach the landing page, on the right side there should be a “Your Repositories” list. Click on the button that says “New Repository”
  4. In the textbox for Repository Name put “civilization_fall16”. For example, to access my repository my url would be github.gatech.edu/thartman3/civilization_fall16.
  5. Next, make your repository “private.” This is very important! If your repository is public other people will be able to see your code. This will be considered an honor code violation.
  6. Next, check the box next to where it says “initialize with a README”
  7. Next, in the drop down menu where it says “Add .gitignore:” select Java from that dropdown menu.
  8. Now select “create repository”
  9. You should have been taken to the location of your repository on github. You will see a bar that looks like the bar shown below. Click on the button circled below. This copies a link to your clipboard.
  10. Go to “Settings.” This is your repository’s settings. You could change stuff here if this were a repository for personal use, but since it’s for homework leave everything unless we tell you to change it!
  11. On the left hand side select “Collaborators”. You will be asked to confirm your credentials.
  12. Add me, “thartman3”, as a collaborator. I will add other TAs as collaborators for you. There should not be any other collaborators on your homework repository. If there are others this will be considered an honor code violation.

Now, inside of your command line…

  1. Open up the command line and cd into a directory where you want to keep your homework.
  2. Type git clone and then paste the link you copied from github in step 9 above.
    • For example, I would type git clone https://github.gatech.edu/thartman3/civilization_fall16.git
    • It might ask you to type in your credentials again. When you start to type your password it won’t show up on the screen, but just type it out correctly and hit enter.
  3. ls or dir and you should see a folder called civilization_fall16 in your directory!

Great! Now you have basic set up done.

Your first push

In order to start writing code, you actually need a file to start with. Download Civilization.java into your civilization_fall16 directory.

Now do the following:

  1. cd into civilization_fall16 in your command line.
  2. Type git status
    • You should see that you have an “Untracked File” called Civilization.java
    • We want to add this file to be “staged for commit.” We’ll get into what that is in just a bit.
  3. Type git add Civilization.java
  4. Type git status
    • Now you can see that Civilization.java is listed as a “change to be committed”
  5. Now we want to commit our change. What this means is that on our local machine (our laptop, for example) we changed our project and we want to make sure that change gets reflected in our repository on github!
    • To commmit type git commit -m "My first commit and adding Civilization.java". The part in quotes is your commit message. This message will tell anyone who takes a look at your repository’s commit history what you changed or did every time you committed.
    • Now that we have committed our changes we actually want to “push” them up to our repository on github.
  6. Type git pull origin master. This brings your local version of your repository on your machine up to date with the remote version of your repository on github. Alwasy pull before you push!
  7. Type git push origin master. This pushes all of the changes you committed on your local repository up to the remote repository.

If you go back to github.gatech.edu and go look at your repository you will see that Civilization.java is now in your remote repository!

As you work…

Any time you get some code written and running you should push your changes up to the remote repository:

  1. Type git status to see what changes are staged or unstaged
  2. Type git add * to add all changes you have made to be staged for commit
  3. Type git commit -m "My message" to commit your changes to your local repository.
  4. Type git pull origin master to make sure you are up-to-date with the remote version of the repository.
  5. Type git push origin master to push your changes up to the remote repository.

Solution Description

Starting the Game

Gameplay

Ending the Game

Tips, Tricks, and Warnings

Checkstyle

Peruse the CS1331 style guide here. This also has the instructions for how to run checkstyle on your code. Here’s a more step-by-step rundown:

What gets printed out is the list of all style errors your code has. Do your best to fix all of them and start coding in the correct style. Each individual checkstyle error results in -1 points on your assignment.

Maximum number of points you can lose on Checkstyle this assignment: 0

Turn-in Procedure

In order to submit your assignment you need to ensure that your working code is pushed to your remote repository by the due date! Follow the instructions outlined above to push your code to your remote repository!

You should only have one .java file: Civilization.java.

Verifying Your Submission

Please be sure that any code you push compiles and runs through the command line! Pull from your repository and make sure everything is working how you want it!