The goal of this assignment is to introduce you to intelligent agents, and at the same time, get you familiar with Git and Maven, which will be used for all the assignments in this course.
-
If it is not already installed, install Git on your local machine.
-
If it is not already installed, install Maven on your local machine.
-
Start reading the Git book. Minimally, read Chapter 1 (Getting Started), which will teach you basic version control concepts, and Chapter 2 (Git Basics), which will teach you the most common commands.
-
Read the Maven Getting Started Guide, which will teach you how to compile and test code using Maven.
-
Sign into https://git.cis.uab.edu using your CIS credentials (not your UAB credentials).
-
Set up SSH access for your account. Go to https://git.cis.uab.edu/profile/keys and follow the instructions there to add an SSH key.
-
Fork the repository for the current assignment, https://git.cis.uab.edu/cs-460/agents-blackjack, by following the link, and clicking on the "Fork" button on the right hand side of the "CS 460 / Agents - Blackjack" page.
-
Give your instructor access to your fork. I cannot grade your assignment unless you complete this step. Click on
Settings
, thenMembers
, thenNew Project Member
. In thePeople
box, search for and add the userbethard
. UnderProject Access
, selectReporter
. Then clickAdd users
. -
Copy the code from your fork at
git.cis.uab.edu
to your local machine so that you can start editing it. Run the following command, replacing<url>
with the URL displayed at the top of your fork's webpage (which looks something likegit@git.cis.uab.edu:.../agents-blackjack.git
):git clone <url>
-
You should see that a directory named
agents-blackjack
has been created and populated. Change to that directory:cd agents-blackjack
-
Compile the code. Run the following command:
mvn clean compile
Everything should compile and you should see a message like:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
-
Test the code. Run the following command:
mvn clean test
The tests should fail, and you should see a message like:
Tests in error: testTenKing(edu.uab.cis.agents.blackjack.DealerAgentTest) testSixJack(edu.uab.cis.agents.blackjack.DealerAgentTest) Tests run: 2, Failures: 0, Errors: 2, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------
Note the
clean
, which ensures that Maven alone (not your development environment) is compiling your code.
If you look closely at the test failures, you will see that the problem is that edu.uab.cis.agents.blackjack.DealerAgent.act
is throwing a java.lang.UnsupportedOperationException
.
Your task is to correctly implement edu.uab.cis.agents.blackjack.DealerAgent.act
by modifying src/main/java/edu/uab/cis/agents/blackjack/DealerAgent.java
. Your agent should implement the following rules:
- If the total points represented by the cards are:
- 16 or less,
act
should returnAction.HIT
- Between 17 and 22,
act
should returnAction.STAND
- 22 or more,
act
should returnAction.BUST
.
- 16 or less,
- In calculating the total points, the order of the cards does not matter, only the point values.
- The numeric cards always count for the equivalent number of points (TWO=2, THREE=3, ..., TEN=10).
- JACK, QUEEN and KING always count for 10 points.
- Each ACE counts for 11 points, unless it would cause the total points to be 22 or more, in which case it counts for 1 point.
You may modify only src/main/java/edu/uab/cis/agents/blackjack/DealerAgent.java
and src/test/java/edu/uab/cis/agents/blackjack/DealerAgentTest.java
. Do not modify any other files. If you need to declare any additional classes, please do so in one of these files.
-
Re-run the tests:
mvn clean test
You should now see a message like:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
Your code is now passing the tests that were given to you. This is a good sign, but note that a successful
mvn test
does not guarantee you full credit on an assignment. We will run extra tests on your code when grading it. For example, the tests you have been given do not test your handling of ACE cards.
-
As you make changes to the code, you should regularly save them to the Git repository. First, add any files with changes to the Git staging area. For this assignment, that will typically mean running something like the following command:
git add src/main/java/edu/uab/cis/agents/blackjack/DealerAgent.java
-
Then commit all the staged changes to your local Git clone. Run the following command, providing an informative commit message:
git commit -m "...your comment about what you changed in the code..."
-
Push your local commits to your remote Git repository on
git.cis.uab.edu
. Run the following command:git push
-
Verify that your changes have been pushed. Go to
https://git.cis.uab.edu/.../agents-blackjack
, where...
is your CIS username. You should see your newest commit displayed near the top of the page. -
You should repeat this process regularly while you edit your code to make sure that your in-progress work is always backed up.
-
To submit your assignment, just make sure that you have pushed all of your changes to
git.cis.uab.edu
. -
I will inspect the date of your last push to your
git.cis.uab.edu
repository. If it is after the deadline, your submission will be marked as late. So please do not push changes togit.cis.uab.edu
after the assignment deadline unless you intend to submit a late assignment.