Skip to content

daniel-bulger/ConnectFourModerator

Repository files navigation

<html>

<body>
<h1>Connect 4 Moderator</h1>
<p>
<h2>Contents</h2>
<p>
<a href="#purpose">Purpose</a><br />
<a href="#start">Start a game</a><br />
<a href="#manual">Manual mode</a><br />
<a href="#bot">Creating a player bot</a><br />
<a href="#end">End of game</a><br />
<a href="#log">Log file</a><br />
<a href="#console">Running from the console (command prompt)</a><br />
<p>
<a name="purpose"><h3>Purpose:</h3></a>
	The Connect 4 Moderator is intended to allow two artificially intelligent computer programs to play Connect 4 against each other,
	to let an AI play against a human, or to let two people play against each other.
<br />
</p><p>
<a name="start"><h3>Start a Game:</h3></a>
	Choose the directory from which to load the programs.<br />
	Select the desired programs in the boxes labeled "player 1" and "player 2"<br />
	If a program loads correctly, a ready message is displayed in the output console.  Otherwise an error message will be displayed.<br />
	Click the Go button to begin the game.<br />
</p><p>
<a name="manual"><h3>Manual mode:</h3></a>
	Alternatively, either player (or both) can be human controlled. To do so, select "MANUAL" from the desired player's program selection box. <br />
	To place a piece while in manual mode, simply click on the board in the desired column.<br />
</p>
<p>
<a name="bot"><h3>Creating a player bot:</h3></a>
<ul>
	<li>The Connect 4 Moderator can control any program that uses the standard output stream to output data (c++ programs, python programs, java programs, etc...).  It launches the program, then captures its console output.
	</li><li>It sends input to the program via standard input just as if a person were sitting at the console
	</li><li>Player programs must first output a lowercase "p" character. They should then wait for input indicating who goes first (1 or 2).
	</li><li>If 1 is received, the program must output its first move (1 through 7). 
	</li><li>If 2 is received the player program must output "?" to indicate it is ready.
	</li><li>The next input each program will receive will be the number 1-7 indicating the opponents move.
	</li><li>They should process this, then output the number of their next move when ready. 
	</li><li>As soon as it's available, they will be sent the opponents next move and play will continue in this way.
	</li><li>Player programs are responsible for keeping track of the board. The only communication between them and the moderator will be a single integer indicating the column of the opponents move.
	</li><li>Players are responsible for keeping track of the number of times a column has been played. Playing in a full column will cause the game to end in an error. 
</li></ul></p><p>
<a name="end"><h3>End of Game:</h3></a>
The game ends when one of the players gets 4 in a row, when it is a tie, or when a player makes an illegal move (e.g. tries to put a piece into a column that is full, or outputs anything other than one of the expected characters)
On a game end condition, your program will be sent one of the following codes:
<ul><li>0: ERROR
</li><li>-1: Player 1 wins
</li><li>-2: Player 2 wins
</li><li>-3: Tie game
</li></ul>
Your program is expected to exit on receiving one of these codes, but there is no penalty for failing to exit. 
</p><p>
<a name="log"><h3>Log File:</h3></a>

	The moderator creates a log file of the game named log.txt in its working directory. 
	The log will contain one line for every game played.
	Each line will contain a string of integers listing each move made during the game. An example is detailed below.
<br />
	The log would contain:
	<ul><li>  43557644322313
    </ul>  
	And here is the flow of the actual game:
	<ul><li>  Player 1 :4
	</li><li>  Player 2 :3
	</li><li>  Player 1 :5
	</li><li>  Player 2 :5
	</li><li>  Player 1 :7
	</li><li>  Player 2 :6
	 </li><li> Player 1 :4
</li><li>	  Player 2 :4
	 </li><li> Player 1 :3
</li><li>	  Player 2 :2
	 </li><li> Player 1 :2
	</li><li>  Player 2 :3
	</li><li>  Player 1 :1
	</li><li>  Player 2 :3
	</li><li>  Player 2 Wins
</li></ul>
	As you can see, the log makes no indication of which player made which move or which player won, it simply lists all the moves in the order they were made.
	You must determine who was the winner, if there was an error, or if the game ended prematurely.
	The log can be used for programs that try to learn from past games.
</p>
<a name="console"><h3>Running from the console:</h3></a>
<p>While the main intended usage of this application is as a GUI, it does have limited console functionality.  When passed arguments from the command line, the app will
 play one game and then exit.</p>
<p>Usage: './ConnectFourModerator AI/file/path1.exe AI/file/path2.exe'</p>
<p>To use a manual player, pass MANUAL_MODE as an argument instead of one or both of the file names</p>
<h4>Console IO</h4>
<p>The only time the app will need input when run from the command line is when a manual player is being used.  If this is the case, simply output the column in which to place a piece each turn.</p>
<p>After each move, the app will output PLAYER_MOVE__, where each underscore is the player who moved, the column where the piece was placed, and the row where the piece was placed, respectively.<br />
Example: PLAYER1MOVE21 would mean player 1 placed a piece in column 2, row 1.<br />
If a manual player attempts to play in a slot that is already full, or in a slot that doesn't exist, the program will output INVALID and the same player will have to input another move.</p>
<p>At the end of a game, the app will output PLAYER_WINS, where the underscore is the player who won, ex: PLAYER1WINS.  If the player wins due to an opponent's error, the program will
output PLAYER_WINSDUETOPLAYER_ERROR</p>
<p>If an AI fails to start properly, the app will output FAILURE_, where the underscore is the player who failed to launch properly.</p>
</body>
</html>

About

A program that allows the user to play Connect-Four manually or through the use of AI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published