AIXI.CTWContextTree.update_context C# (CSharp) Method

update_context() public method

public update_context ( ) : void
return void
        public void update_context()
        {
            Debug.Assert(this.History.Count >= this.Depth, "history is shorter than depth in update_context");
            this.Context = new List<CTWContextTreeNode>();
            this.Context.Add(this.Root);
            CTWContextTreeNode node = this.Root;
            int updateDepth = 1;
            IEnumerable<int> historyIe = History;
            foreach (int symbol in historyIe.Reverse())
            {
                if (node.Children.ContainsKey(symbol))
                {
                    node = node.Children[symbol];
                }
                else
                {
                    CTWContextTreeNode newNode = new CTWContextTreeNode(this);
                    node.Children[symbol] = newNode;
                    this.TreeSize += 1;
                    node = newNode;
                }
                this.Context.Add(node);
                updateDepth += 1;
                if (updateDepth > this.Depth)
                {
                    break;
                }
            }
        }