def __repr__(self): if len(self.d.items()) == 0: return "Empty DDist" else: dictRepr = reduce(operator.add, [util.prettyString(k)+": "+\ util.prettyString(p)+", " \ for (k, p) in self.d.items()]) return "DDist(" + dictRepr[:-2] + ")"
def testGridDynamics(): gm = TestGridMap(0.15) print 'For TestGridMap(0.15):' r = GridDynamics(gm) print 'legalInputs', util.prettyString(r.legalInputs) ans1 = [r.getNextValues((1,1), a) for a in r.legalInputs] print 'starting from (1,1)', util.prettyString(ans1) ans2 = [r.getNextValues((2,3), a) for a in r.legalInputs] print 'starting from (2,3)', util.prettyString(ans2) ans3 = [r.getNextValues((3, 2), a) for a in r.legalInputs] print 'starting from (3,2)', util.prettyString(ans3) gm2 = TestGridMap(0.4) print 'For TestGridMap(0.4):' r2 = GridDynamics(gm2) ans4 = [r2.getNextValues((2,3), a) for a in r2.legalInputs] print 'starting from (2,3)', util.prettyString(ans4)
def testGridDynamics(): gm = TestGridMap(0.15) print "For TestGridMap(0.15):" r = GridDynamics(gm) print "legalInputs", util.prettyString(r.legalInputs) ans1 = [r.getNextValues((1, 1), a) for a in r.legalInputs] print "starting from (1,1)", util.prettyString(ans1) ans2 = [r.getNextValues((2, 3), a) for a in r.legalInputs] print "starting from (2,3)", util.prettyString(ans2) ans3 = [r.getNextValues((3, 2), a) for a in r.legalInputs] print "starting from (3,2)", util.prettyString(ans3) gm2 = TestGridMap(0.4) print "for TestGridMap(0.4):" r2 = GridDynamics(gm2) ans4 = [r2.getNextValues((2, 3), a) for a in r2.legalInputs] print "starting from (2,3)", util.prettyString(ans4)