void OnTriggerEnter(Collider col) { // Make sure it was actually the bottom player that collided if (col.gameObject != BotPlayer.S.gameObject) return; // Get useful player references botPlayer = BotPlayer.S.gameObject; botPlayerRigidBody = botPlayer.GetComponent<Rigidbody>(); botPlayerScript = botPlayer.GetComponent<BotPlayer>(); topPlayer = TopPlayer.S.gameObject; topPlayerRigidBody = topPlayer.GetComponent<Rigidbody>(); topPlayerScript = topPlayer.GetComponent<TopPlayer>(); // Disable BotPlayer botPlayerRigidBody.velocity = Vector3.zero; botPlayer.transform.rotation = Quaternion.LookRotation(botPlayer.transform.position) * Quaternion.Euler(0, 90, 0); botPlayerScript.anim.SetBool("Move", false); botPlayerScript.enabled = false; // Disable TopPlayer topPlayerRigidBody.velocity = Vector3.zero; topPlayer.transform.rotation = Quaternion.LookRotation(topPlayer.transform.position) * Quaternion.Euler(0, 90, 0); topPlayerScript.anim.SetBool("Move", false); topPlayerScript.enabled = false; // Begin moving to Cannon botPlayerScript.anim.SetBool("Move", true); botPlayerRigidBody.velocity = -(botPlayer.transform.position.normalized) * botPlayerScript.speed; movingToCannon = true; }
private IEnumerable <BotPlayer> _GetPlayers(int boardWidth) { BotPlayer red = new BotPlayer() { PlayerName = "p1", BotletId = '1', Energy = 1, Uri = Bot1Url, Spawn = boardWidth + 1, Resource = Resource.P1Botlet, deadBotletId = 'x' }; BotPlayer blue = new BotPlayer() { PlayerName = "p2", BotletId = '2', Energy = 1, Uri = Bot2Url, Spawn = boardWidth * (boardWidth - 1) - 2, Resource = Resource.P2Botlet, deadBotletId = 'X' }; return(new List <BotPlayer>() { red, blue }); }
public static double GetDistanceBetween(BotPlayer player, int targetX, int targetY) { double a = player.blockX - targetX; double b = player.blockY - targetY; double distance = Math.Sqrt(a * a + b * b); return distance; }
public void TestBotPlayerDecisionWithScore17() { var bot = new BotPlayer(); bot.ReceiveScore(17); Assert.False(bot.DecisionMaker()); }
public void IntermediateBeatsBeginner() { int BotWins = 0; int Bot2Wins = 0; SquareValues winner = 0; var blackpieces = Pieces.BlackPlacements(); var whitepieces = Pieces.WhitePlacements(); var Board = new GameBoard(8, blackpieces, whitepieces); var Bot = new BotPlayer3(Board, Types[rnd.Next(Types.Count)]); var Bot2 = new BotPlayer1(Board, Board.OpponentType(Bot.Type)); //var Bot = new BotPlayerTempV(Board, SquareValues.Black, 3); //var Bot2 = new BotPlayerTempV(Board, SquareValues.White, 2); for (int i = 0; i < 100; i++) { winner = BotPlayer.PlayBots(Board, Bot, Bot2); if (winner == Bot.Type) { BotWins++; } else { Bot2Wins++; } } Assert.IsTrue(BotWins > Bot2Wins); }
public SaveGameData(HumanPlayer human, BotPlayer bot, TradeRow row, ObservableCollection <Card> history) { HumanHand = human.Hand.ToList(); HumanDeck = human.Deck.ToList(); HumanGraveyard = human.Graveyard.ToList(); HumanAuthority = human.Authority; HumanTrade = human.AvailableTrade; HumanDamage = human.AvailableDamage; HumanDiscard = human.CardsToDiscard; HumanNextPurchaseFree = human.NextPurchaseForFree; HumanNextShipTop = human.NextPurchaseOnTop; BotHand = bot.Hand.ToList(); BotDeck = bot.Deck.ToList(); BotGraveyard = bot.Graveyard.ToList(); BotAuthority = bot.Authority; BotTrade = bot.AvailableTrade; BotDamage = bot.AvailableDamage; BotDiscard = bot.CardsToDiscard; BotNextPurchaseFree = bot.NextPurchaseForFree; BotNextShipTop = bot.NextPurchaseOnTop; TradeRowDeck = row.Deck.ToList(); TradeRowCurrent = row.CurrentCards.ToList(); PlayedCards = history.ToList(); }
public static List <BotPlayer> GetPlayers(int boardWidth, string bot1Url, string bot2Url) { BotPlayer red = new BotPlayer() { PlayerName = "p1", BotletId = '1', Energy = 1, Uri = GetNormalizedUri(bot1Url), Spawn = boardWidth + 1, Resource = Resource.P1Botlet, deadBotletId = 'x' }; BotPlayer blue = new BotPlayer() { PlayerName = "p2", BotletId = '2', Energy = 1, Uri = GetNormalizedUri(bot2Url), Spawn = boardWidth * (boardWidth - 1) - 2, Resource = Resource.P2Botlet, deadBotletId = 'X' }; return(new List <BotPlayer>() { red, blue }); }
public void AdvancedVsAdvanced() { int BotWins = 0; int Bot2Wins = 0; SquareValues winner = 0; var blackpieces = Pieces.BlackPlacements(); var whitepieces = Pieces.WhitePlacements(); var Board = new GameBoard(8, blackpieces, whitepieces); var Bot = new BotPlayer5(Board, Types[rnd.Next(Types.Count)]); var Bot2 = new BotPlayer5(Board, Board.OpponentType(Bot.Type)); //var Bot = new BotPlayerTempV(Board, SquareValues.Black, 3); //var Bot2 = new BotPlayerTempV(Board, SquareValues.White, 2); for (int i = 0; i < 100; i++) { winner = BotPlayer.PlayBots(Board, Bot, Bot2); if (winner == Bot.Type) { BotWins++; } else { Bot2Wins++; } } Assert.IsFalse(Math.Abs(BotWins - Bot2Wins) > 20); }
public void TestBotPlayerDecisionWithScore16() { var bot = new BotPlayer(); bot.ReceiveScore(16); Assert.True(bot.DecisionMaker()); }
static void Main(string[] args) { WriteIntro(); Game game; IPlayer player1; IPlayer player2; do { game = new Game(); boardRenderer = new BoardRenderer(game.Board); string name = GetPlayerName("player1"); player1 = new HumanPlayer(name, boardRenderer); game.Join(player1); player2 = new BotPlayer(); game.Join(player2); Console.WriteLine(); } while (Play(game, player1, player2)); Console.WriteLine(); WriteLine("Thanks for playing ZNim. Play again soon! [press Enter to exit]", Console.ForegroundColor); Console.ReadLine(); }
public AutoDevice(GameObject myself) { bot = myself.GetComponent <BotPlayer> (); if (bot == null) { bot = myself.AddComponent <BotPlayer> (); } }
public static double GetDistanceBetween(BotPlayer player, int targetX, int targetY) { double a = player.blockX - targetX; double b = player.blockY - targetY; double distance = Math.Sqrt(a * a + b * b); return(distance); }
public static Player[] CreatePlayers(int[] moneys) { Player[] players = new Player[moneys.Length]; for (int i = 0; i < players.Length; i++) { players[i] = new BotPlayer((i + 1).ToString(), moneys[i]); } return(players); }
private Player _GetPlayer(BotPlayer player) { Dictionary <string, Player> players = new Dictionary <string, Player>() { { "p1", GameState.P1 }, { "p2", GameState.P2 } }; return(players[player.PlayerName]); }
public void GivenABotClass_GetMove_ReturnsAn_EnEnumMoveValue() { //Arrange var testPlayer = new BotPlayer(); //Act var result = testPlayer.GetMove(); //Assert Assert.That(result, Is.InstanceOf <Movess>()); }
private void OnTriggerEnter(Collider other) { print("Something Entered a Camera Trigger Zone"); BotPlayer bot = other.transform.parent.GetComponent <BotPlayer>(); if (bot) { bot.zoneCount += 1; } }
public IEnumerable <BotletMove> GetMoves(MoveRequest request) { Grid grid = new Grid(request.State); BotPlayer player = _GetBotPlayer(request.Player, request.State); BotPlayer enemy = _GetBotPlayer(request.Player == "p2" ? "1" : "2", request.State); //current strategy: For each energy, have the closest bot move toward it. //Remaining bots move toward the enemy's base. List <BotletMove> responseMoves = _AssignBotletsToGrabEnergy(grid, player, enemy); return(responseMoves); }
/// <summary> /// Reset the state of the game to start a new one /// </summary> public void Reset() { phase = GamePhase.Setup; humanFirst = (randProvider.Next(1, 101) % 3 != 0); human = new Player("Anonymous"); machine = new BotPlayer("Skynet"); human.PlaceShipsRandomly(); machine.PlaceShipsRandomly(); viewForm.showInitialView(); viewForm.renderHumanShips(human.Ships); }
private async Task <PlayerMoves> GetAllPlayerMovesAsync(BotPlayer player, GameState gameState) { var moves = await GetBotletMovesAsync(player, gameState); var playerMove = new PlayerMoves() { Moves = moves, PlayerName = player.PlayerName }; return(playerMove); }
public void ToggleBot(BotPlayer selectBot) { if (playerIsActive) { EnableBot(selectBot); } else { EnablePlayer(); } }
public void GivenTwoMoves_GameResult_ReturnsTheCorrectString(Movess playerOneMove, Movess playerTwoMove, string expected) { //Arrange var one = new HumanPlayer("James"); var two = new BotPlayer(); var game = new Game(one, two); //Act var result = game.GameResult(playerOneMove, playerTwoMove).Trim(); //Assert Assert.That(result, Is.EqualTo(expected)); }
private void _AssignEnergyToBot(int location) { BotPlayer winningPlayer = _GetEnergyWinningPlayer(location); if (winningPlayer != null) { StringBuilder grid = new StringBuilder(GameState.Grid); grid[location] = '.'; GameState.Grid = grid.ToString(); _GetPlayer(winningPlayer).Energy++; } }
public bool ShouldInvoke(GameState state, BotPlayer player) { return //Check if the attacking players id is equal to the bots id and it is currently attacking ((state.GetValueByte("attacking_player_id") == player.Player.PlayerId & state.GetValueBool("IsAttacking")) | //Check if the defending players id is equal to the bots id and if it is currently defending (state.GetValueByte("defending_player_id") == player.Player.PlayerId & !state.GetValueBool("IsAttacking")) | //Checks the games state, if a player requires help and the bot players has the same value of the attacking player, this bot is asking for help (state.GetValueBool("player_req_help") == true && state.GetValueByte("defending_player_id") != player.Player.PlayerId)); }
public GameController(BattleshipControl form) { humanFirst = (randProvider.Next(1, 101) % 3 != 0); //human will be first in 2 cases out of 3 viewForm = form; human = new Player("You"); machine = new BotPlayer("Skynet"); phase = GamePhase.Setup; human.PlaceShipsRandomly(); machine.PlaceShipsRandomly(); humanFinished += HumanFinishedEventHandler; machineFinished += MachineFinishedEventHandler; }
private void OnTriggerExit(Collider other) { print("Something Left a Camera Trigger Zone"); if (other.transform == brain.followTransform) { brain.DeselectTarget(); BotPlayer bot = other.transform.parent.GetComponent <BotPlayer>(); if (bot) { bot.zoneCount -= 1; } } }
private void _SpawnBot(BotPlayer botPlayer) { Player player = _GetPlayer(botPlayer); if (player.SpawnDisabled == false && player.Energy > 0 && GameState.Grid[player.Spawn] == '.') { StringBuilder grid = new StringBuilder(GameState.Grid); grid[player.Spawn] = botPlayer.BotletId; GameState.Grid = grid.ToString(); player.Energy--; //_GetPlayer(player).energy = player.energy; } }
public void GivenTheFactThatTheUserWins_TheUserScore_IncreasesByOne() { //Arrange var one = new HumanPlayer(); var two = new BotPlayer(); var game = new Game(one, two); //Act game.PlayerOne.Move = Movess.Rock; game.PlayerTwo.Move = Movess.Scissors; game.GameResult(); //Assert Assert.That(game.PlayerOne.Score, Is.EqualTo(1)); }
void Start() { botPlayer = GetComponent <BotPlayer>(); botHeight = GetComponent <CapsuleCollider>().height; botRadius = GetComponent <CapsuleCollider>().radius; rb = GetComponent <Rigidbody>(); controller = GetComponent <CharacterController>(); maxJumpHeight = GetMaxJumpHeight(); timeToMaxJumpHeight = GetTimeToMaxJumpHeight(); destinations = GameObject.FindGameObjectWithTag(botPlayer.managerTag).GetComponentInChildren <BotDestinations>(); Ball.OnOutOfPlay += MoveToServeRecieve; }
public void GivenTwoMovesAreTheSame_TheScoreRemainsTheSame() { //Arrange var one = new HumanPlayer(); var two = new BotPlayer(); var game = new Game(one, two); //Act game.PlayerOne.Move = Movess.Rock; game.PlayerTwo.Move = Movess.Rock; game.GameResult(); //Assert Assert.That(game.PlayerOne.Score, Is.EqualTo(0)); Assert.That(game.PlayerTwo.Score, Is.EqualTo(0)); }
private void _SanitizeMoves(IEnumerable <PlayerMoves> playersMoves) { foreach (PlayerMoves playerMoves in playersMoves) { BotPlayer player = Players.Find(p => p.PlayerName == playerMoves.PlayerName); if (playerMoves.Moves == null) { playerMoves.Moves = new List <BotletMove>(); } else { playerMoves.Moves = _GetValidMovesOnly(playerMoves.Moves, player.BotletId); } } }
// Use this for initialization protected override void Start() { base.Start(); S = this; upKey = KeyCode.W; downKey = KeyCode.S; leftKey = KeyCode.A; rightKey = KeyCode.D; lives = 3; LivesGUI.S.GetComponent<GUIText> ().text = "x " + lives; numKeys = 0; KeyGUI.S.GetComponent<GUIText> ().text = "x " + numKeys.ToString (); }
//[ActionName("Game")] public IActionResult PostGame(Movess move) { if (gameM != null) { gameM.playerOne.Move = move; gameM.result = string.Empty; BotPlayer currentBot = (BotPlayer)gameM.playerTwo; gameM.playerTwo.Move = currentBot.GetMove(); IGame game = new Game(gameM.playerOne, gameM.playerTwo); gameM.result = game.GameResult(); } return(Json(new { Data = gameM })); }
public void EnableBot(BotPlayer selectBot) { playerIsActive = false; player.DisableMove(); foreach (BotPlayer bot in bots) { if (bot == selectBot) { bot.EnableMove(); } else { bot.DisableMove(); } } // }
public override void Update() { if (updateTimer.ElapsedMilliseconds >= 1000) { updateTimer.Restart(); double lowestDistance = 0; BotPlayer lowestDistancePlayer = null; lock (OstBot.playerList) { foreach (BotPlayer player in OstBot.playerList.Values) { if (player.isgod) continue; double currentDistance = GetDistanceBetween(player, xBlock, yBlock); if (currentDistance < lowestDistance || lowestDistance == 0) { lowestDistance = currentDistance; lowestDistancePlayer = player; } } } if (lowestDistancePlayer != null) { targetBotPlayer = lowestDistancePlayer; } } if (targetBotPlayer != null && xBlock != targetBotPlayer.x && yBlock != targetBotPlayer.y) { //pathFinding = null; pathFinding = new PathFinding(); //lagTimer.Restart(); pathToGo = pathFinding.Begin(xBlock, yBlock, targetBotPlayer.blockX, targetBotPlayer.blockY, null); //Console.WriteLine("elapsed shitlagtime " + lagTimer.ElapsedMilliseconds + "MS"); if (pathToGo != null && pathToGo.Count != 0) { Square temp; if (pathToGo.Count >= 2) temp = pathToGo.Pop(); Square next = pathToGo.Pop(); xBlock = next.x; yBlock = next.y; zombieBlock = Block.CreateBlock(0, xBlock, yBlock, 32, -1); zombieOldBlock = Block.CreateBlock(0, xOldBlock, yOldBlock, 4, -1); OstBot.room.DrawBlock(zombieBlock); OstBot.room.DrawBlock(zombieOldBlock); } if (targetBotPlayer != null) { if (!targetBotPlayer.isDead && GetDistanceBetween(targetBotPlayer, xBlock, yBlock) <= 1 && !targetBotPlayer.isgod) { targetBotPlayer.killPlayer(); OstBot.connection.Send("say", "/kill " + targetBotPlayer.name); } } } base.Update(); }
public Match(IGame game, BotPlayer player1, BotPlayer player2) { _game = game; _player1 = player1; _player2 = player2; }