Ejemplo n.º 1
0
    def getState(self, data):
        data = struct.unpack("!i", data)[0]
        # unpack the socket data to test if it is terminated
        if int(data) != self._iter:
            print "c++ iter: " + data + " python iter: " + str(self._iter)
            sys.exit(0)

        # parse the state data which is outputed from compiler
        state, reward_map, _ = parse.getstate("state.txt", self._iter,
                                              self._maxlength,
                                              self._actionsize, self._regs2idx,
                                              self._tofile)
        return state, reward_map
Ejemplo n.º 2
0
def physicaldownonoccupy():
    f = open('workfile.txt', 'w')
    start = 2
    end = 3
    firstline = "3333&" + str(start) + "&" + str(end) + "\n"
    f.writelines(firstline)
    f.writelines("reward\n")
    phys = [2, 3]
    physline = genphys(phys)
    f.write(physline)
    vrs = [0]
    f.writelines("vreward\n")
    virtline = genphys(vrs)
    f.writelines(virtline)
    occ = [2, 3]
    for x in range(len(occ)):
        f.write(genoccupy(occ[x], 1, 2))
    f.close()
    reg2idx = {"0": 0, "1": 1, "2": 2, "3": 3, "4": 4}
    a, y, h = parse.getstate("workfile.txt", 0, 5, 5, reg2idx)
    return h
Ejemplo n.º 3
0
def teststate():
    g = {
        '39': 0,
        '38': 1,
        '37': 2,
        '43': 3,
        '40': 4,
        '115': 5,
        '114': 6,
        '117': 7,
        '116': 8,
        '111': 9,
        '35': 13,
        '113': 10,
        '112': 11,
        '118': 12,
        '229': 14,
        '237': 15,
        '245': 16
    }
    res, _ = parse.getstate("teststate.txt", 1, 300, 17, g)
    print res