/// <summary> /// Read and process Tell message /// </summary> /// <param name="client"> /// Client sending /// </param> /// <param name="packet"> /// Packet data /// </param> public static void Read(Client client, byte[] packet) { PacketReader reader = new PacketReader(ref packet); reader.ReadUInt16(); reader.ReadUInt16(); uint playerId = reader.ReadUInt32(); string message = reader.ReadString(); client.Server.Debug(client, "{0} >> Tell: PlayerId: {1}", client.Character.characterName, playerId); reader.Finish(); if (client.Server.ConnectedClients.ContainsKey(playerId)) { Client tellClient = (Client)client.Server.ConnectedClients[playerId]; if (!tellClient.KnownClients.Contains(client.Character.characterId)) { byte[] pname = PlayerName.New(client, client.Character.characterId); tellClient.Send(pname); tellClient.KnownClients.Add(client.Character.characterId); } byte[] pgroup = MsgPrivateGroup.Create(client.Character.characterId, message, string.Empty); tellClient.Send(pgroup); } else { byte[] sysmsg = MsgSystem.Create("Player not online."); client.Send(sysmsg); } }
public Team PopulateTeam(Team.TeamType cType) { //read roster from JSON file and populate team objects with players try { Team iTeam = new Team(); iTeam.TypeOfTeam = cType; StreamReader Reader = new StreamReader("c:\\temp\\" + cType.ToString() + ".json"); string json = Reader.ReadToEnd(); List <String> PlayersList = JsonConvert.DeserializeObject <List <String> >(json); iTeam.TeamPlayers = new List <Player>(); FieldingPosition fp = FieldingPosition.Pitcher; foreach (String PlayerName in PlayersList) { Player Pl = new Player(); Pl.Name = PlayerName.ToString(); Pl.FieldingPositionNow = fp; iTeam.TeamPlayers.Add(Pl); fp++; } return(iTeam); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } }
public GameState CopyAndPlay(int x, int y, PlayerName player) { var newState = this.Copy(); if (newState.Field.Board[x, y] != 0) throw new Exception(string.Format("Can't play ({0},{1}) because it was already played", x, y)); newState.Field.Board[x, y] = (int)player; return newState; }
public string DoubtDodgeFailMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[Random.Range(9, 13)]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[Random.Range(10, 13)]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[Random.Range(9, 11)]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[Random.Range(9, 12)]; } switch (Random.Range(0, 5)) { case 0: return("NOOOO!!!"); case 1: return("Ugh..."); case 2: return("Ooh... nooo...."); case 3: return("Waaaah~~!!"); case 4: return("RIP, me."); default: return("..."); } }
// Use this for initialization void Start() { selected = Select.selectedPlayer; //DetermineFightOpponents (selected,opponents); StartCoroutine (StartGame()); }
public int CompareTo(object obj) { if (!(obj is ScoreboardEntry)) { throw new Exception("Bad object comparison"); } if (obj == null) { return(1); } var toCompare = obj as ScoreboardEntry; if (Points > toCompare.Points) { return(1); } else if (Points < toCompare.Points) { return(-1); } if (MinesOwned > toCompare.MinesOwned) { return(1); } else if (MinesOwned < toCompare.MinesOwned) { return(-1); } return(PlayerName.CompareTo(toCompare.PlayerName)); }
public override int GetHashCode() { int hash = 1; if (PlayerId.Length != 0) { hash ^= PlayerId.GetHashCode(); } if (PlayerName.Length != 0) { hash ^= PlayerName.GetHashCode(); } if (IsHouseOwner != false) { hash ^= IsHouseOwner.GetHashCode(); } if (position_ != null) { hash ^= Position.GetHashCode(); } if (rotation_ != null) { hash ^= Rotation.GetHashCode(); } if (ExtraContent.Length != 0) { hash ^= ExtraContent.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void CheckGameStatus() { CheckMateLabel.Visible = false; if (_game.IsGameOver() || _game.IsGameDraw()) { TurnTimer.Stop(); ChessBoard.Enabled = false; BoardStateHistory.Enabled = false; Message.Location = new Point(413, 150); if (_game.IsGameDraw()) { Message.Text = drawMessage; } else { Message.Text = _currentPlayerName + winMessage; } } else { _currentPlayerTurn = _currentPlayerTurn == PlayerName.PlayerOne ? PlayerName.PlayerTwo : PlayerName.PlayerOne; _currentPlayerName = _currentPlayerTurn == PlayerName.PlayerOne ? playerOne : playerTwo; if (_game.IsCheck()) { CheckMateLabel.Text = _currentPlayerName + checkMateText; CheckMateLabel.Visible = true; } } }
/// <summary> /// Handles the TurnOver event by having the /// other player take their turn /// </summary> /// <param name="player">who finished their turn</param> /// <param name="newConfiguration">the new board configuration</param> void HandleTurnOverEvent(PlayerName player, Configuration newConfiguration) { board.Configuration = newConfiguration; // check for game over if (newConfiguration.Empty) { // fire event with winner if (player == PlayerName.Player1) { gameOverEvent.Invoke(PlayerName.Player2, currentMatch); } else { gameOverEvent.Invoke(PlayerName.Player1, currentMatch); } timer.Run(); } else // game not over, so give other player a turn if (player == PlayerName.Player1) { takeTurnEvent.Invoke(PlayerName.Player2, newConfiguration); } else { takeTurnEvent.Invoke(PlayerName.Player1, newConfiguration); } }
// Case Table that sets modifiers of Player Types public void PlayerBuffs() { PlayerName PlayerName = (PlayerName)(1); switch (PlayerName) { case PlayerName.God: Name = "God"; Health = Health * 999f; Strength = Strength * 999f; Armour = Armour * 999; break; case PlayerName.None: Player = "Null"; Health = 1; Strength = 0; Armour = 0; break; default: Console.WriteLine("Default Player Modifiers Active"); break; } }
public Player() { Name = new PlayerName(); ByeWeeks = new ByeWeeks(); Headshot = new Headshot(); EligiblePositions = new List <EligiblePosition>(); }
private void RandomNameJsonSaver() { for (int i = 0; i < randomNamesMale.Count; i++) { PlayerName n01 = new PlayerName(); n01.name = randomNamesMale[i]; gameData.male.Add(n01); } for (int i = 0; i < randomNamesFemale.Count; i++) { PlayerName n02 = new PlayerName(); n02.name = randomNamesFemale[i]; gameData.female.Add(n02); } /* * for (int i = 0, j = 0; i < randomNamesMale.Count && j < randomNamesFemale.Count; i++, j++) * { * PlayerName n01 = new PlayerName(); * PlayerName n02 = new PlayerName(); * n01.name = randomNamesMale[i]; * gameData.male.Add(n01); * n02.name = randomNamesFemale[j]; * gameData.female.Add(n02); * } */ }
public string DoubtFailMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[Random.Range(9, 13)]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[Random.Range(10, 13)]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[Random.Range(9, 11)]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[Random.Range(9, 12)]; } switch (Random.Range(0, 5)) { case 0: return("Noooo!!!"); case 1: return("L-Lucky shot!"); case 2: return("Such... trick..."); case 3: return("Ouch!"); case 4: return("Goodbye, world..."); default: return("..."); } }
/// <summary> /// Handles the pause between games timer finishing /// </summary> void HandlePauseBetweenGamesTimerFinished() { // update the progress bar updateProgressBar(); // check whether we need to move onto the next game if (gameCounter == GameConstants.MaxGames) { // if new game, need to reset game count gameCounter = 0; // and move to the next difficult combination difficultyIndex++; } // check if all games have completed if (difficultyIndex >= difficultyList.Count) { // if yes, load statistics scene SceneManager.LoadScene("statistics"); } else { // if not, let listeners know that we are going to start a new game gameStartingEvent.Invoke(); // alternate the starting player for each game started = started == PlayerName.Player1 ? PlayerName.Player2 : PlayerName.Player1; // get the difficulty combination for this game currentDifficulties = difficultyList[difficultyIndex]; // start the new game StartGame(started, currentDifficulties); } }
public string WinFailMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[16]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[13]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[15]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[14]; } switch (Random.Range(0, 5)) { case 0: return("Why can't I win..."); case 1: return("Nuuuu!"); case 2: return("Waaaa..."); case 3: return("Nyauu~~!!!"); case 4: return("N-Next time!"); default: return("..."); } }
public string DoubtResponseMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[8]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[9]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[8]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[8]; } switch (Random.Range(0, 5)) { case 0: return("!!!"); case 1: return("Gah!"); case 2: return("Erk!"); case 3: return("Nyuu~?"); case 4: return("Can't be helped..."); default: return("..."); } }
// method to input player name and start game private void btnPlayerNext_Click(object sender, RoutedEventArgs e) { // if there are players to be made if (players != 0) { // fire event with playername PlayerName?.Invoke(txtboxPlayername.Text, null); txtboxPlayername.Text = ""; players--; txtboxPlayername.Focus(); // if there is no more players to be made if (players == 0) { // sets button to say start btnPlayerNext.Content = "Start"; // sets ui elements to hidden txtboxPlayername.Visibility = Visibility.Hidden; lblPlayerName.Visibility = Visibility.Hidden; // focuses the button QOL btnPlayerNext.Focus(); } } // if there is no players to be made else { // fire event that setup is done Close?.Invoke("", null); } }
async void HandlePlayerNameMessage(PlayerName message) { if (GetPlayerBySecret(message.Secret) != null) { return; } GameNet.Player netPlayer = BaseServer.GetPlayerBySecret(message.Secret); if (netPlayer == null) { return; } ServerPlayer player = new ServerPlayer(netPlayer, NextPlayerId, message.Name); await BaseServer.SendTo(netPlayer, new PlayerId(player.Id)); await Task.Delay(500); _players[player.Secret] = player; BaseServer.Send(player.ToBasePlayer(), ProtocolType.Udp); EmitPlayerAdded(player); }
public string DoubtDodgeSuccessMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[4]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[7]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[5]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[7]; } switch (Random.Range(0, 5)) { case 0: return("Huehuehue~~"); case 1: return("I got you!"); case 2: return("Oh no you don't."); case 3: return("Dadada~~~"); case 4: return("Here's your present~!!"); default: return("Take this!"); } }
private IBot CreateBot(PlayerName player = PlayerName.Player1) { IBot bot = new JuinenBot(); var settings = new Settings() { YourBot = player }; bot.ApplySettings(settings); return bot; }
public string DoubtSuccessMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[4]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[7]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[5]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[7]; } switch (Random.Range(0, 5)) { case 0: return("Mwahaha~~!!"); case 1: return("So obvious."); case 2: return("You can't fool me!"); case 3: return("Phew, close call."); case 4: return("Dundundun~~"); default: return("Yay, I got it right!"); } }
public static void WriteJson(this PlayerName value, JsonWriter writer, JsonSerializer serializer) { switch (value) { case PlayerName.Nathalie: serializer.Serialize(writer, "Nathalie"); break; } }
void Start() { string playerButton = PlayerName + "ButtonDoubt"; if (playerButton.Contains("Player1")) { Button btnDoubt = GameObject.Find(playerButton).GetComponent <Button>(); btnDoubt.onClick.AddListener(delegate { Doubt(); }); } canCallDoubt = false; isPlayDiceRolled = false; isDoubtDiceRolled = false; GameObject.Find(PlayerName + "Name").GetComponent <Text>().text = RealName; if (PlayerName.Contains("Player1")) { characterSprite = Resources.LoadAll <Sprite>("neptune_sprite"); } if (PlayerName.Contains("Player2")) { characterSprite = Resources.LoadAll <Sprite>("noire_sprite"); } if (PlayerName.Contains("Player3")) { characterSprite = Resources.LoadAll <Sprite>("blanc_sprite"); } if (PlayerName.Contains("Player4")) { characterSprite = Resources.LoadAll <Sprite>("vert_sprite"); } }
public static List <Player> CreateListOfPlayerLists(int amount, int playerNameStartValue) { if (MinPlayersRequired > amount || amount > MaxPlayersRequired) { throw new ArgumentOutOfRangeException($"{nameof(amount)} must be between 24 and 30."); } if (playerNameStartValue < MinPlayerNameStartValue) { throw new ArgumentOutOfRangeException($"{nameof(playerNameStartValue)} must be larger than {MinPlayerNameStartValue}."); } List <Player> players = new List <Player>(); for (int i = playerNameStartValue; i <= (amount + playerNameStartValue - 1); i++) { PlayerName firstName = new PlayerName("Player"); PlayerName lastName = new PlayerName(i.NumberToWords().FirstToUpper(true).Trim()); int year = random.Next(DateTime.Now.Year - 50, DateTime.Now.Year - 17); int month = random.Next(1, 13); int day = random.Next(1, DateTime.DaysInMonth(year, month) + 1); DateTime dateOfBirth = new DateTime(year, month, day); players.Add(new Player(firstName, lastName, new DateOfBirth(dateOfBirth))); } return(players); }
internal async Task <bool> RegisterPlayer() { try { RegistrationState = "Registering..."; Registering = true; if (PlayerName.All(char.IsLetterOrDigit)) { PlayerDescriptor player = await GameLoader.Instance.RegisterPlayer(ServerIP, PlayerName); GameLoader.Instance.Player = player; RegistrationState = "Logged in!"; IsSuccessfullyRegistered = true; } } catch { RegistrationState = "Register"; } finally { Registering = false; } return(IsSuccessfullyRegistered); }
private void TryAddPlayer() { if (string.IsNullOrWhiteSpace(PlayerName)) { SetTextBoxDesign(); Message = "Du måste skriva något."; return; } else if (PlayerName.Contains(" ")) { SetTextBoxDesign(); Message = "Ditt namn får inte innehålla mellanslag"; return; } if (_module.TryAddPlayer(PlayerName, out _)) { SetActivePlayer(PlayerName); MessageBox.Show($"Välkommen {ActivePlayerName}! Du är nu en medlem!"); GoToPage(ApplicationPage.GamePage); return; } else { SetTextBoxDesign(); Message = "Du har valt ett namn som är upptaget - försök igen"; } }
public ThreatMusicInfo(LevelInfo level, PlayerName primaryPlayer) { columnCount = Util.randExclusive(level.minColumnCount, level.maxColumnCount + 1); var columnIndices = new int[columnCount]; for (int i = 0; i < columnCount; i++) { columnIndices[i] = i; } int[] shuffledColumns = columnIndices.OrderBy(x => Util.rnd.Next()).ToArray(); addRandomButton(level, shuffledColumns[0], PlayerName.Fighter); addRandomButton(level, shuffledColumns[1], PlayerName.Hacker); addRandomButton(level, shuffledColumns[2], PlayerName.Rogue); for (int i = 3; i < columnCount; i++) { addRandomButton(level, shuffledColumns[i], primaryPlayer); } int noteAddAttempts = Util.randExclusive(level.minNoteAddAttempts, level.maxNoteAddAttempts + 1); for (int i = 0; i < noteAddAttempts; i++) { addRandomButton(level, Util.randExclusive(0, columnCount), primaryPlayer); } }
public string DoubtMsg() { if (PlayerName.Contains("Player1")) { avatar.sprite = characterSprite[1]; } if (PlayerName.Contains("Player2")) { avatar.sprite = characterSprite[2]; } if (PlayerName.Contains("Player3")) { avatar.sprite = characterSprite[1]; } if (PlayerName.Contains("Player4")) { avatar.sprite = characterSprite[1]; } switch (Random.Range(0, 1)) { case 0: return("Doubt!"); default: return("..."); } }
public async Task <IActionResult> UpdateName([FromBody] PlayerName player) { await commandService.Issue(new UpdatePlayerName(User.Id(), User.CallSign(), player.FirstName, player.LastName)); return(Ok()); }
/// <summary> /// Handles the TurnOver event by having the /// other player take their turn /// </summary> /// <param name="player">who finished their turn</param> /// <param name="newConfiguration">the new board configuration</param> void HandleTurnOverEvent(PlayerName player, Configuration newConfiguration) { board.Configuration = newConfiguration; // check for game over if (newConfiguration.Empty) { // fire event with winner if (player == PlayerName.Player1) { gameOverEvent.Invoke(PlayerName.Player2, player1_Difficulty, player2_Difficulty); pauseBetweenGamesTimer.Run(); } else { gameOverEvent.Invoke(PlayerName.Player1, player1_Difficulty, player2_Difficulty); pauseBetweenGamesTimer.Run(); } } else { // game not over, so give other player a turn if (player == PlayerName.Player1) { takeTurnEvent.Invoke(PlayerName.Player2, newConfiguration); } else { takeTurnEvent.Invoke(PlayerName.Player1, newConfiguration); } } }
public Player(int id, PlayerName name, int pairId) { Id = id; Name = name; PairId = pairId; Turns = new List <Turn>(); }
// Update is called once per frame void Update() { if (hasHitCup && !isLiveBall()) { lastHitter = lastHitter == PlayerName.One ? PlayerName.One : PlayerName.Two; } }
public void SpawnDeathText(PlayerName playerName, GameObject player, int count) { Vector3 position = new Vector3(player.transform.position.x, deathTextPositions.x, player.transform.position.z); GameObject text = Instantiate(deathTextPrefab, position, deathTextPrefab.transform.rotation); //text.transform.LookAt (GameObject.FindGameObjectWithTag ("MainCamera").transform); text.transform.GetChild(0).GetComponent <Outline>().effectColor = GlobalVariables.Instance.playersColors[(int)playerName]; if (count == 0) { text.transform.GetChild(0).GetComponent <Text>().text = "Dead!"; } else if (count != 1) { text.transform.GetChild(0).GetComponent <Text>().text = count + " lives"; } else { text.transform.GetChild(0).GetComponent <Text>().text = count + " life"; } text.transform.DOMoveY(deathTextPositions.y, deathTextDuration).SetEase(Ease.OutQuad).SetUpdate(false); text.transform.DOScale(0, 1f).SetEase(Ease.OutQuad).SetDelay(deathTextDuration * 0.9f).OnComplete(() => Destroy(text)).SetUpdate(false); }
public void CraigSelectActivate() { var navigation = selectbutton.navigation; navigation.selectOnUp = craigbutton; selectbutton.navigation = navigation; selectedPlayer = PlayerName.Craig; ModifyButton (); }
internal static IInstruction Parse(PlayerName name, string[] splited) { int points; if (Int32.TryParse(splited[3], out points) && points >= 0) { return new ComboInstruction(name, points); } return null; }
internal static IInstruction Parse(PlayerName name, string[] splited) { int value; if (Int32.TryParse(splited[2], out value) && value >= 0) { return new StackInstruction(name, value); } return null; }
public Position GetPosition(PlayerName player) { if (this.IsCached) { return this.RetrieveFromCache(); } return this.service.GetPosition(player); }
public void AmySelectActivate() { var navigation = selectbutton.navigation; navigation.selectOnUp = amybutton; selectbutton.navigation = navigation; selectedPlayer = PlayerName.Amy; ModifyButton (); }
public void WillSelectActivate() { var navigation = selectbutton.navigation; navigation.selectOnUp = willbutton; selectbutton.navigation = navigation; selectedPlayer = PlayerName.Will; ModifyButton (); }
internal static IInstruction Parse(PlayerName name, string[] splited) { int skips; if (Int32.TryParse(splited[3], out skips) && skips >= 0) { return new SkipsInstruction(name, skips); } return null; }
// Update is called once per frame void Update() { if(EventSystem.current.currentSelectedGameObject != selectbutton.gameObject){ selectbutton.interactable = false; selectbutton.GetComponentInChildren<Text>().text = "Select"; selectedPlayer = PlayerName.None; confirm.enabled = false; } }
/// <summary> /// Calculates the score for the current boards /// </summary> /// <param name="boards">array of 10 boards (9 tiny boards + 1 macroboard), each of which with 9 ints (0 = not played, 1 = player1, 2 = player2)</param> /// <param name="playableBoards">array of playable tiny boards</param> /// <param name="player">Current player</param> /// <returns>Score</returns> public int Evaluate(int[][] boards, bool[] playableBoards, PlayerName player) { if (boards.Length != 10) throw new Exception("boards must have 10 elements"); if (playableBoards.Length != 9) throw new Exception("playableboards must have 9 elements"); int score = 0; foreach(int i in Enumerable.Range(0, 9).Where(i => playableBoards[i])) { score += EvaluateBoard(boards[i], player); } score += EvaluateMacroBoard(boards[9], player); return score; }
public PlayerState this[PlayerName name] { get { switch (name) { case PlayerName.player1: return Player1; case PlayerName.player2: return Player2; default: return null; } } }
public Player this[PlayerName name] { get { switch (name) { case PlayerName.Player1: return Player1; case PlayerName.Player2: return Player2; case PlayerName.None: default: return null; } } }
internal static IInstruction Parse(PlayerName name, string[] splitted) { if (splitted.Length != 3) { return null; } switch (splitted[1].ToUpperInvariant()) { case "STACK": return StackInstruction.Parse(name, splitted); case "POST": return PostInstruction.Parse(name, splitted); case "HAND": return HandInstruction.Parse(name, splitted); case "FOLD": case "CALL": case "CHECK": case "RAISE": return ActionInstruction.Parse(name, splitted); case "WINS": return WinsInstruction.Parse(name, splitted); } return null; }
internal static IInstruction Parse(PlayerName name, string[] splited) { var type = (GameActionType)Enum.Parse(typeof(GameActionType), splited[1], true); int value; if (Int32.TryParse(splited[2], out value) && value >= 0) { switch (type) { case GameActionType.fold: return new ActionInstruction(name, GameAction.Fold); case GameActionType.call: return new ActionInstruction(name, GameAction.Call); case GameActionType.check: return new ActionInstruction(name, GameAction.Check); case GameActionType.raise: return new ActionInstruction(name, GameAction.Raise(value)); } } return null; }
public static ushort Create(GameState state, PlayerName name, int r) { ushort row = 0; for (var c = 0; c < 10; c++) { if (state[name].Field[r, c] == FieldInstruction.FixedBlock) { row |= Flag[c]; } else if (state[name].Field[r, c] == FieldInstruction.LockedBlock) { return Row.Locked; } } return row; }
public bool SetPlayer(int num, PlayerName nam) { //prepare player to be set if (players [num].name == nam) { Debug.Log ("Picking the same character... okay?"); return true; } foreach (KeyValuePair<int,Player> player in players){ if(player.Value.name == nam){ Debug.Log ("Player already chosen by "+player.Value.number.ToString()); return false; } } Debug.Log ("Set!"); players [num].name = nam; return true; }
public void SelectActivate(GameObject go) { //Player.players.Add(player_num,new Player()); //Player.players[player_num].name = _dicPlayerNameByName[name]; if (player_num == 1) { player1name = _dicPlayerNameByGO[go]; _dicButtonByName[player1name].interactable = false; } if (player_num == 2) { player2name = _dicPlayerNameByGO[go]; } if (player_num == SceneManager.players) { Application.LoadLevel ("Game"); } else { player_num++; } }
internal static IInstruction Parse(PlayerName name, string[] splited) { var rows = new List<int[]>(); foreach(var row in splited[3].Split(';')) { var cells = row.Split(','); if (!cells.All(c => c == "0" || c == "1" || c == "2" || c == "3")) { return null; } rows.Add(cells.Select(c => Int32.Parse(c)).ToArray()); } if (!rows.All(row => row.Length == rows[0].Length)) { return null; } var field = new int[rows.Count, rows[0].Length]; for (var row = 0; row < rows.Count; row++) { for (var col = 0; col < rows[0].Length; col++) { field[row, col] = rows[row][col]; } } return new FieldInstruction(name, field); }
public StackInstruction(PlayerName name, int value) { m_Name = name; m_Value = value; }
private static ACDCBot GetBot(NodeCollection nodes, PlayerName name, MT19937Generator rnd) { var bot = new ACDCBot(nodes, rnd) { Settings = new Settings() { YourBot = name, }, }; return bot; }
public ComboInstruction(PlayerName name, int points) { m_Name = name; m_Points = points; }
public ActionInstruction(PlayerName name, GameAction value) { m_Name = name; m_Value = value; }
public FieldInstruction(PlayerName name, int[,] field) { m_Name = name; m_Field = field; }
public HandInstruction(PlayerName name, Cards hand) { m_Name = name; m_Value = hand; }
internal static IInstruction Parse(PlayerName name, string[] splited) { var hand = Cards.Parse(splited[2]); return new HandInstruction(name, hand); }
public Player(PlayerName name) { _player = (byte) name; }
public static int EvaluateBoard(int[] board, PlayerName player) { if (board.Length != 9) throw new Exception("board must have 9 elements"); int score = 0; int playerId = (int)player; int opponentPlayerId = 3 - playerId; foreach(var tictactoe in TicTacToes) { int mine = (board[tictactoe[0]] == playerId ? 1 : 0) + (board[tictactoe[1]] == playerId ? 1 : 0) + (board[tictactoe[2]] == playerId ? 1 : 0); int his = (board[tictactoe[0]] == opponentPlayerId ? 1 : 0) + (board[tictactoe[1]] == opponentPlayerId ? 1 : 0) + (board[tictactoe[2]] == opponentPlayerId ? 1 : 0); if (mine == 0 && his == 0) score += 1; //Both empty else if (mine > 0 && his > 0) score += 0; //Neither else if (mine == 1) score += 3; //Mine: 1 else if (mine == 2) score += 5; //Mine: 2 else if (his == 1) score += 2; //His: 1 else if (his == 2) score += 4; //His: 2 } return score; }
public int EvaluateMacroBoard(int[] board, PlayerName player) { return EvaluateBoard(board, player); }