Example #1
0
        private IEngine ConvertEngineKindToEngine(EngineKind engineKind, PieceColor color)
        {
            switch (engineKind)
            {
            case EngineKind.Human:
                return(new HumanEngine(color));

            case EngineKind.Random:
                if (color == PieceColor.White)
                {
                    return(new RandomEngine(color, viewModel.WhitePlayerRandomEngineUseRandomSeed ? null : (int?)viewModel.WhitePlayerRandomEngineSeedValue));
                }
                else
                {
                    return(new RandomEngine(color, viewModel.BlackPlayerRandomEngineUseRandomSeed ? null : (int?)viewModel.BlackPlayerRandomEngineSeedValue));
                }

            case EngineKind.Cuda:
                if (color == PieceColor.White)
                {
                    return(new CudaEngine(color, viewModel.WhitePlayerCudaEngineMctsIteration, viewModel.WhitePlayerCudaEngineGridSize, viewModel.WhitePlayerCudaEngineBlockSize));
                }
                else
                {
                    return(new CudaEngine(color, viewModel.BlackPlayerCudaEngineMctsIteration, viewModel.BlackPlayerCudaEngineGridSize, viewModel.BlackPlayerCudaEngineBlockSize));
                }

            case EngineKind.AlphaBeta:
                if (color == PieceColor.White)
                {
                    return(new AlphaBetaEngine(color, viewModel.WhitePlayerAlphaBetaEngineTreeDepth));
                }
                else
                {
                    return(new AlphaBetaEngine(color, viewModel.BlackPlayerAlphaBetaEngineTreeDepth));
                }

            case EngineKind.Mcts:
                if (color == PieceColor.White)
                {
                    return(new MctsEngine(color, viewModel.WhitePlayerMctsEngineRandomSeed, viewModel.WhitePlayerMctsEngineUctParameter, viewModel.WhitePlayerMctsEngineNumberOfIterations));
                }
                else
                {
                    return(new MctsEngine(color, viewModel.BlackPlayerMctsEngineRandomSeed, viewModel.BlackPlayerMctsEngineUctParameter, viewModel.BlackPlayerMctsEngineNumberOfIterations));
                }

            default:
                throw new ArgumentException("Nierozpoznany typ silnika");
            }
        }
Example #2
0
 /// <summary>Initializes a new instance of the <see cref="LegacyExecutionEngine"/> class with an initial module</summary>
 /// <param name="kind"><see cref="EngineKind"/> for the engine to create</param>
 /// <param name="optLevel">Optimization level for the engine</param>
 /// <remarks>This does not create the underlying engine, instead that is deferred until the first module is added</remarks>
 public LegacyExecutionEngine(EngineKind kind, CodeGenOpt optLevel)
 {
     Kind         = kind;
     Optimization = optLevel;
     OwnedModules = new Dictionary <int, LLVMModuleRef>( );
 }
Example #3
0
 /// <summary>Initializes a new instance of the <see cref="LegacyExecutionEngine"/> class with an initial module</summary>
 /// <param name="kind"><see cref="EngineKind"/> for the engine to create</param>
 /// <remarks>This does not create the underlying engine, instead that is deferred until the first module is added</remarks>
 public LegacyExecutionEngine(EngineKind kind)
     : this(kind, CodeGenOpt.Default)
 {
 }