Beispiel #1
0
 public TreeStateSuccessor(TreeState parent, TreeAction action, TreeState result, decimal valueOfResultingState)
 {
     ParentState = parent;
     ActionTaken = action;
     ResultingState = result;
     ValueOfResultingState = valueOfResultingState;
 }
Beispiel #2
0
        private void InitTree()
        {
            // Tier 1
            var root = new TreeState("A1");
            StartingState = root;
            _stateActions[root] = new List<TreeAction>();

            // Tier 2
            var A2 = new TreeState("A2");
            var B2 = new TreeState("B2");
            var C2 = new TreeState("C2");
            InitSuccessors(root, A2, B2, C2);

            // Tier 3
            var A3 = new TreeState("A3");
            var B3 = new TreeState("B3");
            var C3 = new TreeState("C3");
            InitSuccessors(A2, A3, B3, C3);

            var D3 = new TreeState("D3");
            var E3 = new TreeState("E3");
            var F3 = new TreeState("F3");
            InitSuccessors(B2, D3, E3, F3);

            var G3 = new TreeState("G3");
            var H3 = new TreeState("H3");
            var I3 = new TreeState("I3");
            InitSuccessors(C2, G3, H3, I3);

            // Tier 4
            var A4 = new TreeState("A4");
            var B4 = new TreeState("B4");
            var C4 = new TreeState("C4");
            InitSuccessors(A3, A4, B4, C4);

            var D4 = new TreeState("D4");
            var E4 = new TreeState("E4");
            var F4 = new TreeState("F4");
            InitSuccessors(B3, D4, E4, F4);

            var G4 = new TreeState("G4");
            var H4 = new TreeState("H4");
            var I4 = new TreeState("I4");
            InitSuccessors(C3, G4, H4, I4);

            var J4 = new TreeState("J4");
            var K4 = new TreeState("K4");
            var L4 = new TreeState("L4");
            InitSuccessors(D3, J4, K4, L4);

            var M4 = new TreeState("M4");
            var N4 = new TreeState("N4");
            var O4 = new TreeState("O4");
            InitSuccessors(E3, M4, N4, O4);

            var P4 = new TreeState("P4");
            var Q4 = new TreeState("Q4");
            var R4 = new TreeState("R4");
            InitSuccessors(F3, P4, Q4, R4);

            var S4 = new TreeState("S4");
            var T4 = new TreeState("T4");
            var U4 = new TreeState("U4");
            InitSuccessors(G3, S4, T4, U4);

            var V4 = new TreeState("V4");
            var W4 = new TreeState("W4");
            var X4 = new TreeState("X4");
            InitSuccessors(H3, V4, W4, X4);

            var Y4 = new TreeState("Y4");
            var Z4 = new TreeState("Z4");
            InitSuccessors(I3, null, Y4, Z4);
        }
Beispiel #3
0
 public IEnumerable<TreeAction> GetActionsToState(TreeState state)
 {
     return _stateActions[state];
 }
Beispiel #4
0
        private void InitSuccessors(TreeState parent, TreeState left, TreeState middle, TreeState right)
        {
            var successors = new List<TreeStateSuccessor>();
            if(left != null)
            {
                successors.Add(new TreeStateSuccessor(parent, TreeAction.Left, left, _values[left.Name]));
                _stateActions.Add(left, Enumerable.Concat(_stateActions[parent], new[] { TreeAction.Left }));
            }

            if (middle != null)
            {
                successors.Add(new TreeStateSuccessor(parent, TreeAction.Middle, middle, _values[middle.Name]));
                _stateActions.Add(middle, Enumerable.Concat(_stateActions[parent], new[] { TreeAction.Middle }));
            }

            if (right != null)
            {
                successors.Add(new TreeStateSuccessor(parent, TreeAction.Right, right, _values[right.Name]));
                _stateActions.Add(right, Enumerable.Concat(_stateActions[parent], new[] { TreeAction.Right }));
            }

            _stateSuccessors.Add(parent, successors);
        }