public GameManager(IGameRules rules) { Board = new ObservableCollection<int>(); Rules = rules; BindingOperations.EnableCollectionSynchronization(board, _lock); this.GameFinished = true; }
public MinMax(VERSION version, IGameRules <GAME_BOARD, GAME_MOVE_DESCRIPTION> rules, int max_depth = 0) { this.version = version; this.rules = rules; this.max_depth = max_depth; useSmartDepth = max_depth == USE_SMART_DEPTH; }
public ConstructForm(IDataProvider dataProvider, IGameRules gameRules) { questionController = new QuestionController(dataProvider, gameRules); questionController.RefreshPackNameList(); InitializeComponent(); PackList.Items.AddRange(questionController.packNameList.ToArray()); }
public BoundaryLessGrid CreateNextGeneration(IGameRules gameRules) { var nextGen = Clone(_cells); for (int x = 0; x < _cells.GetLength(0); x++) { for (int y = 0; y < _cells.GetLength(1); y++) { var currentCellReadonly = _cells[x, y].GetReadOnlyVersion(); var nextState = gameRules.GetNextState(currentCellReadonly, GetNeighbours(x, y)); if (nextState == CellState.Alive && _cells[x, y].IsDead()) { nextGen[x, y].Revive(); } else if (nextState == CellState.Dead) { nextGen[x, y].Kill(); } } } return(new BoundaryLessGrid(nextGen)); }
public void SetUp() { var rulesDictionary = new Dictionary <GameAction, List <GameAction> >() { { GameAction.Rock, new List <GameAction>() { GameAction.Scissors } }, { GameAction.Paper, new List <GameAction>() { GameAction.Rock } }, { GameAction.Scissors, new List <GameAction>() { GameAction.Paper } } }; GameRules = new GameRules(rulesDictionary); PlayerMocks = new List <Mock <IPlayer> >(); Players = new List <IPlayer>(); Moves = new List <IMove>(); UiControllerMock = new Mock <IUserInteraction>(); }
public QuestionController(IDataProvider dataProvider, IGameRules gameRules) { GameRules = gameRules; DataProvider = dataProvider; timer.Tick += new EventHandler(Timer_Tick); TimeLeftToAnswer = GameRules.TimeToAnswer; questionPack = new QuestionPack(gameRules); }
public Game(IGameRules gameRules) { this.gameRules = gameRules; Arena = new Arena(this.gameRules.ARENA_WIDTH, this.gameRules.ARENA_HEIGHT); Teams = new List <Team>(); PodRacers = new List <PodRacer>(); }
public SantaseGame(IPlayer firstPlayer, IPlayer secondPlayer, IGameRules gameRules, ILogger logger) { this.RestartGame(); this.firstPlayer = firstPlayer; this.secondPlayer = secondPlayer; this.gameRules = gameRules; this.logger = logger; }
public Move MakeMove(IGameRules gameRules) { var validOptions = gameRules.ValidOptions.ToList(); var numberOfOptions = validOptions.Count; string moveToMake = validOptions[_rand.Next(0, numberOfOptions)]; return(new Move(this, moveToMake)); }
public SpaceShip(IGameRules gameRules) { size = gameRules.Width / SIZE_RATIO; leftBoundary = topBoundary = 0 - size / 4; rightBoundary = gameRules.Width - size * (3.0 / 4); bottomBoundary = gameRules.Height - size * (3.0 / 4); x = gameRules.Width / 2 - size / 2; y = gameRules.Height - size - gameRules.Height / 30; }
public GameState(TetrominoType firstBlock, IGameRules gameRules, IRng rng) { NextTetromino = firstBlock; GameRules = gameRules; Rng = rng; Board = new MutableBoard(gameRules); Time = 0; Level = 0; }
public AsteroidsGame(IGameRules gameRules, int fps) { this.gameRules = gameRules; viewUpdateInterval = 0 == fps ? 0 : 1000 / fps; timer = new Timer(gameRules.SpeedMs); timer.Elapsed += gameLoop; stopWatch = new Stopwatch(); GameState = EGameState.GameOver; }
public PlayerFactory(IPlayerEntity playerEntity, IGameRules gameRules, IFrameEntity frameEntity, IFrameMapper frameMapper) { GameRules = gameRules; FrameEntity = frameEntity; PlayerEntity = playerEntity; FrameMapper = frameMapper; }
public Player(IMove move, IPosition startPosition, int lives, IBoardRules boardRules, IGameRules playerReaction) { this.move = move; numberOfLives = lives; this.boardRules = boardRules; this.playerReaction = playerReaction; currentPosition = startPosition; }
public GameStateMachine CreateNewGame(IGameRules gameRules) { var gameId = Guid.NewGuid(); var game = TryCreateGame(gameId, gameRules); if (game == null) { throw new InvalidOperationException($"Failed to create new game: {gameId}"); } return(game); }
public static IGame CreateGame ( IGameRules rules, IPlayer player1, IPlayer player2, byte gameSize ) { var history = new History(); return(new Implementations.Game(rules, player1, player2, history, gameSize)); }
/// <summary> /// /// </summary> /// <param name="title"></param> /// <param name="author"></param> /// <param name="players"></param> /// <param name="rules"></param> /// <param name="interactionController"></param> /// <param name="match"></param> /// <param name="score"></param> /// <param name="matchResult"></param> public Application(string title, string author, List <IPlayer> players, IGameRules rules, IUserInteraction interactionController, Contest match, IScore score, IContestResult matchResult) { Title = title; Author = author; Players = players; Rules = rules; InteractionController = interactionController; Match = match; Score = score; MatchResult = matchResult; }
public MutableBoard(IGameRules gameRules, int width = 10, int heightVisible = 20) { GameRules = gameRules; Width = width; HeightVisible = heightVisible; Height = heightVisible + 2; m_Data = new TetrominoType[Width * Height]; for (int i = 0; i < m_Data.Length; ++i) { m_Data[i] = TetrominoType.Empty; } }
public Game(IBoard board, int numOfPlayers, IGameRules rules) { Board = (Board.Board)board; //TODO: remove type casting Rules = rules; NumberOfUniversities = numOfPlayers; ProbabilityWithNoCut = Math.Pow( (1 - GameConstants.DiceRollNumber2Chance[7]/GameConstants.Chance.TotalDiceRoll), NumberOfUniversities ); CreateUniversities(numOfPlayers); Round = 1; Reset(); }
public GameStateMachine?TryCreateGame(Guid gameId, IGameRules gameRules) { var game = new GameStateMachine(gameId, gameRules, this); if (!gamesById.TryAdd(game.GameId, game)) { return(null); } gamesByPlayerKey.TryAdd(game.DefenderKey, game); gamesByPlayerKey.TryAdd(game.AttackerKey, game); return(game); }
public GameServiceTest() { var serviceProvider = new ServiceCollection() .AddLogging() .BuildServiceProvider(); var factory = serviceProvider.GetService <ILoggerFactory>(); _logger = factory.CreateLogger <GameService>(); _repository = new FakeCardsRepository("GameServiceTestDb"); _rules = new FakeGameRules(); _gameService = new GameService(_repository, _logger, _rules); }
public Game(IGameRules rules, IPlayer player1, IPlayer player2, IHistory history, byte size) { // remove this intialization player1.Figures = new List <IFigure>(); player2.Figures = new List <IFigure>(); _history = history; Size = size; Rules = rules; Board = new Board(player1, player2, size); Rules.PlaceFigures(Board); }
public Trick( RoundPlayerInfo firstToPlay, RoundPlayerInfo secondToPlay, IStateManager stateManager, IDeck deck, IGameRules gameRules) { this.firstToPlay = firstToPlay; this.secondToPlay = secondToPlay; this.stateManager = stateManager; this.deck = deck; this.gameRules = gameRules; }
public static IGrid GetNextGenerationGrid(IGrid currentGrid, IGameRules gameRules) { try { return new Generation().GetNextGeneration(currentGrid, gameRules); } catch (Exception e) { System.Console.WriteLine(e); ApplicationLogger.LogException(1, e, LogCategory.Business, TraceEventType.Error); } return null; }
/// <summary> /// By applying game rules get the next genertion grid instance /// </summary> /// <param name="currentGrid"> Grid on which games rules </param> /// <param name="gameRules"> </param> /// <returns> Evolved grid instance </returns> public IGrid GetNextGeneration(IGrid currentGrid, IGameRules gameRules) { if (currentGrid != null && gameRules != null) { var gridCopy = currentGrid.Copy(currentGrid); foreach (var cell in currentGrid.GetAllCurrentCellInfo()) { cell.Alive = gameRules.WillBeAliveInNextGeneration(gridCopy, cell); gridCopy.MakeCell(cell); } return gridCopy; } return null; }
public SimRound( ISimPlayer firstPlayer, ISimPlayer secondPlayer, IGameRules gameRules, PlayerPosition firstToPlay = PlayerPosition.FirstPlayer) { this.gameRules = gameRules; this.deck = new SimDeck(); this.stateManager = new SimStateManager(); this.firstPlayer = new SimRoundPlayerInfo(firstPlayer); this.secondPlayer = new SimRoundPlayerInfo(secondPlayer); this.firstToPlay = firstToPlay; }
public GameMaker(int rowCount, int rowWidth, int groundFrom, int groundTo, GameObject player, ILevelGenerator levelGenerator, IGameRules gameRules, IWorldCreator worldCreator) { _rowCount = rowCount; _rowWidth = rowWidth; _groundFrom = groundFrom; _groundTo = groundTo; _worldCreator = worldCreator; _player = player; _levelGenerator = levelGenerator; _gameRules = gameRules; Debug.Log("New game, GameMaker constructor."); }
private SemaphoreHost(IGameRules gameRules, IGameResolver gameResolver, IEnumerable<IParserPlayer> playersIncome, ILogger logger) { Logger = logger; resolver = gameResolver; // init players this.players = playersIncome.ToConcurrentQueue(gameRules, gameResolver, mi); // devise a game finish condition ctSrc = new CancellationTokenSource(gameResolver.MaxMilliseconds); ctSrc.Token.Register(CancellationRoutine); sem = new SemaphoreSlim(0, 1); }
public Round( IPlayer firstPlayer, IPlayer secondPlayer, IGameRules gameRules, PlayerPosition firstToPlay = PlayerPosition.FirstPlayer) { this.gameRules = gameRules; this.deck = new Deck(); this.stateManager = new StateManager(); this.firstPlayer = new RoundPlayerInfo(firstPlayer); this.secondPlayer = new RoundPlayerInfo(secondPlayer); this.firstToPlay = firstToPlay; }
private static void StartGame() { IPlayer player1 = ChoosePlayerType(1); Console.Clear(); player1.Initialise(); Console.Clear(); IPlayer player2 = ChoosePlayerType(2); Console.Clear(); player2.Initialise(); Console.Clear(); IGameRules gameRules = GetGameRules(player1, player2); Console.WriteLine("Hit any key to begin"); Console.ReadKey(); Console.Clear(); int round = 1; while (!gameRules.HasWinner()) { Console.WriteLine($"-----------ROUND {round}------------"); var player1Move = player1.MakeMove(gameRules); Console.WriteLine($"{player1.PlayerName} chose: {player1Move.ChosenOption}"); var player2Move = player2.MakeMove(gameRules); Console.WriteLine($"{player2.PlayerName} chose: {player2Move.ChosenOption}"); var result = gameRules.GetRoundWinner(player1Move, player2Move); if (result.HasWinner) { Console.WriteLine($"{result.Winner.PlayerName} is the winner in round {round}"); } else { Console.WriteLine($"Round {round} was a draw"); } Console.WriteLine(); Console.WriteLine("-----CURRENT SCOREBOARD------"); Console.WriteLine(gameRules.GetCurrentResults()); Console.WriteLine(); Console.WriteLine("Hit any key to start the next round"); Console.ReadKey(); Console.Clear(); round++; } Console.WriteLine($"{gameRules.GetGameWinner().Winner.PlayerName} is the winner!!"); }
public Move MakeMove(IGameRules gameRules) { Move move; if (string.IsNullOrWhiteSpace(_lastMove)) { move = GetRandomMove(gameRules); } else { move = new Move(this, gameRules.WhatBeats(_lastMove)); } _lastMove = move.ChosenOption; return(move); }
public static Player NewPlayer(PlayerType pType, string name, IGameRules rules) { switch (pType) { case PlayerType.Random: return(new PlayerRandom(name, rules)); break; case PlayerType.Memory: return(new PlayerMemory(name, rules)); break; case PlayerType.Thorough: return(new PlayerThorough(name, rules)); break; case PlayerType.Cheater: return(new PlayerCheater(name, rules)); break; case PlayerType.ThoroughCheater: return(new PlayerThoroughCheater(name, rules)); break; } return(null); }
public Move MakeMove(IGameRules gameRules) { var validMoves = gameRules.ValidOptions.ToList(); OutputMoves(validMoves); int chosenMove; while (!int.TryParse(ReadInUserInput(), out chosenMove) || validMoves.ElementAtOrDefault(chosenMove - 1) == null) { OutputGameInfo("You didn't enter a valid move, Try again...."); OutputMoves(validMoves); } return(new Move(this, validMoves[chosenMove - 1])); }
Random rand = new Random(); //??? public GameForm(IDataProvider dataProvider, IGameRules gameRules) { questionController = new QuestionController(dataProvider, gameRules); questionController.RefreshPackNameList(); InitializeComponent(); CreateRadio(); questionController.timer.Tick += new EventHandler(Timer_Tick); if (!gameRules.HintsAvailable) { foreach (Button item in hintsPanel.Controls) { item.Enabled = false; item.BackgroundImage = ToolStripRenderer.CreateDisabledImage(item.BackgroundImage); } } }
public SimRound( ISimPlayer firstPlayer, ISimPlayer secondPlayer, IGameRules gameRules, IDeck deck, ISimStateManager stateManager, PlayerPosition firstToPlay = PlayerPosition.FirstPlayer) { this.gameRules = gameRules; this.deck = deck; this.stateManager = new SimStateManager(); //stateManager; this.firstPlayer = new SimRoundPlayerInfo(firstPlayer); this.secondPlayer = new SimRoundPlayerInfo(secondPlayer); this.firstToPlay = firstToPlay; }
public DefaultGame(IApp app, IGameBoard board, IPlayer player1, IPlayer player2, IGameRules gameRules) { if (app == null) throw new ArgumentNullException(nameof(app)); if (player1 == null) throw new ArgumentNullException(nameof(player1)); if (player2 == null) throw new ArgumentNullException(nameof(player2)); if (player1.Equals(player2)) throw new ArgumentException($"{nameof(player1)} is the same as {nameof(player2)}"); if (player1.Name == player2.Name) throw new ArgumentException( $"{nameof(player1)}.{nameof(player1.Name)} == {nameof(player2)}.{nameof(player2.Name)}"); this.App = app; this.Players = new [] { player1, player2 }; var reversedBoard = new DefaultBoard(new ReversedLanes(board.Lanes), board.Bar, board.BearedOff); this.Boards = new [] { board, reversedBoard }; this.Rules = gameRules; }
public GameOfLife(IGameRules gameRules) { _gameRules = gameRules; }
public void SetUp() { rules = new DefaultGameRules(); }
public void Uninitialize() { this.app = null; this.gameRules = null; }
public void Initialize(IInitializeContext context) { this.app = context.App; this.gameRules = new DefaultGameRules(); }
// TODO: Should last trick winner wins 10 additional points? // TODO: What if the total score is 65:65 after giving 10 additional points? Should the player with the last trick win the round? public RoundWinnerPoints GetWinnerPoints( int firstPlayerPoints, int secondPlayerPoints, PlayerPosition gameClosedBy, PlayerPosition noTricksPlayer, IGameRules gameRules) { if (gameClosedBy == PlayerPosition.FirstPlayer) { if (firstPlayerPoints < gameRules.RoundPointsForGoingOut) { return RoundWinnerPoints.Second(3); } } if (gameClosedBy == PlayerPosition.SecondPlayer) { if (secondPlayerPoints < gameRules.RoundPointsForGoingOut) { return RoundWinnerPoints.First(3); } } if (firstPlayerPoints == secondPlayerPoints) { // Equal points => 0 points to each return RoundWinnerPoints.Draw(); } if (firstPlayerPoints < gameRules.RoundPointsForGoingOut && secondPlayerPoints < gameRules.RoundPointsForGoingOut) { if (firstPlayerPoints > secondPlayerPoints) { return RoundWinnerPoints.First(1); } if (secondPlayerPoints > firstPlayerPoints) { return RoundWinnerPoints.Second(1); } } if (firstPlayerPoints > secondPlayerPoints) { if (secondPlayerPoints >= gameRules.HalfRoundPoints) { return RoundWinnerPoints.First(1); } if (noTricksPlayer == PlayerPosition.SecondPlayer) { return RoundWinnerPoints.First(3); } // at lest one trick and less than half of the points return RoundWinnerPoints.First(2); } else { // secondPlayerPoints > firstPlayerPoints if (firstPlayerPoints >= gameRules.HalfRoundPoints) { return RoundWinnerPoints.Second(1); } if (noTricksPlayer == PlayerPosition.FirstPlayer) { return RoundWinnerPoints.Second(3); } // at lest one trick and less than half of the points return RoundWinnerPoints.Second(2); } }
public PlayersTrainerBase(IGameRules rules) { this.gameManager = new GameManager(rules); ShouldMinimize = false; RequireSingleThreaded = true; }
public PlayersStorage(IConnectionProvider connectionProvider, IGameRules gameRules) { _ConnectionProvider = connectionProvider; _GameRules = gameRules; }
public ColorPlayerTrainer(IGameRules rules, IPositionPlayer opponent) : base(rules) { gameManager.Player1 = opponent; }
public PositionStepTrainer(IGameRules rules) : base(rules) { gameManager.Player2 = new MeanColorPlayer(this.gameManager.Rules as VanDerWaerdenGameRules); }