public void MakeAMoveWhenTileIsRotated() { Admin a = new Admin(); Board b = new Board(); List <SPlayer> inGame = new List <SPlayer>(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 1, 3)); b.registerPlayer(p1); inGame.Add(p1); TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 3, 6, 4, 7, 2, 1, 5); Tile rotatedTile = t1.rotate(); TurnResult tr = a.playATurn(b, rotatedTile); Posn playerPosn = tr.currentPlayers[0].getPlayerPosn(); Assert.IsTrue(playerPosn.returnCol() == 2, "p1 not at correct col"); Assert.IsTrue(playerPosn.returnRow() == 1, "p1 not at correct row"); Assert.IsTrue(playerPosn.returnLocationOnTile() == 0, "p1 not at correct location on tile"); Assert.IsTrue(tr.currentPlayers.Exists(x => x.returnColor() == "p1"), "p1 not in winning players"); }
public void MakeAMoveCauseTokenToCrossMultipleTiles() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); Tile t4 = test.makeTile(0, 1, 2, 7, 4, 5, 3, 6); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 1, 3)); b.registerPlayer(p1); b.grid[1, 1] = t2; b.grid[1, 3] = t1; b.grid[1, 4] = t3; TurnResult tr = a.playATurn(b, t4); Posn playerPosn = tr.currentPlayers[0].getPlayerPosn(); Assert.IsTrue(playerPosn.returnRow() == 1); Assert.IsTrue(playerPosn.returnCol() == 4); Assert.IsTrue(playerPosn.returnLocationOnTile() == 3); }
public void SettingPlayerPosition() { SPlayer p1 = new SPlayer(); p1.setPosn(new Posn(1, 2, 3)); Posn playerPosn = p1.getPlayerPosn(); Assert.IsTrue(playerPosn.returnRow() == 1); Assert.IsTrue(playerPosn.returnCol() == 2); Assert.IsTrue(playerPosn.returnLocationOnTile() == 3); }
public void PlaceTilePlacesTile() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Board b = new Board(); b.addPlayerToBoard("blue", new Posn(0, 0, 3)); Posn endPos = b.placeTile("blue", t1); Assert.IsTrue(endPos.returnCol() == 1); Assert.IsTrue(endPos.returnRow() == 0); Assert.IsTrue(endPos.returnLocationOnTile() == 3); Assert.IsTrue(b.getTileAt(0, 1) != null); }
public void MakeMoveWhereMultiplePlayersEliminated() { Admin a = new Admin(); Board b = new Board(); TestScenerios test = new TestScenerios(); //tile to be placed Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); //tile the player is on Tile t2 = test.makeTile(1, 3, 0, 5, 2, 7, 4, 6); test.putTileOnBoard(t2, b, 1, 1); //players to be eliminated SPlayer elim1 = new SPlayer("elim1", new List <Tile>()); elim1.setPosn(new Posn(0, 0, 2)); elim1.playerState = SPlayer.State.Playing; SPlayer elim2 = new SPlayer("elim2", new List <Tile>()); elim2.setPosn(new Posn(0, 0, 3)); elim2.playerState = SPlayer.State.Playing; //player left over SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 1, 0)); p1.playerState = SPlayer.State.Playing; b.registerPlayer(p1); b.registerPlayer(elim1); b.registerPlayer(elim2); TurnResult tr = a.playATurn(b, t1); Posn playerPosn = tr.currentPlayers[0].getPlayerPosn(); Assert.AreEqual(playerPosn.returnLocationOnTile(), 3, "Remaining player not at location 3 on tile"); Assert.IsTrue(playerPosn.returnCol() == 1); Assert.IsTrue(playerPosn.returnRow() == 1); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.returnColor() == "elim1"), "eliminated player is in eliminated list"); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.returnColor() == "elim2"), "eliminated player is in eliminated list"); Assert.IsNotNull(tr.playResult); Assert.IsTrue(tr.playResult.Exists(x => x.returnColor() == "p1"), "p1 not in the winning list of players"); Assert.AreEqual(tr.playResult.Count, 1); }
public void PlaceTilePlacesTile() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); SPlayer p1 = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); Board b = new Board(); p1.setPosn(new Posn(0, 0, 3)); Posn endPos = b.placeTile(p1, t1); Assert.IsTrue(endPos.returnCol() == 1); Assert.IsTrue(endPos.returnRow() == 0); Assert.IsTrue(endPos.returnLocationOnTile() == 3); Assert.IsTrue(b.occupied(0, 1)); }
public void MakeAMoveCauseMultiplePlayersToMove() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 6, 3, 5, 4, 7); Tile t2 = test.makeTile(0, 1, 2, 7, 3, 4, 5, 6); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 0, 2)); SPlayer p2 = new SPlayer("p2", new List <Tile>()); p2.setPosn(new Posn(0, 1, 5)); SPlayer p3 = new SPlayer("p3", new List <Tile>()); p3.setPosn(new Posn(1, 2, 6)); b.registerPlayer(p1); b.registerPlayer(p2); b.registerPlayer(p3); b.grid[1, 2] = t2; TurnResult tr = a.playATurn(b, t1); Posn playerPosn0 = tr.currentPlayers[0].getPlayerPosn(); Posn playerPosn1 = tr.currentPlayers[1].getPlayerPosn(); Posn playerPosn2 = tr.currentPlayers[2].getPlayerPosn(); Assert.IsTrue(playerPosn0.returnRow() == 1); Assert.IsTrue(playerPosn0.returnCol() == 2); Assert.IsTrue(playerPosn0.returnLocationOnTile() == 2); Assert.IsTrue(playerPosn1.returnRow() == 1); Assert.IsTrue(playerPosn1.returnCol() == 1); Assert.IsTrue(playerPosn1.returnLocationOnTile() == 5); Assert.IsTrue(playerPosn2.returnRow() == 1); Assert.IsTrue(playerPosn2.returnCol() == 1); Assert.IsTrue(playerPosn2.returnLocationOnTile() == 4); Assert.IsNull(tr.playResult); }
public void MakingAMoveFromTheEdge() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(0, -1, 3)); b.registerPlayer(p1); TurnResult tr = a.playATurn(b, t1); Posn playerPosn = tr.currentPlayers[0].getPlayerPosn(); Assert.IsTrue(playerPosn.returnLocationOnTile() == 3); Assert.IsTrue(playerPosn.returnRow() == 0); Assert.IsTrue(playerPosn.returnCol() == 0); }
public void RunATournament() { int numOfTournaments = 10; int randomWins = 0; int lstSymWins = 0; int mostSymWins = 0; for (int i = 0; i < numOfTournaments; i++) { Admin a = new Admin(); List <Tile> drawPile = a.initializeDrawPile("drawPilepaths.txt"); Board b = new Board(); b.drawPile = drawPile; List <string> allPlayers = new List <string>() { "blue", "hotpink", "green" }; SPlayer randomPlayer = new SPlayer(allPlayers[0], new List <Tile>(), new RandomPlayer()); randomPlayer.initialize(b); randomPlayer.placePawn(b); SPlayer leastSymPlayer = new SPlayer(allPlayers[1], new List <Tile>(), new LeastSymmetricPlayer()); leastSymPlayer.initialize(b); leastSymPlayer.placePawn(b); SPlayer mostSymPlayer = new SPlayer(allPlayers[2], new List <Tile>(), new MostSymmetricPlayer()); mostSymPlayer.initialize(b); mostSymPlayer.placePawn(b); a.dealTiles(new List <SPlayer> { randomPlayer, leastSymPlayer, mostSymPlayer }, b); List <SPlayer> winners = null; foreach (string color in b.getPlayerOrder()) { Posn tempPosn = b.getPlayerPosn(color); Debug.WriteLine(color + " is at: " + string.Format("{0} {1} {2}", tempPosn.returnRow(), tempPosn.returnCol(), tempPosn.returnLocationOnTile())); } SPlayer currentPlayer = b.getFirstActivePlayer(); Tile playTile = currentPlayer.playTurn(b, drawPile.Count); Debug.WriteLine(currentPlayer.returnColor() + " Turn"); Debug.WriteLine("Playing Tile:"); Debug.WriteLine(playTile.paths[0].loc1 + " " + playTile.paths[0].loc2); Debug.WriteLine(playTile.paths[1].loc1 + " " + playTile.paths[1].loc2); Debug.WriteLine(playTile.paths[2].loc1 + " " + playTile.paths[2].loc2); Debug.WriteLine(playTile.paths[3].loc1 + " " + playTile.paths[3].loc2); TurnResult tr = a.playATurn(b, playTile); //Debug.WriteLine("Eliminated: "); foreach (SPlayer p1 in tr.eliminatedPlayers) { //Debug.WriteLine(p1.returnColor()); } while (winners == null) { foreach (string color in b.getPlayerOrder()) { Posn tempPosn = b.getPlayerPosn(color); Debug.WriteLine(color + " is at: " + string.Format("{0} {1} {2}", tempPosn.returnRow(), tempPosn.returnCol(), tempPosn.returnLocationOnTile())); } SPlayer p = b.getFirstActivePlayer(); playTile = p.playTurn(b, drawPile.Count); Debug.WriteLine(p.returnColor() + " Turn"); Debug.WriteLine("Playing Tile:"); Debug.WriteLine(playTile.paths[0].loc1 + " " + playTile.paths[0].loc2); Debug.WriteLine(playTile.paths[1].loc1 + " " + playTile.paths[1].loc2); Debug.WriteLine(playTile.paths[2].loc1 + " " + playTile.paths[2].loc2); Debug.WriteLine(playTile.paths[3].loc1 + " " + playTile.paths[3].loc2); tr = a.playATurn(tr.b, playTile); Debug.WriteLine("Eliminated: "); foreach (SPlayer p1 in tr.eliminatedPlayers) { Debug.WriteLine(p1.returnColor()); } winners = tr.playResult; } foreach (SPlayer p in winners) { if (p.returnColor() == "blue") { randomWins++; } else if (p.returnColor() == "hotpink") { lstSymWins++; } else { mostSymWins++; } Debug.WriteLine(p.returnColor() + " has won!"); } } Console.WriteLine("Random Player Wins: " + randomWins + "/" + numOfTournaments); Console.WriteLine("Least Symmetric Player Wins: " + lstSymWins + "/" + numOfTournaments); Console.WriteLine("Most Symmetric Player Wins: " + mostSymWins + "/" + numOfTournaments); }