示例#1
0
    public void Mutate(BossDecisionNode node)
    {
        if (UnityEngine.Random.Range(0, 1.00f) <= MUTATIONCHANCE)
        {
            List <BossDecisionNode> matches = BossNodeData.FindMatches(node.left, node.right);

            node.heuristic = matches[UnityEngine.Random.Range(0, matches.Count)].heuristic;
        }

        if (node.left.heuristic != BossHeuristic.Heuristic.NONE)
        {
            Mutate(node.left);
        }
        else
        {
            if (UnityEngine.Random.Range(0, 1.00f) <= MUTATIONCHANCE)
            {
                node.left = actions[UnityEngine.Random.Range(0, actions.Count)];
            }
        }

        if (node.right.heuristic != BossHeuristic.Heuristic.NONE)
        {
            Mutate(node.right);
        }
        else
        {
            if (UnityEngine.Random.Range(0, 1.00f) <= MUTATIONCHANCE)
            {
                node.right = actions[UnityEngine.Random.Range(0, actions.Count)];
            }
        }
    }
示例#2
0
 public laser(Boss m_boss) : base(m_boss)
 {
     nodeData = new BossNodeData(new List <BossNodeType>(new BossNodeType[] { BossNodeType.ATTACK, BossNodeType.MEDIUMRANGE }), null, null);
 }
 public BossDecisionNode(BossHeuristic.Heuristic m_heursitic, BossNodeData m_nodeData)
 {
     heuristic = m_heursitic;
     nodeData  = m_nodeData;
 }
示例#4
0
 public aim(Boss m_boss) : base(m_boss)
 {
     nodeData = new BossNodeData(new List <BossNodeType>(new BossNodeType[] { BossNodeType.ATTACK }), null, null);
 }
示例#5
0
 public RequiredAction2(Boss m_boss) : base(m_boss)
 {
     nodeData = new BossNodeData(new List <BossNodeType>(new BossNodeType[] { BossNodeType.ATTACK, BossNodeType.RETREAT }), null, null);
 }
示例#6
0
 public movingtriangle(Boss m_boss) : base(m_boss)
 {
     nodeData = new BossNodeData(new List <BossNodeType>(new BossNodeType[] { BossNodeType.ATTACK, BossNodeType.LONGRANGE }), null, null);
 }
示例#7
0
    public void GenerateTree(int m_points)
    {
        if (m_points < 2)
        {
            m_points = 2;
        }

        List <BossAction>       actionSpace         = new List <BossAction>();
        List <BossAction>       possibleActionSpace = Boss.Current().actions;
        List <BossAction>       requiredActionSpace = Boss.Current().requiredActions;
        List <BossDecisionNode> layerNodes          = new List <BossDecisionNode>();
        List <BossDecisionNode> newLayerNodes       = new List <BossDecisionNode>();

        for (int i = 0; i < m_points; i++)
        {
            actionSpace.Add(possibleActionSpace[Random.Range(0, possibleActionSpace.Count)]);
        }

        foreach (BossAction A in requiredActionSpace)
        {
            actionSpace.Add(A);
        }

        foreach (BossAction action in actionSpace)
        {
            layerNodes.Add(action);
        }

        do
        {
            newLayerNodes = new List <BossDecisionNode>();

            if (layerNodes.Count % 2 == 0)
            {
                for (int i = 0; i < layerNodes.Count - 1; i += 2)
                {
                    List <BossDecisionNode> nodeSpace = BossNodeData.FindMatches(layerNodes[i], layerNodes[i + 1]);
                    BossDecisionNode        node      = nodeSpace[Random.Range(0, nodeSpace.Count)];
                    node.left  = layerNodes[i];
                    node.right = layerNodes[i + 1];
                    newLayerNodes.Add(node);
                }

                layerNodes = newLayerNodes;
            }
            else
            {
                for (int i = 0; i < layerNodes.Count - 2; i += 2)
                {
                    List <BossDecisionNode> nodeSpace = BossNodeData.FindMatches(layerNodes[i], layerNodes[i + 1]);
                    BossDecisionNode        node      = nodeSpace[Random.Range(0, nodeSpace.Count)];
                    node.left  = layerNodes[i];
                    node.right = layerNodes[i + 1];
                    newLayerNodes.Add(node);
                }

                newLayerNodes.Add(layerNodes[layerNodes.Count - 1]);
                layerNodes = newLayerNodes;
            }
        } while (layerNodes.Count > 1);

        rootNode = layerNodes[0];
    }
示例#8
0
 public bulletline(Boss m_boss) : base(m_boss)
 {
     nodeData = new BossNodeData(new List <BossNodeType>(new BossNodeType[] { BossNodeType.ATTACK, BossNodeType.LONGRANGE }), null, null);
 }
示例#9
0
 public ReqiredBossAction1(Boss m_boss) : base(m_boss)
 {
     nodeData = new BossNodeData(new List <BossNodeType>(new BossNodeType[] { BossNodeType.ATTACK, BossNodeType.CLOSERANGE }), null, null);
 }