@@ -0,0 +1,3026 @@
+#########################################################################%0A##%0A##file: AgentJBaseClass.py%0A##Author: Ken Zyma%0A##Project: Blocks World and Agency%0A##%0A##This file contains utility functions for AgentJ Class%0A##Edited by: Erin Fowler Nov 26, 2013%0A##Changes made:  Below functions moved from AgentJBaseClass and put in new class%0A###########################################################################%0A%0A#******************************convertNtoStr()**************************%0A#Actions:       takes n and converts to string%0A#Return:%09returns dictionary%0A#********************************************************************%0Adef convertNtoStr(n):%0A        return %7B%0A                '1': %22one%22,%0A                '2': %22two%22,%0A                '3': %22three%22,%0A                '4': %22four%22,%0A                '5': %22five%22,%0A                '6': %22six%22,%0A                '7': %22seven%22,%0A                '8': %22eight%22,%0A                '9': %22nine%22,%0A                '0': %22zero%22,%0A                '-1': %22table%22,%0A                %7D.get(n,%22none%22)%0A%0A#*********************************reconstructCfg()**************************%0A#Actions:       re-build the BW cfg from it's id%0A#Return:%09configuration%0A#********************************************************************%0Adef reconstructCfg(nodeID):%0A        cfg=%5B%5D%0A        i=1%0A        while i%3Clen(nodeID):%0A                current=nodeID%5B(i-1):i%5D%0A                temp=%5B%5D%0A                while current!='a':%0A                        if (current != '0'):%0A                                temp.append(int(current))%0A                        i = i+1%0A                        current=nodeID%5B(i-1):i%5D%0A                cfg.append(temp)%0A                i = i+1%0A        return cfg%0A%0A#*********************************unstranslateMv()**************************%0A#Actions:  takes a split move, looks for it in node and returns its idx%0A#Return:   returns an int%0A#********************************************************************%0Adef untranslateMv(a,node):%0A        #take care of special case--table%0A        if (a==%22-1%22):%0A                return -1%0A        #all other cases%0A        for i in node:%0A                if int(a) in i:%0A                        return node.index(i)%0A                %0A#*********************************numbize()**************************%0A#Actions:       generate a number, is called in genCfgId()%0A#Return:%09returns a number%0A#Changes:       None%0A#********************************************************************%0Adef numbize(nList):%0A        num=0%0A        for n in nList:%0A                num*=100%0A                num+=n%0A        return num%0A%0A#***********************genCfgId()*****************************************%0A#Actions: generate configuration ID in the form of a string%0A#         stacks separated by a's and blocks separated by 0's%0A#Returns: string configuration ID%0A#**************************************************************************%0Adef genCfgId(cfg):%0A        nL=map(numbize,cfg)%0A        nL.sort()%0A        cfId=''%0A        for n in nL:%0A                cfId+=str(n)+'a'%0A        return cfId%0A

Create AgtJUtilityClass.py