Exemple #1
0
        public GnuGoBot(ISimpleInjectorWrapper simpleInjector, string binaryPath, string botInstanceName)
        {
            if (simpleInjector == null)
            {
                throw new ArgumentNullException(nameof(simpleInjector));
            }

            if (binaryPath == null)
            {
                throw new ArgumentNullException(nameof(binaryPath));
            }

            if (botInstanceName == null)
            {
                throw new ArgumentNullException(nameof(botInstanceName));
            }

            var fileService = simpleInjector.GetInstance <IFileService>();
            var confService = simpleInjector.GetInstance <IConfigurationService>();
            var path        = fileService.PathCombine(confService.CurrentDirectoryPath, binaryPath);

            if (!fileService.FileExists(path))
            {
                throw new FileNotFoundException("Bot binary not found,", path);
            }

            this.process = simpleInjector.GetInstance <IProcessManagerFactory>().Create(path, "--mode gtp");
            this.process.DataReceived = this.OnDataReceived;
            this.Name          = botInstanceName;
            this.MovePerformed = delegate { }; // To reduce null reference checking
        }
Exemple #2
0
        public Adjudicator(ISimpleInjectorWrapper simpleInjector, Duel duel)
        {
            if (simpleInjector == null)
            {
                throw new ArgumentNullException(nameof(simpleInjector));
            }

            if (duel == null)
            {
                throw new ArgumentNullException(nameof(duel));
            }

            var fileService = simpleInjector.GetInstance <IFileService>();

            this.configurationService = simpleInjector.GetInstance <IConfigurationService>();
            var binaryPath = this.configurationService.GetAdjudicatorBinaryPath();

            if (!fileService.FileExists(binaryPath))
            {
                throw new FileNotFoundException("Adjudicator binary not found,", binaryPath);
            }

            this.process = simpleInjector.GetInstance <IProcessManagerFactory>().Create(binaryPath, "--mode gtp");
            this.logger  = simpleInjector.GetInstance <ILogger>();
            this.process.DataReceived = this.OnDataReceived;
            this.duel = duel;
            if (this.duel.BoardSize != 19)
            {
                this.process.WriteData("boardsize {0}", this.duel.BoardSize);
            }

            this.WhiteMoveValidated = delegate { };
            this.BlackMoveValidated = delegate { };
            this.Resigned           = delegate { };
        }
Exemple #3
0
        public TournamentInitializer(ISimpleInjectorWrapper simpleInjector, string name, string gamesCount)
        {
            if (simpleInjector == null)
            {
                throw new ArgumentNullException(nameof(simpleInjector));
            }

            this.configurationReader = simpleInjector.GetInstance <IConfigurationReader>();
            this.botFactory          = simpleInjector.GetInstance <IGoBotFactory>();
            this.simpleInjector      = simpleInjector;
            this.Name       = name;
            this.gamesCount = gamesCount;
        }