Compare commits
No commits in common. "968c7f08e564684ea0359e05783d971855624939" and "b83ac78952e28746cabd56d8f2e3e036046c9748" have entirely different histories.
968c7f08e5
...
b83ac78952
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,5 +11,3 @@ chess-java-interface-dummy/target
|
|||||||
chess-java-interface/.classpath
|
chess-java-interface/.classpath
|
||||||
chess-java-interface/.project
|
chess-java-interface/.project
|
||||||
chess-java-interface/target
|
chess-java-interface/target
|
||||||
chess-python-interface/.project
|
|
||||||
chess-python-interface/.pydevproject
|
|
||||||
|
@ -1,47 +1,16 @@
|
|||||||
package net.hypki.wmi.oop.chess.dummy;
|
package net.hypki.wmi.oop.chess.dummy;
|
||||||
|
|
||||||
import static java.lang.System.currentTimeMillis;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.Period;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.hypki.wmi.oop.chess.ChessInterface;
|
import net.hypki.wmi.oop.chess.ChessInterface;
|
||||||
|
|
||||||
public class BasicStudent implements ChessInterface {
|
public class BasicStudent implements ChessInterface {
|
||||||
|
|
||||||
private static final Random random = new Random(currentTimeMillis());
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public BasicStudent() {
|
|
||||||
this.name = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BasicStudent(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return super.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String nextMove(String opponentMove) {
|
public String nextMove(String opponentMove) {
|
||||||
try {
|
return opponentMove;
|
||||||
Thread.currentThread().sleep(1000 * (random.nextInt(3)));
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
System.err.println("Cannot sleep " + e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return "e" + (random.nextInt(7) + 1) + "-e" + (random.nextInt(7) + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void printBoard() {
|
public void printBoard() {
|
||||||
System.out.println("Printing board not implemented yet");
|
System.out.println("Not implemented yet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.hypki.wmi.oop.chess;
|
package net.hypki.wmi.oop.chess;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for chess programs for the classes 'Programowanie obiektowe' for
|
* Interface for chess programs for the classes 'Programowanie obiektowe' for Java language
|
||||||
* Java language
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface ChessInterface {
|
public interface ChessInterface {
|
||||||
|
@ -6,19 +6,28 @@ public class ChessMatchMain {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Preparing chess interface...");
|
System.out.println("Preparing chess interface...");
|
||||||
|
|
||||||
ChessInterface white = new BasicStudent();
|
ChessInterface student1White = new BasicStudent();
|
||||||
ChessInterface black = new BasicStudent();
|
ChessInterface student2Black = new BasicStudent();
|
||||||
|
|
||||||
Tournament tournament = new Tournament(white, black);
|
String nextMove = null;
|
||||||
|
while (true) {
|
||||||
|
nextMove = student1White.nextMove(nextMove);
|
||||||
|
|
||||||
tournament.run();
|
if (nextMove == null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
nextMove = student2Black.nextMove(nextMove);
|
||||||
|
|
||||||
|
if (nextMove == null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("Match finished!");
|
System.out.println("Match finished!");
|
||||||
|
|
||||||
System.out.println("Student1 board:");
|
System.out.println("Student1 board:");
|
||||||
white.printBoard();
|
student1White.printBoard();
|
||||||
|
|
||||||
System.out.println("Student2 board:");
|
System.out.println("Student2 board:");
|
||||||
black.printBoard();
|
student2Black.printBoard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
package net.hypki.wmi.oop.chess;
|
|
||||||
|
|
||||||
public class Tournament {
|
|
||||||
|
|
||||||
private ChessInterface white;
|
|
||||||
|
|
||||||
private ChessInterface black;
|
|
||||||
|
|
||||||
public Tournament() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tournament(ChessInterface white, ChessInterface black) {
|
|
||||||
setWhite(white);
|
|
||||||
setBlack(black);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChessInterface getWhite() {
|
|
||||||
return white;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWhite(ChessInterface white) {
|
|
||||||
this.white = white;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChessInterface getBlack() {
|
|
||||||
return black;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlack(ChessInterface black) {
|
|
||||||
this.black = black;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
String nextMove = null;
|
|
||||||
while (true) {
|
|
||||||
nextMove = getWhite().nextMove(null);
|
|
||||||
|
|
||||||
if (nextMove == null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
System.out.println("Next move: " + nextMove);
|
|
||||||
|
|
||||||
nextMove = getBlack().nextMove(nextMove);
|
|
||||||
|
|
||||||
if (nextMove == null)
|
|
||||||
break;
|
|
||||||
|
|
||||||
System.out.println("Next move: " + nextMove);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String nextMove(ChessInterface chessInterface, String nextMove) {
|
|
||||||
try {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return chessInterface.nextMove(nextMove);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
System.err.println(t);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
'''
|
|
||||||
Created on May 30, 2023
|
|
||||||
|
|
||||||
@author: ahypki
|
|
||||||
'''
|
|
||||||
class ChessInterface:
|
|
||||||
def nextMove(self, opponentMove = None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def printBoard(self):
|
|
||||||
pass
|
|
@ -1,7 +1,2 @@
|
|||||||
- każda klasa - osobny plik
|
- każda klasa - osobny plik
|
||||||
- do gita nie wrzucamy skompilowanych plików
|
- do gita nie wrzucamy skompilowanych plików
|
||||||
|
|
||||||
- dodać limit czasowy na jeden ruch: 1 minuta i niech to będzie parametr
|
|
||||||
- ja musze dodać jednak walidator bo mi studenci kombinują
|
|
||||||
|
|
||||||
https://www.developer.com/design/top-10-java-coding-guidelines/
|
|
Loading…
Reference in New Issue
Block a user