Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.idea/
out/

# Eclipse
.metadata
.settings
Expand Down
Binary file added Dawid.jar
Binary file not shown.
Binary file added alg/A_Pawlikowska/APawlikowska.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/A_Pawlikowska/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java - jar .\Programs\A_Pawlikowska\APawlikowska.jar
Binary file added alg/Adam_Kamiński/BrickFighter.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Adam_Kamiński/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar BrickFighter.jar
Adam Kaminski
2 changes: 2 additions & 0 deletions alg/Artur_Braksator/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar ./Programs/Artur_Braksator/programWalczacy.jar
programWalczacy.jar (Artur Braksator)
Binary file added alg/Artur_Braksator/programWalczacy.jar
Binary file not shown.
Binary file added alg/Borecki_Beniamin/AlgorytmWalczacy.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Borecki_Beniamin/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar ./Programs/Borecki_Beniamin/AlgorytmWalczacy.jar
Borecki Beniamin
Binary file added alg/Dawid_Sowa/Dawid.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Dawid_Sowa/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Dawid_Sowa/Dawid.jar
Binary file added alg/Jakub_Bielawski/bricks-1.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Jakub_Bielawski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -cp bricks-1.0-SNAPSHOT.jar com.algorytmy.bricks.App
Jakub Bielawski
Binary file added alg/Karol_Szymanski/Player.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Karol_Szymanski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Karol_Szymanski/Player.jar
Binary file added alg/Maciej_Step/PlayerA.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Maciej_Step/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar .\Programs\Maciej_Step\PlayerA.jar
Binary file added alg/Maciej_Tarnowski/Maciej_Tarnowski.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Maciej_Tarnowski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar -XX:+UseConcMarkSweepGC ./Programs/Maciej_Tarnowski/Maciej_Tarnowski.jar
Maciej "Anal destroyer" Tarnowski
Binary file added alg/Marcin_Krasuski/Marcin_Krasuski.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Marcin_Krasuski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Marcin_Krasuski/Marcin_Krasuski.jar
Binary file added alg/Mateusz_Blaszczak/Bloczki.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Mateusz_Blaszczak/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar ./Programs/Mateusz_Blaszczak/Bloczki.jar
Bloczki.jar (Mateusz B�aszczak)
Binary file added alg/Mateusz_Koczan/Player.exe
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Mateusz_Koczan/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./Programs/Mateusz_Koczan/Player.exe
Binary file added alg/Mateusz_Ostrowski/Game03.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Mateusz_Ostrowski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar ./Programs/Mateusz_Ostrowski/Game03.jar
MATEUSZ OSTROWSKI
Binary file added alg/Michal_Weiss/284950.jar
Binary file not shown.
Binary file added alg/Michal_Weiss/Mateusz_Ostrowski/Game03.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Michal_Weiss/Mateusz_Ostrowski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar ./Programs/Mateusz_Ostrowski/Game03.jar
MATEUSZ OSTROWSKI
1 change: 1 addition & 0 deletions alg/Michal_Weiss/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Michal_Weiss/284950.jar
Binary file added alg/Patryk_Milewski/PatrykMilewski.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Patryk_Milewski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Patryk_Milewski/PatrykMilewski.jar
Binary file added alg/Pawel_Zarczuk/Pawel_Zarczuk.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Pawel_Zarczuk/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Pawel_Zarczuk/Pawel_Zarczuk
Binary file added alg/Paweł_Makowski/Paweł_Makowski.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/Paweł_Makowski/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./Programs/Pawe�_Makowski/Pawe�_Makowski.exe
Pawe� Makowski
Binary file added alg/Rafal_Aspras/Algorytm.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Rafal_Aspras/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Rafal_Aspras/Algorytm.jar
2 changes: 2 additions & 0 deletions alg/Wiktor_Grochal/info.txt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main.exe
Wiktor Grochal
Binary file added alg/Wiktor_Grochal/main.exe
Binary file not shown.
Binary file added alg/Wojtek_Musiatowicz/Wojtek_Musiatowicz.jar
Binary file not shown.
1 change: 1 addition & 0 deletions alg/Wojtek_Musiatowicz/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -jar ./Programs/Wojtek_Musiatowicz/Wojtek_Musiatowicz.jar
Binary file added alg/anna_grenda/bricksbot-1.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions alg/anna_grenda/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java -jar .Programs/Anna_Grenda/bricksbot-1.0-SNAPSHOT.jar 100 16
Anna Grenda
2 changes: 2 additions & 0 deletions alg/michal_regula/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
michalregula
michal regula
Binary file added alg/michal_regula/michalregula.exe
Binary file not shown.
50 changes: 50 additions & 0 deletions src/main/java/ttsu/game/Block.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ttsu.game;

import java.awt.*;

public final class Block {
public final Point a;
public final Point b;

public Block(Point a, Point b) {
this.a = a;
this.b = b;
}

public boolean hasCommonPoint(Block block) {
return (block.a == a && block.b == b) || (block.a == b && block.b == a);
}

public boolean isConsistent() {
return a.distance(b) == 1.0;
}

// public boolean isInsideBoard() {
// return a.x >= 0 && a.x < Main.X && b.x >= 0 && b.y < Main.Y;
// }

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Block)) {
return false;
}
Block other = (Block) obj;
return a.equals(other.a) && b.equals(other.b);
}

@Override
public int hashCode() {
return a.hashCode() + b.hashCode();
}

