diff --git a/Config.py b/Config.py index eee07f201c84228600ddb484ef48ddf913d110db..051e6bcb224fe4124890bc5ca26f9d7931c2d430 100644 --- a/Config.py +++ b/Config.py @@ -87,7 +87,7 @@ class Config : print("state :", self.state, file=output) print("stack :",[self.getAsFeature(ind, "ID") for ind in self.stack], file=output) print("history :",[str(trans) for trans in self.history[-10:]], file=output) - print("historyPop :",[(str(c[0]),"dat:"+str(c[1]),"mvt:"+str(c[2]),"reward:"+str(c[3])) for c in self.historyPop[-10:]], file=output) + print("historyPop :",[(str(c[0]),"dat:"+str(c[1]),"mvt:"+str(c[2]),"reward:"+str(c[3]),"state:"+str(c[4])) for c in self.historyPop[-10:]], file=output) toPrint = [] for lineIndex in range(self.wordIndex-left, self.wordIndex+right) : if lineIndex not in range(len(self.lines)) : diff --git a/Transition.py b/Transition.py index 2c6eadf5941ed449956b564dabbcabfbe5e44e06..e2cba778c2292a720adf630030e8be47e27aad3a 100644 --- a/Transition.py +++ b/Transition.py @@ -46,7 +46,7 @@ class Transition : exit(1) config.history.append(self) if "BACK" not in self.name : - config.historyPop.append((self,data,None)) + config.historyPop.append((self,data,None, None, config.state)) def appliable(self, config) : if self.name == "RIGHT" : @@ -173,7 +173,7 @@ def scoreOracleReduce(config, ml) : ################################################################################ def applyBack(config, strategy, size) : for i in range(size) : - trans, data, movement, _ = config.historyPop.pop() + trans, data, movement, _, state = config.historyPop.pop() config.moveWordIndex(-movement) if trans.name == "RIGHT" : applyBackRight(config, data, trans.size) @@ -188,6 +188,7 @@ def applyBack(config, strategy, size) : else : print("ERROR : trying to apply BACK to '%s'"%trans.name, file=sys.stderr) exit(1) + config.state = state ################################################################################ ################################################################################ @@ -290,8 +291,9 @@ def applyTransition(strat, config, transition, reward) : moved = config.moveWordIndex(movement) movement = movement if moved else 0 if len(config.historyPop) > 0 and "BACK" not in transition.name : - config.historyPop[-1] = (config.historyPop[-1][0], config.historyPop[-1][1], movement, reward) - config.state = newState + config.historyPop[-1] = (config.historyPop[-1][0], config.historyPop[-1][1], movement, reward, config.historyPop[-1][4]) + if "BACK" not in transition.name : + config.state = newState return moved ################################################################################