Skip to content

Commit

Permalink
First version of WinnerLogic. Just for syncing purpose. Its not worki…
Browse files Browse the repository at this point in the history
…ng atm.
  • Loading branch information
timesqueezer committed Oct 13, 2012
1 parent 76eb7f5 commit 0db8db2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
Binary file modified server-gui/game_gui.conf
Binary file not shown.
10 changes: 10 additions & 0 deletions server-gui/sync.error
Expand Up @@ -33,3 +33,13 @@ java.lang.InterruptedException
at java.lang.Object.wait(Object.java:485)
at sc.plugin2013.gui.renderer.RenderFacade$1.run(RenderFacade.java:70)
at java.lang.Thread.run(Unknown Source)
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at sc.plugin2013.gui.renderer.RenderFacade$1.run(RenderFacade.java:70)
at java.lang.Thread.run(Unknown Source)
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at java.lang.Object.wait(Object.java:485)
at sc.plugin2013.gui.renderer.RenderFacade$1.run(RenderFacade.java:70)
at java.lang.Thread.run(Unknown Source)
2 changes: 1 addition & 1 deletion simpleclient-ca-src/src/sc/player2013/Starter.java
Expand Up @@ -20,7 +20,7 @@ public Starter(String host, int port, String reservation, String strategy) throw
super(host, port);

/** Hier wird die zu verwendende Strategie eingetragen.*/
IGameHandler logic = new RandomLogic(this);
IGameHandler logic = new WinnerLogic(this);
setHandler(logic);

// einem spiel beitreten
Expand Down
41 changes: 29 additions & 12 deletions simpleclient-ca-src/src/sc/player2013/WinnerLogic.java
Expand Up @@ -13,6 +13,7 @@
import sc.plugin2013.IGameHandler;
import sc.plugin2013.Move;
import sc.plugin2013.MoveContainer;
import sc.plugin2013.Pirate;
import sc.plugin2013.Player;
import sc.plugin2013.PlayerColor;
import sc.plugin2013.util.InvalidMoveException;
Expand Down Expand Up @@ -62,27 +63,43 @@ public void gameEnded(GameResult data, PlayerColor color,
@Override
public void onRequestAction() {
System.out.println("*** Es wurde ein Zug angefordert");
Field field = new Field(FieldType.START);
MoveContainer moveC = new MoveContainer();
// Schleife die 3 mal durchlaufen wird. i wird jedes mal erhöht
for (int i = 0; i < 3; i++) {
// Liste der verfügbaren Züge
LinkedList<Move> possibleMoves = (LinkedList<Move>) gameState
.getPossibleMoves();
LinkedList<Move> possibleMoves = (LinkedList<Move>) gameState.getPossibleMoves();
System.out.println("*** Anzahl der möglichen Züge:"
+ possibleMoves.size());
Move move;

Move move = null;

// Wenn es mögliche Züge gibt:
if (possibleMoves.size() > 0) {

if (field.numPirates(gameState.getCurrentPlayerColor()) > 0) {


}
// Create move


if (currentPlayer.getCards().size() <= 1) {
for (int k = gameState.getBoard().size(); k > 0; k--) {
Field pirate_field = gameState.getBoard().getField(k);
if (pirate_field.numPirates(gameState.getCurrentPlayerColor()) > 0) {
move = new BackwardMove(k);
}
}


} else {

int biggest_index = 0;

for (Move m: possibleMoves) {
if (m.fieldIndex > biggest_index) {
biggest_index = m.fieldIndex;
}
}
for (Move m: possibleMoves) {
if (m.fieldIndex == biggest_index) {
move = (ForwardMove) m;
}
}
}

} else {
move = null;
}
Expand Down

0 comments on commit 0db8db2

Please sign in to comment.