From 56b29a33016f15c1fa13b9f13f7eac4370ee2201 Mon Sep 17 00:00:00 2001 From: Immanuel Alvaro Bhirawa Date: Tue, 9 May 2023 10:46:24 +1000 Subject: [PATCH] task 13 optimized for multiple players Signed-off-by: Immanuel Alvaro Bhirawa --- src/comp1110/ass2/BlueLagoon.java | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/comp1110/ass2/BlueLagoon.java b/src/comp1110/ass2/BlueLagoon.java index 54617a7..cfa0de0 100644 --- a/src/comp1110/ass2/BlueLagoon.java +++ b/src/comp1110/ass2/BlueLagoon.java @@ -670,15 +670,33 @@ public class BlueLagoon { } // After the endPhase is over, move to the next player - state.nextPlayer(); + state.nextPlayer(); - // if the current player cannot play the move, move to the next player - if (!state.getCurrentPlayer().canPlay(state)) state.nextPlayer(); + // if the current player cannot play, go to the next player + int players = state.getNumPlayers(); + while (!state.getCurrentPlayer().canPlay(state)) { + if (players == 1) break; + state.nextPlayer(); + players--; + } return state.toString(); } - //upStream pull lol + // // Tally up the score + // else if (state.getCurrentPhase() == 'S') { + // state.scorePhase(); + // } + // } + // + // // After the endPhase is over, move to the next player + // state.nextPlayer(); + // + // // if the current player cannot play the move, move to the next player + // if (!state.getCurrentPlayer().canPlay(state)) state.nextPlayer(); + // + // return state.toString(); + // } /** * Given a state string, returns a valid move generated by your AI. *