Ejemplo n.º 1
0
        public ParetoTreeNode(Playfield state, ParetoTreeNode parent, int childIndex, RandomRoller roller,
                              ParetoTreePolicy treePolicy, Random rnd, ParetoMCTSPlayer a_player)
        {
            this.m_player = a_player;
            this.state    = state;
            this.parent   = parent;
            this.m_rnd    = rnd;
            //children = new ParetoTreeNode[ParetoMCTSParameters.NUM_ACTIONS];
            this.roller      = roller;
            this.mTreePolicy = treePolicy;
            pa = new ParetoArchive();
            this.childIndex       = childIndex;
            this.m_prunedChildren = new bool[ParetoMCTSParameters.NUM_ACTIONS];
            this.m_numIters       = 0;
            //this.m_pi = pi;

            isTerminal           = false;
            isExpanded           = false;
            isExhausted          = false;
            numExpandedChildren  = 0;
            numExhaustedChildren = 0;
            nodeNum = GameManager.Instance.nodeCount;
            GameManager.Instance.nodeCount++;

            totValue = new double[ParetoMCTSParameters.NUM_TARGETS];
        }
Ejemplo n.º 2
0
 public SimpleTreeNode(Playfield state, RandomRoller RandomRoller, ParetoTreePolicy ParetoTreePolicy, ParetoMCTSPlayer a_ParetoMCTSPlayer)
 {
     this(state, null, RandomRoller, ParetoTreePolicy, a_ParetoMCTSPlayer);
     this.RandomRoller     = RandomRoller;
     this.paretoTreePolicy = ParetoTreePolicy;
     pa = new ParetoArchive();
 }
Ejemplo n.º 3
0
 public ParetoTreeChanceNode(Playfield state, ParetoTreeNode parent, int childIndex, RandomRoller roller,
                             ParetoTreePolicy treePolicy, Random rnd, ParetoMCTSPlayer a_player, Action chanceAction, int childrenSize) :
     this(state, parent, childIndex, roller,
          treePolicy, rnd, a_player, chanceAction)
 {
     this.children = new List <ParetoTreeNode>(childrenSize);
 }
Ejemplo n.º 4
0
 public TreeNode(Playfield state, TreeNode parent, RandomRoller RandomRoller, ParetoTreePolicy ParetoTreePolicy, ParetoMCTSPlayer a_ParetoMCTSPlayer)
 {
     this.m_ParetoMCTSPlayer = a_ParetoMCTSPlayer;
     this.parent             = parent;
     totValue              = new double[ParetoMCTSParameters.NUM_TARGETS];
     this.RandomRoller     = RandomRoller;
     this.paretoTreePolicy = ParetoTreePolicy;
     // System.out.println("Made a TreeNode of depth " + depth() + ", arity " + children.Length);
 }
Ejemplo n.º 5
0
        //public ParetoMCTSPlayer(ParetoTreePolicy a_treePolicy, HeuristicMO a_h, Random a_rnd, Game a_game, PlayoutInfo pInfo)
        //{
        //    m_playoutInfo = pInfo;
        //    //m_heightMap = new int[a_game.getMap().getMapWidth()][a_game.getMap().getMapHeight()];
        //    m_heuristic = a_h;
        //    m_heuristic.setPlayoutInfo(m_playoutInfo);
        //    m_treePolicy = a_treePolicy;
        //    this.m_rnd = a_rnd;
        //    this.m_targetWeights = ParetoMCTSParameters.targetWeights;
        //    m_globalPA = new ParetoArchive();
        //    m_randomRoller = new RandomRoller(RandomRoller.RANDOM_ROLLOUT, this.m_rnd, ParetoMCTSParameters.NUM_ACTIONS);
        //    m_root = new ParetoTreeNode(null, m_randomRoller, m_treePolicy, m_rnd, this, m_playoutInfo);
        //    this.m_numCalls = 0;
        //    this.m_numIters = 0;
        //}

        public ParetoMCTSPlayer(ParetoTreePolicy a_treePolicy, Random a_rnd, Playfield a_game, HeuristicType _ht)
        {
            //m_playoutInfo = pInfo;
            ////m_heightMap = new int[a_game.getMap().getMapWidth()][a_game.getMap().getMapHeight()];
            //m_heuristic = a_h;
            //m_heuristic.setPlayoutInfo(m_playoutInfo);
            m_treePolicy         = a_treePolicy;
            this.m_rnd           = a_rnd;
            this.m_targetWeights = ParetoMCTSParameters.targetWeights;
            m_globalPA           = new ParetoArchive();
            m_randomRoller       = new RandomRoller(RandomRoller.RANDOM_ROLLOUT, this.m_rnd, ParetoMCTSParameters.NUM_ACTIONS);
            //m_root = new ParetoTreeNode(null, m_randomRoller, m_treePolicy, m_rnd, this, m_playoutInfo);
            m_root          = new ParetoTreeNode(a_game, null, -1, m_randomRoller, m_treePolicy, m_rnd, this);
            this.m_numCalls = 0;
            this.m_numIters = 0;

            m_runList     = new List <ParetoTreeNode>();
            heuristicType = _ht;

            ////bounds[0][0] = -Math.Sqrt(8) * 8 * 8;
            //bounds[0][0] = 0;
            //bounds[0][1] = Math.Sqrt(8) * 8 * 8 * 2;
            ////bounds[1][0] = -Math.Sqrt(8) * 8 * 8;
            //bounds[1][0] = 0;
            //bounds[1][1] = Math.Sqrt(8) * 8 * 8;
            ////bounds[2][0] = -10 * 10;
            ////bounds[2][1] = 10 * 10;
            ////bounds[2][0] = -Math.Sqrt(8) * 8 * 10;
            //bounds[2][0] = 0;
            //bounds[2][1] = Math.Sqrt(8) * 8 * 10 * 2;

            switch (this.heuristicType)
            {
            case HeuristicType.Boardvalue:
                bounds    = new double[3][];
                bounds[0] = new double[2];
                bounds[1] = new double[2];
                bounds[2] = new double[2];
                //bounds[0][0] = -Math.Sqrt(8) * 8 * 8;
                bounds[0][0] = 0;
                bounds[0][1] = 1f;
                //bounds[1][0] = -Math.Sqrt(8) * 8 * 8;
                bounds[1][0] = 0;
                bounds[1][1] = 1f;
                //bounds[2][0] = -10 * 10;
                //bounds[2][1] = 10 * 10;
                //bounds[2][0] = -Math.Sqrt(8) * 8 * 10;
                bounds[2][0] = 0;
                bounds[2][1] = 1f;
                break;

            case HeuristicType.LethalCheck:
                bounds       = new double[1][];
                bounds[0]    = new double[2];
                bounds[0][0] = 0;
                bounds[0][1] = 1f;
                break;

            case HeuristicType.DrawCard:
                bounds           = new double[2][];
                bounds[0]        = new double[2];
                bounds[1]        = new double[2];
                bounds[0][0]     = 0;
                bounds[0][1]     = 1f;
                bounds[1][0]     = 0;
                bounds[1][1]     = 1f;
                initNewCardCount = m_root.state.moveTrigger.newHandcardList.Count;
                break;
            }
        }