Skip to content
Snippets Groups Projects
Commit c269c0a0 authored by Franck Dary's avatar Franck Dary
Browse files

Corrected bug that made BACK transitions unusable

parent 33fa0a6b
No related branches found
No related tags found
No related merge requests found
......@@ -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)) :
......
......@@ -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
################################################################################
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment