예제 #1
0
파일: Program.cs 프로젝트: W3SS/cardstock
        void SingleGame(string game)
        {
            var exp = new Experiment();

            exp.fileName = game;
            // System.Console.WriteLine(g.Substring(6, g.Length - 4));
            exp.numGames  = 100;
            exp.numEpochs = 10;

            exp.logging    = false;
            exp.evaluating = false;
            exp.type       = GameType.RndandAI;

            var codeGen = new ParseEngine(exp);

            codeGen.setWorld(new World());
            codeGen.Loader();
            codeGen.Experimenter();
            System.Console.ReadLine();
        }
예제 #2
0
파일: Scorer.cs 프로젝트: W3SS/cardstock
        // define heuristics here
        public List <double> Score()
        {
            //var path = Path.Combine("Gamepool", "Scoring" + name + ".txt");
            gameWorld = new World();
            List <double> empty = new List <double>();

            empty.Add(0.0);
            for (int i = 0; i < exps.Count; i++)
            {
                Debug.WriteLine("Experiment " + i);
                engine = new ParseEngine(exps[i]);
                engine.setWorld(gameWorld);
                var tup = engine.Loader();



                if (!tup.Item1)
                {
                    Debug.WriteLine("not shuffling"); return(empty);
                }
                if (!tup.Item2)
                {
                    Debug.WriteLine("no choice"); return(empty);
                }

                var compiling = engine.Experimenter();
                if (!compiling)
                {
                    Debug.WriteLine("not compiling"); return(empty);
                }
            }

            //gameWorld.EvalOver();
            Debug.WriteLine("passed reasonable");
            List <double> total       = new List <double>();
            var           cleanoutput = "";
            StreamWriter  heurfile    = new StreamWriter(exps[0].fileName + "-heuristics.txt");

            foreach (Heuristic h in hs)
            {
                var score  = h.Eval(gameWorld);
                var output = h.ToString().Substring(32) + "\t" + (score / h.Weight()) +
                             "\t" + h.Weight() + "\t" + score;
                var split     = h.ToString().Split('.');
                var heuristic = split[split.Length - 1];
                cleanoutput += heuristic + ": " + score + "\n";
                text        += "    " + output;


                Console.WriteLine(output);
                heurfile.WriteLine(output);
                total.Add(score);
            }
            heurfile.Close();

            /*
             *          if (!File.Exists(path))
             *          {
             *                  File.WriteAllText(path, cleanoutput + "\n\n----\n\n\t");
             *          }
             *          else
             *          {
             *                  using (StreamWriter file = new StreamWriter(path, true))
             *                  {
             *                          file.WriteLine(cleanoutput + "\n\n----\n\n");
             *                  }
             *          }*/

            return(total);
        }