Esempio n. 1
0
 public PythonEngine(Game game)
 {
     _engine = Python.CreateEngine();
     var searchPaths = _engine.GetSearchPaths().ToList();
     var pythonPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Scripting", "PythonIncludes");
     searchPaths.Add(pythonPath);
     _engine.SetSearchPaths(searchPaths);
     _engine.Runtime.Globals.SetVariable("WumpusGame", game);
     _game = game;
 }
 public void Execute(Game game)
 {
     Console.WriteLine("Please enter path to script. Leave empty to cancel");
     var path = Console.ReadLine();
     if(string.IsNullOrEmpty(path))
     {
         return;
     }
     _engine.RunScript(path);
 }
        public void Execute(Game game)
        {
            game.Reinitialise();
            while (true)
            {
                Console.WriteLine(game.CurrentPerception);
                Console.WriteLine(Strings.EnterAction);

                var result = game.Step();
                Console.WriteLine(result.Message);
                Console.WriteLine();
                if (result.GameOver)
                    break;
            }
            Console.WriteLine(Strings.GameOver);
            Console.WriteLine("Score: {0}", game.CurrentState.ActiveAgent.Score);
            Console.ReadLine();
        }
Esempio n. 4
0
 private static Game GetGame()
 {
     IAgent agent = new SimpleAgent();
     var factories = new List<ICellFactory>();
     factories.Add(new EmptyCellFactory());
     factories.Add(new PitCellFactory());
     factories.Add(new BatCellFactory());
     var actions = new List<IAction>();
     actions.Add(new MoveAction());
     actions.Add(new FireAction());
     actions.Add(new TurnLeftAction());
     actions.Add(new TurnRightAction());
     actions.Add(new FindWumpusAction());
     actions.Add(new GrabAction());
     IMapGenerator generator = new RandomGenerator(factories);
     generator.AddMapGeneratedHook(new GoldAddHook());
     var game = new Game(generator, actions, agent);
     game.RegisterInitialisationHook(new GiveArrowHook());
     return game;
 }
Esempio n. 5
0
 public void Execute(Game game)
 {
     System.Environment.Exit(0);
 }
 public RunScriptMenuEntry(Game game)
 {
     _engine = new PythonEngine(game);
 }