AIXI.CTWContextTreeFast.revert_tree C# (CSharp) Method

revert_tree() public method

public revert_tree ( int symbolCount = 1 ) : void
symbolCount int
return void
        public void revert_tree(int symbolCount = 1)
        {
            for (int i = 0; i < symbolCount; i++)
            {
                if (this.History.Count == 0)
                {
                    return;
                }
                int symbol = this.History.Last();
                this.History.RemoveAt(this.History.Count - 1);

                if (this.History.Count >= this.Depth)
                {
                    this.update_context();
                    for (int j = this.Depth - 1; j >= 0; j--)
                    {
                        int nodeI = this.Context[j];
                        this.revert_node(nodeI, symbol);
                    }
                }
            }
        }

Usage Example

Example #1
0
        public void TestMethod1()
        {
            //here we make instances of CTWContextTreeFast and CTWContextTree and test if they behave in same way
            var ctf = new CTWContextTreeFast(9);
            var ct = new CTWContextTree(9);

            int[] input = { 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1 };
            ct.update_tree(input);
            ctf.update_tree(input);
            ct.revert_tree(4);
            ctf.revert_tree(4);
            int[] input2 = { 0, 0, 1 };
            ct.update_tree(input2);
            ctf.update_tree(input2);

            Assert.IsTrue(ctf.compare(ct));
        }