@Override
public String toString() {
return (this.a.x + (Main.COUNT_FROM_ONE ? 1 : 0)) + "x" +
(this.a.y + (Main.COUNT_FROM_ONE ? 1 : 0)) + "_" +
(this.b.x + (Main.COUNT_FROM_ONE ? 1 : 0)) + "x" +
(this.b.y + (Main.COUNT_FROM_ONE ? 1 : 0));
}
}
74 changes: 74 additions & 0 deletions src/main/java/ttsu/game/Communication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package ttsu.game;

import ttsu.game.ai.GameIntelligenceAgent;
import ttsu.game.ai.MinimaxAgent;
import ttsu.game.ai.PropabilityAgent;
import ttsu.game.ai.RandomAgent;
import ttsu.game.ai.heuristic.tictactoe.TicTacToeEvaluator;
import ttsu.game.tictactoe.TicTacToeBoardPrinter;
import ttsu.game.tictactoe.TicTacToeGameState;
import ttsu.mrozu.Algorithm;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.*;
import java.util.ArrayList;

public class Communication {
public static void Communication() throws IOException, InterruptedException {
TicTacToeGameState gameState = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
TicTacToeBoardPrinter boardPrinter = new TicTacToeBoardPrinter(System.out);
GameIntelligenceAgent<TicTacToeGameState> propabilityAgent = new PropabilityAgent<TicTacToeGameState>();

String input;
int boardSize;
ArrayList<Point> excludedPoints;

input = br.readLine();

long startTime = System.nanoTime();

boardSize = Parser.parseBoardSize(input);
excludedPoints = Parser.parseExcludedPoints(input);
gameState = new TicTacToeGameState(boardSize, excludedPoints);

if(Main.DEBUG) {
System.out.println(Watcher.timePassedMs(startTime));
}

System.out.println("OK");

while (true) {
input = br.readLine();

startTime = System.nanoTime();

if (input.equals("stop") || input.equals("STOP"))
break;
else {
if (input.equals("start") || input.equals("START")) {

gameState = propabilityAgent.evaluateNextState(gameState);
System.out.println(gameState.getLastMove().toString());

} else {
Block opponentBlock = Parser.parseOpponentMove(input);

gameState.play(opponentBlock);
gameState.switchPlayer();

gameState = propabilityAgent.evaluateNextState(gameState);
System.out.println(gameState.getLastMove().toString());
}
}

if (Main.DEBUG) {
boardPrinter.printGameBoard(gameState.getGameBoard());
System.out.println("Time: " + Watcher.timePassedMs(startTime));
}
}
}

}
22 changes: 6 additions & 16 deletions src/main/java/ttsu/game/DiscreteGameState.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package ttsu.game;

import ttsu.game.tictactoe.GameBoard;
import ttsu.game.tictactoe.TicTacToeGameState;

import java.util.List;

public interface DiscreteGameState {

/**
* Gets a list of available next states from the current game state.
*
* @return a {@link List} of available {@link DiscreteGameState}s; an empty list when there are no
* available states. This will never be null.
*/
List<DiscreteGameState> availableStates();

/**
* Gets whether this game state represents a terminal state.
*
* @return <code>true</code> if the game is over; <code>false</code> otherwise.
*/
TicTacToeGameState.Player getCurrentPlayer();
public GameBoard getGameBoard();
boolean hasWin(TicTacToeGameState.Player p);
boolean isOver();

// TODO: consider getCurrentPlayer so it doesn't have to be passed into the
// minimax evaluation.
}
19 changes: 19 additions & 0 deletions src/main/java/ttsu/game/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ttsu.game;

public class Main {
public static int DEFAULT_SIZE = 4;
public static int PROP_DEPTH = 100;
public static boolean COUNT_FROM_ONE = false;
public static boolean DEBUG = false;
public static long TIME_LIMIT = 200;

public static void main(String[] args) {

try {
Communication.Communication();
} catch (Exception e) {
System.err.println("IO Exception");
}

}
}
45 changes: 45 additions & 0 deletions src/main/java/ttsu/game/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ttsu.game;

import java.awt.*;
import java.util.ArrayList;

public class Parser {
static int parseBoardSize(String input) {
return Integer.parseInt(input.split("_")[0]);
}

static Block parseOpponentMove(String input) {
String[] splitted = input.split("_");

Point p1,p2;
Block block;

p1 = new Point(
Integer.parseInt(splitted[0].split("x")[0]) - (Main.COUNT_FROM_ONE ? 1 : 0),
Integer.parseInt(splitted[0].split("x")[1]) - (Main.COUNT_FROM_ONE ? 1 : 0)
);
p2 = new Point(
Integer.parseInt(splitted[1].split("x")[0]) - (Main.COUNT_FROM_ONE ? 1 : 0),
Integer.parseInt(splitted[1].split("x")[1]) - (Main.COUNT_FROM_ONE ? 1 : 0)
);

return new Block(p1,p2);
}

static ArrayList<Point> parseExcludedPoints(String input) {
String[] values = input.split("_");
ArrayList<Point> output = new ArrayList<Point>();

for (int i = 1; i < values.length; i++) {
String[] numbers = values[i].split("x");
output.add(
new Point(
Integer.parseInt(numbers[0]) - (Main.COUNT_FROM_ONE ? 1 : 0),
Integer.parseInt(numbers[1]) - (Main.COUNT_FROM_ONE ? 1 : 0)
)
);
}

return output;
}
}
55 changes: 0 additions & 55 deletions src/main/java/ttsu/game/Position.java

This file was deleted.

7 changes: 7 additions & 0 deletions src/main/java/ttsu/game/Watcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ttsu.game;

public class Watcher {
public static long timePassedMs(long startTime) {
return (System.nanoTime() - startTime) / 1000000;
}
}
Loading