This was an assignment for AI that required students' programs to compete in order to win the triangle game. This provides an interface for the students' programs- implementing the 'gameboard' backend logic written in Python and a visual front-end to show the current status of the game written in Java using LibGDX for rendering.
Each module communicates with one another via sockets.
Server to client, client to server, and server to gui.
The client may be written in C/C++, Java, or Python.
The base code for each language is provided with methods needed to parse server and game data. Therefore, students will simply need
to subclass the given class and implement the AI.
-
player_ex.py
python triangle.py
- open another shell/terminal
java -jar gui.jar
- open another shell/terminal
python player_ex.py
- open another shell/terminal
python player_ex.py
Each student need only to implement the AI to determine the line to draw. The following are the same interface written in diffrent languages that can be subclassed and implemented.
- triangle_client.py
- triangle_client.c TODO
- triangle_client.cpp TODO
- triangle_client.java TODO
-
The gameboard is an imaginary object that has the following layout:
--------------------------> m
| (0,0) (0,1) (0,2) (0,3)
| (1,0) (1,1) (1,2) (1,3)
| (2,0) (2,1) (2,2) (2,3)
| (3,0) (3,1) (3,2) (3,3)
n (grows downwards) -
Two players are required to play.
-
Each player is a program written in any language.
-
Each player takes turns 'drawing' a line in the game board.
-
There can be no duplicate or overlapping lines.
-
If a player draws a valid line and 1 or more triangle is formed then the player receives 1 point for each triangle formed.
-
If a triangle is formed, then the player who formed the triangle(s) gets another turn.
-
Player with most points win.
-
If the payer fails to respond within 10 seconds, or crashes, then the player is disqualified.
-
If the line drawn is an invalid line then the player is automatically disqualified.
- An invalid line is a line that is already drawn, overlaps another line, or does not represent a line in the game board (or wrong format).
-
- Player 1 and 2 connects to server 'localhost' at port 8000.
- Player 1 goes first and alternates with player 2.
- The server sends a flag and the currently drawn lines as a string
(to the player to start its turn) - Player's AI determines the best line to draw next and sends this coordinate to the server.
- Server sends client the result of drawing the line.
Do what ever you want with the code - WTFPL