public static void Start() { var renderer = new ConsoleRenderer(); int gameMode = int.Parse(renderer.RenderMainMenu()); var inputProvider = new ConsoleInputProvider(); var chessEngine = new StandardTwoPlayerEngine(renderer, inputProvider); IGameInitializationStrategy gameInitializationStrategy; switch (gameMode) { case 1: gameInitializationStrategy = new StandardStartGameInitializationStrategy(); chessEngine.Initialize(gameInitializationStrategy); chessEngine.Start(); break; case 2: gameInitializationStrategy = new Chess960StandardStartGameInitializationStrategy(); chessEngine.Initialize(gameInitializationStrategy); chessEngine.Start(); break; } Console.ReadLine(); }
static void Main(string[] args) { IInputProvider inputProvider = new ConsoleInputProvider(); IOutputProvider outputProvider = new ConsoleOutputProvider(); //IStorageProvider storageProvider = new LocalStorageProvider(); IStorageProvider storageProvider = new EFStorageProvider(); IClientProvider clientProvider = new WebClientProvider(); IPageProvider pageProvider = new WebClinetPageProvider(clientProvider); ILinkProcessorProvider linkProcessorProvider = new LinkProcessorProvider(outputProvider, storageProvider); IPageParserProvider pageParserProvider = new PageParserProvider(); WebPageProcessor wpp = new WebPageProcessor(storageProvider, inputProvider, outputProvider, pageProvider, linkProcessorProvider, pageParserProvider, 1000); wpp.Start(); Task.Run(() => { while (true) { Thread.Sleep(500); Console.WriteLine(wpp.numberOfThreadsRunning); } }); Console.ReadLine(); }
public static void Main() { int matrixLength = ConsoleInputProvider.GetInput(); Matrix matrix = Generator.Generate(matrixLength); ConsoleOutputProvider.PrintMatrix(matrix); }
private static void Main() { while (true) { var number = ConsoleInputProvider.GetIntegerInput("Enter a number to count it`s factorial: ", (i) => i >= 1, GetValidationMessage); var isYesInput = ConsoleInputProvider.GetYesNoInput("Enable recursive method? (y/n) "); if (number > 5000 && isYesInput) { Console.WriteLine($"Recursive method may not handle calculating of {number}!, please, choose another method or smaller number!"); continue; } if (number > 50000 && !isYesInput) { Console.WriteLine($"Iterative method may take too long to calculate {number}!, please, choose another method or smaller number!"); continue; } var factorial = isYesInput ? Recursive(number) : NonRecursive(number); Console.WriteLine($"Factorial of the number {number} is {factorial}."); Console.WriteLine("-------------------"); } }
static Program() { var configFactory = new ConfigFactory(); var cellFactory = new CellFactory(); var figureFactory = new FigureFactory(); var boardFactory = new BoardFactory(figureFactory, cellFactory); var linesFactory = new LinesFactory(); Console = new ConcreteConsole(); var consoleInputProvider = new ConsoleInputProvider(Console); var playerRegisterManager = new PlayerRegisterManager(consoleInputProvider, Console); PreparationService = new GamePreparationService(configFactory, playerRegisterManager, consoleInputProvider, Console); var inputManager = new GameInputProvider(consoleInputProvider, Console); PartyFinishedProvider = new PartyFinishProvider(consoleInputProvider); GameFactory = new GameFactory(boardFactory, linesFactory, inputManager); var figureDrawerFactory = new FigureDrawerFactory(Console); var figureDrawerProvider = new FigureDrawerProvider(figureDrawerFactory); BoardDrawer = new BoardDrawer(Console, figureDrawerProvider); }
public static void Start() { Console.WriteLine("Would you like to play Chess960?(y/n)"); string input = Console.ReadLine(); bool chess960 = false; if (input.ToLower() == "y") { chess960 = true; } var renderer = new ConsoleRenderer(); renderer.RenderMainMenu(); var inputProvider = new ConsoleInputProvider(); var chessEngine = new StandardTwoPlayerEngine(renderer, inputProvider); var gameInitializationStrategy = new StandardStartGameInitializationStrategy(); chessEngine.Initialize(gameInitializationStrategy, chess960); chessEngine.Start(); Console.ReadLine(); }
public static void Main() { IRenderer renderer = new ConsoleRenderer(); IInputProvider provider = new ConsoleInputProvider(); Facade facade = new Facade(); facade.Start(renderer, provider); }
/// <summary> /// Start method which hides game setup. /// </summary> public static void Start() { IRenderer renderer = new Renderers.ConsoleFancyRenderer(); IInputProvider provider = new ConsoleInputProvider(); Engine engine = new Engine(renderer, provider); engine.StartGame(); }
/// <summary> /// The main method of the program. /// </summary> public static void Main() { IInputProvider inputProvider = new ConsoleInputProvider(); ConsoleRenderer renderer = new ConsoleRenderer(); ICellDamageHandler damageHandler = new DefaultDamageHandler(); ConsoleGame consoleGame = new ConsoleGame(inputProvider, renderer, damageHandler); consoleGame.Start(); }
public static BigInteger RunVaccuumRobot(bool isManualInput) { // Upon inspection, the following commands solve the problem: // A,B,A,B,A,C,B,C,A,C // A: L,6,R,6,6,L,6 // B: R,6,6,L,5,5,L,4,L,6 // C: L,5,5,L,5,5,L,4,L,6 BigInteger[] program = GetDay17Input(); program[0] = 2; var encodedCommands = EncodeRobotCommands( mainMovementRoutine: "A,B,A,B,A,C,B,C,A,C", movementFunctionA: "L,6,R,6,6,L,6", movementFunctionB: "R,6,6,L,5,5,L,4,L,6", movementFunctionC: "L,5,5,L,5,5,L,4,L,6", continuousVideoFeed: false); IInputProvider inputProvider; if (isManualInput) { inputProvider = new ConsoleInputProvider(); } else { inputProvider = new BufferedInputProvider(); } var outputListener = new ListOutputListener(); IntcodeComputer computer = new IntcodeComputer(inputProvider, outputListener); computer.LoadProgram(program); var computerStatus = IntcodeProgramStatus.Running; int outputStartIndex = 0; int commandIndex = 0; while (IntcodeProgramStatus.Running.Equals(computerStatus) || IntcodeProgramStatus.AwaitingInput.Equals(computerStatus)) { // Provide inputs if automated if (IntcodeProgramStatus.AwaitingInput.Equals(computerStatus) && !isManualInput) { ((BufferedInputProvider)inputProvider).AddInputValue(encodedCommands[commandIndex]); Console.Write(encodedCommands[commandIndex]); commandIndex++; } // Run program computerStatus = computer.RunProgram(); // Display output if (outputListener.Values.Count > 0) { DisplayProgramOutput(outputListener, outputStartIndex); outputStartIndex = outputListener.Values.Count; } } return(outputListener.Values.LastOrDefault()); }
private RogueEngine(int width, int height, ConsoleInputProvider inputProvider) { this.input = inputProvider; Console.CursorVisible = false; ConsoleWidth = width; ConsoleHeight = height; // Set the console size and speed Console.SetWindowSize(ConsoleWidth, ConsoleHeight); Console.SetBufferSize(ConsoleWidth, ConsoleHeight); }
public void WhenArgDoesContainsOddNumberOfLines__InputNotValidExceptionOccurs(string arg, int expectedVehicleCount) { var sut = new ConsoleInputProvider(); Input input = sut.Provide(arg); Assert.NotNull(input); Assert.Equal("surface info", input.SurfaceParameter); Assert.Equal(expectedVehicleCount, input.VehicleAndCommandsParameterList.Count); }
/// <summary>Initializes a new instance of the <see cref="JokeLoop" /> class.</summary> public JokeLoop(/* [Dependency Injection] * IUserInfoClient userInfoClient, * IChuckNorrisClient chuckNorrisClient, * IOutputProvider output, * IInputProvider Input*/) { UserInfoClient = new UserInfoClient(); ChuckNorrisClient = new ChuckNorrisClient(); Output = new ConsoleOutputProvider(); Input = new ConsoleInputProvider(); }
public static void Start() { IRenderer renderer = new ConsoleRenderer(); IInputProvider inputProvider = new ConsoleInputProvider(); renderer.RenderMainMenu(); IChessEngine chessEngine = new StandardTwoPlayerEngine(renderer, inputProvider); IGameInitializationStrategy strategy = new StandardStartGameInitializationStrategy(); chessEngine.Initialize(strategy); chessEngine.Start(); }
public static void StartGame() { ConsoleHelpers.SetConsoleInfo(); IRenderer renderer = new ConsoleRenderer(); IInputProvider consoleInputProvider = new ConsoleInputProvider(); int size = consoleInputProvider.GetSize(); IEngine engine = new Engine(renderer, size); engine.Run(); }
private static void Main() { ICommandInputProvider commandInput = new CommandReader(); IInfoInputProvider menuInput = new Menu(); IInputProvider inputProvider = new ConsoleInputProvider(commandInput, menuInput); IInfoRenderer infoPanel = new InfoPanel(); IPlayFieldRenderer playFieldPanel = new PlayFieldPanel(); ILadderRenderer topScoresPanel = new TopScoresPanel(); IRenderer consoleRenderer = new ConsoleRender(infoPanel, playFieldPanel, topScoresPanel); LabyrinthFacade.Start(consoleRenderer, inputProvider, FileLogger.Instance()); }
public static void Main(string[] args) { var renderer = new ConsoleRenderer(); var inputProvider = new ConsoleInputProvider(); var board = new Board(); var fruitWarEngine = new StandardFruitWarEngine(renderer, inputProvider, board); fruitWarEngine.Initialize(); fruitWarEngine.Start(); Console.ReadLine(); }
static void Main(string[] args) { IData data = new Data(); IRenderer renderer = new ConsoleRenderer(); IInputProvider inputProvider = new ConsoleInputProvider(); IOutputProvider outputProvider = new ConsoleOutputProvider(); IGameInitializationStrategy gameInitializationStrategy = new StandardGameInitializationStrategy(); var engine = new StandardOnePlayerEngine(inputProvider, outputProvider, renderer, data); renderer.RenderMainMenu(); engine.Initialize(gameInitializationStrategy); engine.Run(); }
//static void OldMain(string[] args) //{ // var tournaments = ChallongeApiWrapper.GetTournamentList(CHALLONGE_USERNAME, CHALLONGE_APIKEY, CHALLONGE_SUBDOMAIN); // CsvWriter.WriteLine("tournament-list.csv", "Name of Event, Challonge URL, Participants"); // foreach (var tournament in tournaments) // { // var tdata = ChallongeApiWrapper.GetTournament(tournament.ApiUrl, CHALLONGE_USERNAME, CHALLONGE_APIKEY); // var name = tdata.Name; // var url = tdata.UrlAddress(); // var numParticipants = tdata.Participants.Count; // CsvWriter.WriteLine("tournament-list.csv", "{0}, {1}, {2}", name, url, numParticipants); // var filename = string.Format("{0}-participants.csv", tdata.ApiUrl); // CsvWriter.WriteLine(filename, "Tournament Name, Participant Name"); // foreach (var particiapant in tdata.Participants) // { // var participantName = particiapant.Name; // CsvWriter.WriteLine(filename, "{0}, {1}", name, participantName); // } // filename = string.Format("{0}-results.csv", tdata.ApiUrl); // CsvWriter.WriteLine(filename, "Tournament Name, Winner, Loser"); // foreach (var match in tdata.CompleteMatches) // { // var p1name = match.Player1 == null ? "Bye" : match.Player1.Name; // var p2name = match.Player2 == null ? "Bye" : match.Player2.Name; // if (match.WinnerId == match.Player1Id) // CsvWriter.WriteLine(filename, "{0}, {1}, {2}", name, p1name, p2name); // else // CsvWriter.WriteLine(filename, "{0}, {1}, {2}", name, p2name, p1name); // } // } //} private static void Main(string[] args) { TournamentKey = ConsoleInputProvider.GetTournamentKey(); Console.WriteLine(); var numStations = ConsoleInputProvider.GetNumberOfStations(); Console.WriteLine(); var stationsToExclude = ConsoleInputProvider.GetStationsToExclude(); _tournament = ChallongeApiWrapper.GetTournament(TournamentKey, CHALLONGE_USERNAME, CHALLONGE_APIKEY); // Console Settings Console.Title = string.Format("Challonge Match Viewer - {0}", _tournament.Name); Console.WindowWidth = 100; //Console.WindowHeight = 84; Console.CursorVisible = false; // Wait for the tournament to start Console.WriteLine(string.Format("Waiting for the '{0}' tournament to start...", _tournament.Name)); while (_tournament.OpenMatches.Count == 0) { System.Threading.Thread.Sleep(UPDATE_INTERVAL_SEC * 1000); _tournament = ChallongeApiWrapper.GetTournament(TournamentKey, CHALLONGE_USERNAME, CHALLONGE_APIKEY); } _tournament.StationManager.AddNewStations(numStations); foreach (var station in stationsToExclude) { _tournament.StationManager.RemoveStation(station); _tournament.StationManager.RemoveStation(string.Format("TV {0}", station)); } // Create a timer to ping Challonge for updates to bracket var timer = new Timer(UPDATE_INTERVAL_SEC * 1000); timer.Elapsed += UpdateTournamentMatches; timer.Enabled = true; var startTime = DateTime.Now; UpdateTournamentMatches(null, null); while (_tournament.OpenMatches.Count != 0) { OutputMatchesToConsole(_tournament, startTime); System.Threading.Thread.Sleep(1000); } }
static void Main() { var renderer = new ConsoleRenderer(); var inputProvider = new ConsoleInputProvider(); var chessEngine = new StandartTwoPlayerEngine(renderer, inputProvider); var gameInitializationStrategy = new StartInitializationStrategy(); chessEngine.Initialize(gameInitializationStrategy); chessEngine.Start(); Console.ReadLine(); }
public static void Start() { var renderer = new ConsoleRenderer(); renderer.RenderMainMenu(); var inputProvider = new ConsoleInputProvider(); var gameEngine = new StandardTwoPlayerEngine(renderer, inputProvider); var gameInitializationStrategy = new StandardStartGameInitializationStrategy(); gameEngine.Initialize(gameInitializationStrategy); gameEngine.Start(); }
public static void Start() { IRenderer renderer = new ConsoleRenderer(); //renderer.RenderMainMenu(); IInputProvider inputProvider = new ConsoleInputProvider(); IChessEngine engine = new StandadrdTwoPlayerEngine(renderer, inputProvider); IInitializeGameBoard initializeGameBoard = new StandadGameInitialization(); engine.Initialize(initializeGameBoard); engine.Start(); Console.ReadLine(); }
public static void Start() { IRenderer renderer = new ConsoleRenderer(); //renderer.RenderMainManu(); IInputProvider inputProvider = new ConsoleInputProvider(); IChessEngine chessEngine = new StandartTwoPlayerEngine(renderer, inputProvider); IGameInitializationStrategy gameInitializationStrategy = new StandartStartGameInitializationStrategy(); chessEngine.Initialize(gameInitializationStrategy); chessEngine.Start(); Console.ReadLine(); }
public static void Main() { IRenderer renderer = new ConsoleRenderer(); // renderer.RenderMainMenu(); IInputProvider inputProvider = new ConsoleInputProvider(); ILudoEngine ludoEngine = new StandardFourPlayerEngine(renderer, inputProvider); IGameInitializationStrategy gameInitializationStrategy = new StartGameInitializationStrategy(); ludoEngine.Initialize(gameInitializationStrategy); ludoEngine.Start(); Console.ReadLine(); }
private static void Main() { const int maxK = 30; const int i = 1; bool KRangeValidator(int value) => value >= i && value <= maxK; double Formula(double mValue, int iValue) => Sqrt(mValue * (1.0 / iValue)) * Sin(mValue * iValue); while (true) { var k = ConsoleInputProvider.GetIntegerInput("Enter the number k: ", KRangeValidator, GetValidationMessage); var m = ConsoleInputProvider.GetIntegerInput("Enter the number m: ", (val) => true, GetValidationMessage); var result = CalculateSum(i, k, m, Formula); WriteLine($"The result of the sum is {result}"); WriteLine("---------------------"); } }
public static void Start() { //Създавам кой ми принтира IRenderer renderer = new ConsoleRenderer(); //Извиквам мейн меню //renderer.RenderMenu(); //Създавам кой ще ми чете данните за шаха IInputProvider inputProvider = new ConsoleInputProvider(); //създавам енджина IEngine engine = new TwoPlayerEngine(renderer, inputProvider); //създавам как да инициализирам самата игра IGameInitialization gameInitialization = new StandartStartGameInitialization(); engine.Initialize(gameInitialization); engine.Start(); Console.ReadLine(); }
private void InitializeMap(BigInteger[] program, bool isAutomated) { ExploredPoints = new Dictionary <string, ShipSectionInfo>(); ExplorationTree = new Tree <string>(); UnexploredPoints = new HashSet <string>(); ItemLocations = new Dictionary <string, string>(); RobotPosition = "O"; RobotInventory = new HashSet <string>(); IsAutomated = isAutomated; ExplorationTree.Add(RobotPosition, null); UnexploredPoints.Add(RobotPosition); _inputProviderManual = new ConsoleInputProvider(); _inputProviderAutomated = new BufferedInputProvider(); IInputProvider inputProviderToUse = _inputProviderAutomated; if (!IsAutomated) { inputProviderToUse = _inputProviderManual; } _outputListener = new ListOutputListener(); _computer = new IntcodeComputer(inputProviderToUse, _outputListener); _computer.LoadProgram(program); }
public StandardTwoPlayerEngine(ConsoleRenderer renderer, ConsoleInputProvider inputProvider) { this.renderer = renderer; this.inputProvider = inputProvider; }
public void WhenArgIsNull__InputNotValidExceptionOccurs(string arg) { var sut = new ConsoleInputProvider(); Assert.Throws <InputNotValidException>(() => sut.Provide(arg)); }
public void WhenArgContainsLessThan3Line__InputNotValidExceptionOccurs(string arg) { var sut = new ConsoleInputProvider(); Assert.Throws <InputNotValidException>(() => sut.Provide(arg)); }
public void WhenArgDoesContainsEvenNumberOfLines__InputNotValidExceptionOccurs(string arg) { var sut = new ConsoleInputProvider(); Assert.Throws <InputNotValidException>(() => sut.Provide(arg)); }