CSCI-4150 - Homework 1 - Due: Mon, Feb 11, 11:59:59 PM

Homework Description:

Before starting this homework, you may want to play around with the Yahoo! Arrows game to help you understand it better. Here are some slides with snapshots from the game.


You will implement two search algorithms capable of finding a goal state (aka board configuration) with the maximum reward to the Yahoo! Arrows game. A Java framework will be given to you which will represent the arrow board, the rules for moving the pieces and a function to check to see if it's a valid solution. You are responsible for extending this framework and implementing various search algorithms so that given a particular configuration, you program will be able to find the desired solution in a timely manner. Your program is also required to return the intermediate states between the initial configuration and the final state.

Board: The board consists of three types of objects: red arrows, blue arrows and spaces. The standard yahoo game starts out with all of the red arrows on the left side, all of the blue arrows on the right side and a space in the middle. However, your program should be able to start from any input state. The goal of the game is to move all of the blue arrows to the left side and all of the red arrows to the right side while following certain rules. The board will be represented in the code as char's with red arrows = 'r', blue arrows = 'b' and spaces = 's'. The initial configuration is a string consisted of these characters. Example: the Yahoo! Arrows game is "rrrrsbbbb" and the solution is "bbbbsrrrr"

Moving: Red arrows can only move to the right and blue arrows can only move to the left and they must move into a space. An arrow can only move into a space if that space is right next to the arrow or if a single arrow of the opposite color is between it and a space. See the Yahoo! game.

Rewards: A constant rewards is given to each valid move. If you reach the goal/solution state, you receive an infinite reward. The objective of the game is to maximize the total reward.

Code:

You will be given the code to several Java classes to help you get started: Provided Source Code. A link to the Java Collections Framework is provided (bottom of page). This framework contains a lot of classes which you will find useful. Using them is very much like using the STL libraries in C++. Note that using the framework is optional. It is provided for your convenience.

Classes:

Running the provided code:
The code given to you will be a zip file with the java files stored in a src folder with a makefile and a Manifest.txt file in main folder. If you are compiling and running from the command line, use the makefile with the commands "make" and "make run". If you are using an IDE such as Eclipse or NetBeans, simply create a new project and either import the code with the IDE's functions or just copy the .java files into whichever folder your project is saved in.
When running the project, you can either give it an argument or provide one when the program starts for the initial configuration. You should be able to type in an input from the console panel of both Eclipse and NetBeans.

Goals:

We will be testing your search algorithm on various inputs such as "rrsbbsr", "rsbsrsbs" and other arbitrary configurations. Therefore, just hard coding a solution to a problem similar to the Yahoo! games one will not work. The path that you program should produce will be consisted of an array of ArrowBoard objects with the first object in the array representing the initial state and the last one representing the final state. This path must be stored in the public variables within the ArrowBoardSolver class for the two search algorithms. You also must set the numNodes variables to the number of total nodes that you visit in your searches. You algorithm must also produce a result within a reasonable time of 3-4 minutes per run.

  1. Find a path to a state with the maximum reward given an arrow board state through an exhaustive search by trying all possibilities for the search path. Fill in the function solveExhaustive(ArrowBoard board) and place the resulting path in pathExhaustive and the number of nodes in numNodesExhaustive. For this part, implement Iterative Deepening search technique.
  2. Find a path to a state with the maximum reward using A*. Design your heuristics so that it outputs a solution on a large input configurations (e.g. input of length 15-30). We will impose a restriction on the number of nodes that can be generated. Fill in the function solveHeuristics(ArrowBoard board, int maxNodes) and place the resulting path in pathHeuristics and the number of nodes in numNodesHeuristics. You should increment a counter every time a node is visited and must terminate when maxNodes is reached (outputting the best solution found so far).

Grading:

50% will be automatically taken off from submissions that do not compile. Therefore, make absolutely sure that your code will work with the code that we provide, specifically the Main and Utilities class. We will be testing the solution paths that you will provide by running your array of ArrowBoard objects through the isValidPath(ArrowBoard[] board) function in the Utilities class. This function is provided for you to test your solutions before submission. We will also be checking the numNodes variables. If your program takes more than a reasonable time (> 5 mins) to run, 10% of your grade will be taken off.

Submitting:

Submit the following items in a zip file.

  1. ArrowBoardSolver.java, ArrowBoard.java and any other classes that your program needs. You should not be submitting your own versions of Main.java or Utilities.java because we will be using the ones that we provide and will overwrite yours.
  2. A readme describing what files you are submitting, any problems that you encountered and anything else that you need to explain or feel that we should know.
  3. A pdf file that contains both of your algorithms in pseudo-code and an explanation + justification of your heuristic in plain English.
Submit your code at the following web page: https://cgi.cs.rpi.edu/submit/submit.html?course=ai.

Links:

Arrows Yahoo! Games
Provided Source Code

Java SE 6 API Documentation
Java Collections Framework Overview Outline Tutorial

Hints: Please come to Wei's office hours if you cannot get the provided code to compile and run. Do not wait until the last day to start learning Java.