AIXI.CTWContextTreeFast.compare C# (CSharp) Method

compare() public method

public compare ( CTWContextTree other ) : bool
other CTWContextTree
return bool
        public bool compare(CTWContextTree other)
        {
            if (this.TreeSize != other.TreeSize ||
                this.Depth != other.Depth)
            {
                return false;
            }

            for (int i = 0; i < this.Context.Count; i++) {
                if (!this.SameNode(this.Context[i], other.Context[i])) {
                    return false;
                }
            }
            for (int i=0; i<this.History.Count; i++){
                if (this.History[i] != other.History[i]){
                    return false;
                }
            }

            return this.compare(this.RootI, other.Root);
        }

Same methods

CTWContextTreeFast::compare ( int meI, CTWContextTreeNode he ) : bool

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));
        }