compete against another program

Your program will compete against another program, the programs will communicate with each other by reading and writing from a shared file on the hard drive. Each program will take turns adding a letter to an ever-growing word fragment in the shared file. Before adding a letter to the file your program should figure out what the next best letter to play is. It should maintain the current word fragment and use methods in a class that extends to find the next letter to choose. There is a third program written by the professor, called the arbiter, that will officiate the game. The arbiter will also read and write to the shared file to communicate with the programs. The arbiter is responsible for starting and stopping the game as well as notifying each program when it is there turn. The arbiter will use a dictionary containing more than 100K words to decide if a word greater then 3 characters has been made or if a fragment has any possibility of creating a word. The arbiter will pass the file path of the shared file to your program as a Runtime argument. In your program’s public static main(String[] args) function args parameter will be an array of length 1 and the first index will contain the file path to the shared file. 

Conditions to Win

1) Your opponent creates a word

2) Your opponent creates a word fragment that has no chance of becoming a word

3) Your opponent takes more than 15 seconds to write their letter to the shared file

4) Your opponent writes text to the shared file that does not conform to the game Text Formate Guidelines

5) Your opponent does not submit a program

Text formate Guidelines

There are very simple rules that each program must follow when writing to the shared file. A program can only write to the share text file when it is their turn. And when they do write to the file they must follow the formatting pattern YOUR_FORMATED_TEAM_NAME+DELIMITER+(Your selected letter). Each line of text in the file will contain Key Words that can be used to figure out the state of the game and who’s turn it is. 

Key Words

GAME_START = “GAME_START”- denotes the game has begun

GAME_OVER = “GAME_OVER”- denotes the game is over 

TURN = “TURN” – denotes a turn

DELIMITER = “:” –  a value that separates values 

YOUR_FORMATTED_TEAM_NAME = [Your team name] – your team name with all the white space removed and in all capital letters. 

You will know when it is your turn when a line equal to YOUR_FORMATED_TEAM_NAME+DELIMITER+TURN is written to the file by the arbiter. You can only use standard American English ASCII alphabetical letters for your selection, no digits or punctuation marks. You need not worry about writing code for proper text formatting and parsing as it has already been done for you in the class This class contains methods that you can use to tell if it is your turn and to properly format your text. It is highly recommended that you used this class to parse and format your text as all the code has been written for you and it is well tested. Below you will find example text written to the shared file in a hypothetical game between “Team 1” and “Team 2”:

Example Text File













General Logic

First, your program should use a class that extends to monitor the shared file for changes and then use a class the extends to figure out the next letter to play. Your dictionary is expected to read from a dictionary text file of your choice that will accompany your program. Next, it should use the to decipher the changes and to properly format text to write to the file. Lastly, it should use a class or classes that implement and to read and write to the file. Below you will find a programmatic flow chart that I made to help you get started 

Logic For Your AI

If you are the first team you can only win if you attempt to create words with an even number of characters and if your the second team you can only win if you create words with an odd number of characters. Keep in mind the not all even/odd words will lead to victory as some of these words contain sub-words within them. So don’t try to create words that have smaller winning words for your opponent. Always keep the system as simple as possible.

To start GhostApp.jar 

Use the following command in terminal or command prompt: java -jar [File Path to SGhostApp.jar] [Optional – min word length (Default 6)] [File Path to a Ghost App] [Optional -File Path to a Ghost App (Defaults to user Testing Gui mode if not specified)]

example for user testing with a minimum length of 6 characters:

java -jar /Users/HWilliams/Desktop/SGhostApp.jar /Users/HWilliams/Desktop/My_Ghost_App.jar

example for a head to head competition with a minimum length of 8 characters:

java -jar /Users/HWilliams/Desktop/SGhostApp.jar 8 /Users/HWilliams/Desktop/My_Ghost_App.jar /Users/HWilliams/Desktop/Opponent_Ghost_App.jar 

Leave a Reply

Your email address will not be published. Required fields are marked *