public Match(IOpponent opponent1, IOpponent opponent2, int bestOfTotal) { _opponent1 = opponent1; _opponent2 = opponent2; _bestOfTTotal = bestOfTotal; IntiSets(); }
public GameInstance() { Console.WriteLine("What kind of opponent would you like? 'Ai' or 'Human'"); _opponentType = SelectOpponentType(); _opponent = CreateOpponent(_opponentType); InitaliseGameLoop(_mainPlayer, _opponent); }
/// <summary> /// Implements <see cref="IComparer{IOpponent}"/> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public int Compare(IOpponent <int> x, IOpponent <int> y) { if (x == null) { throw new ArgumentNullException(nameof(x)); } if (y == null) { throw new ArgumentNullException(nameof(y)); } if (x.Home < y.Home) { return(-1); } if (x.Home > y.Home) { return(1); } // Home points are equal if (x.Guest < y.Guest) { return(1); } if (x.Guest > y.Guest) { return(-1); } // Home and guest points are equal return(0); }
public Predictor(IOpponent opponent, ReadOnlyCollection <Deck> metaDecks) { Log.Debug("Copying possible decks from the meta"); _classDecks = new List <Deck>(metaDecks); _possibleDecks = new List <Deck>(metaDecks); _opponent = opponent; CheckOpponentClass(); CheckOpponentMana(); }
// Start is called before the first frame update void Start() { if (IsNetworkedGame) { InstantiateNetworkController(); } OpponentController = OpponentControllerObject.GetComponent <IOpponent>(); GameCoreController.Instance.Opponent = OpponentController; StartCoroutine(GameCoreController.Instance.PlayGame()); }
/* * Our main game loops, all instances of the game are held here. */ public void StartAiOpponentGameLoop(MainPlayer mainPlayer, IOpponent opponent) { Console.ForegroundColor = ConsoleColor.DarkRed; // throw new NotImplementedException("To be done at later date"); mc.Draw(_gameMap, mainPlayer, opponent as Player); while (true) { Play(_gameMap, mainPlayer, opponent as IPlayer); Play(_gameMap, opponent as IPlayer, mainPlayer); } }
private void InitaliseGameLoop(MainPlayer mainPlayer, IOpponent opponent) { if (opponent is Ai) { StartAiOpponentGameLoop(mainPlayer, opponent); } else { Console.BackgroundColor = ConsoleColor.White; StartPlayerOpponentGameLoop(mainPlayer, opponent); } }
public void StartPlayerOpponentGameLoop(MainPlayer mainPlayer, IOpponent opponent) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Blue; IPlayer ipOpponent = (IPlayer)opponent; mc.Draw(_gameMap, mainPlayer, ipOpponent); while (true) { Play(_gameMap, mainPlayer, ipOpponent); Play(_gameMap, ipOpponent, mainPlayer); } }
public bool Beats(IOpponent opponent) { return opponent.BeatenByPaper(); }
public bool Beats(IOpponent opponent) { return(opponent.BeatenByScissors()); }
public bool Beats(IOpponent opponent) { return(opponent.BeatenByPaper()); }
public bool Beats(IOpponent opponent) { return(opponent.BeatenByRock()); }
/// <summary> /// Start playground in a regular fashion when a match is known /// </summary> private async void StartRegular(MatchEntity match) { // which player are we? playerColor = match.WhitePlayer == Auth.Player ? PieceColor.White : PieceColor.Black; // who is the opponent UnisavePlayer opponentPlayer = playerColor.IsWhite() ? match.BlackPlayer : match.WhitePlayer; // connect to the opponent if (opponentPlayer == null) { // AI Debug.Log("Starting computer opponent..."); opponent = new ComputerOpponent( playerColor.Opposite(), board, match.Duration ); } else { // Real person Debug.Log("Connecting to photon opponent..."); opponent = PhotonOpponent.CreateInstance(match.EntityId); } // create and setup the board board.CreateBoard( playerColor.IsWhite(), match.WhitePlayerSet, match.BlackPlayerSet ); // create the clock clock = new Clock(match.Duration); // register opponent events opponent.OnMoveFinish += OpponentsMoveWasFinished; opponent.OnGiveUp += OnOpponentGaveUp; opponent.OnOutOfTime += OnOpponentTimeOver; // wait for the opponent Debug.Log("Waiting for the opponent..."); await opponent.WaitForReady(); // === start the game === // if we are white, we are the one to start Debug.Log("Game has started."); if (playerColor.IsWhite()) { PerformOurMove(); } else { // it's the opponents turn so just wait clock.StartOpponent(); } }
/// <summary> /// Implements <see cref="IComparable{IResult}"/> /// </summary> /// <param name="other"></param> /// <returns></returns> public int CompareTo(IOpponent <int> other) { return(Compare(this, other)); }
public void KeyDown(Commands cmd) { if (Client.IsPlaying) { if (_isConfusionActive) { Commands confusedCmd; if (_confusionMapping.TryGetValue(cmd, out confusedCmd)) cmd = confusedCmd; } if (_timers.ContainsKey(cmd) && _timers[cmd].IsEnabled) return; switch (cmd) { case TetriNET.Client.Interfaces.Commands.Hold: Client.Hold(); break; case TetriNET.Client.Interfaces.Commands.Drop: Client.Drop(); break; case TetriNET.Client.Interfaces.Commands.Down: Client.MoveDown(); break; case TetriNET.Client.Interfaces.Commands.Left: Client.MoveLeft(); break; case TetriNET.Client.Interfaces.Commands.Right: Client.MoveRight(); break; case TetriNET.Client.Interfaces.Commands.RotateClockwise: Client.RotateClockwise(); break; case TetriNET.Client.Interfaces.Commands.RotateCounterclockwise: Client.RotateCounterClockwise(); break; case TetriNET.Client.Interfaces.Commands.DiscardFirstSpecial: Client.DiscardFirstSpecial(); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOn1: Client.UseFirstSpecial(0); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOn2: Client.UseFirstSpecial(1); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOn3: Client.UseFirstSpecial(2); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOn4: Client.UseFirstSpecial(3); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOn5: Client.UseFirstSpecial(4); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOn6: Client.UseFirstSpecial(5); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOnSelf: Client.UseFirstSpecial(Client.PlayerId); break; case TetriNET.Client.Interfaces.Commands.UseSpecialOnRandomOpponent: { IOpponent[] opponents = Client.Opponents.ToArray(); if (opponents.Any()) { int rnd = Randomizer.Instance.Next(opponents.Length); IOpponent opponent = opponents[rnd]; if (opponent != null) Client.UseFirstSpecial(opponent.PlayerId); } } break; } if (_timers.ContainsKey(cmd)) _timers[cmd].Start(); } }
public PredictionController(IOpponent opponent, ReadOnlyCollection <Deck> metaDecks) { _opponent = opponent; _predictor = new Predictor(opponent, metaDecks); _predictionLog = new CustomLog(LogName); }
public bool Beats(IOpponent opponent) { return opponent.BeatenByScissors(); }
public bool Beats(IOpponent opponent) { return opponent.BeatenByRock(); }
public void KeyDown(Commands cmd) { if (Client.IsPlaying) { if (_timers.ContainsKey(cmd) && _timers[cmd].Enabled) { return; } switch (cmd) { case Commands.Hold: Client.Hold(); break; case Commands.Drop: Client.Drop(); break; case Commands.Down: Client.MoveDown(); break; case Commands.Left: Client.MoveLeft(); break; case Commands.Right: Client.MoveRight(); break; case Commands.RotateClockwise: Client.RotateClockwise(); break; case Commands.RotateCounterclockwise: Client.RotateCounterClockwise(); break; case Commands.DiscardFirstSpecial: Client.DiscardFirstSpecial(); break; case Commands.UseSpecialOn1: Client.UseFirstSpecial(0); break; case Commands.UseSpecialOn2: Client.UseFirstSpecial(1); break; case Commands.UseSpecialOn3: Client.UseFirstSpecial(2); break; case Commands.UseSpecialOn4: Client.UseFirstSpecial(3); break; case Commands.UseSpecialOn5: Client.UseFirstSpecial(4); break; case Commands.UseSpecialOn6: Client.UseFirstSpecial(5); break; case Commands.UseSpecialOnSelf: Client.UseFirstSpecial(Client.PlayerId); break; case Commands.UseSpecialOnRandomOpponent: { IOpponent opponent = Client.Opponents.FirstOrDefault(); if (opponent != null) { Client.UseFirstSpecial(opponent.PlayerId); } } break; } if (_timers.ContainsKey(cmd)) { _timers[cmd].Start(); } } }