Package tulip :: Package interfaces :: Module gr1c :: Class GR1CSession
[frames] | no frames]

Class GR1CSession

Manage interactive session with gr1c.

Given lists of environment and system variable names determine the order of values in state vectors for communication with the gr1c process. Eventually there may be code to infer this directly from the spec file.

**gr1c is assumed not to use GNU Readline.**

Please compile it that way if you are using this class. (Otherwise, GNU Readline will echo commands and make interaction with gr1c more difficult.)

The argument `prompt` is the string printed by gr1c to indicate it is ready for the next command. The default value is a good guess.

Unless otherwise indicated, command methods return True on success, False if error.

Instance Methods
 
__init__(self, spec_filename, sys_vars, env_vars=[], prompt='>>> ')
 
iswinning(self, state)
Return True if given state is in winning set, False otherwise.
 
getindex(self, state, goal_mode)
 
env_next(self, state)
Return list of possible next environment moves, given current state.
 
sys_nextfeas(self, state, env_move, goal_mode)
Return list of next system moves consistent with some strategy.
 
sys_nexta(self, state, env_move)
Return list of possible next system moves, whether or not winning.
 
getvars(self)
Return string of environment and system variable names in order.
 
numgoals(self)
 
reset(self, spec_filename=None)
Quit and start anew, reading spec from file with given name.
 
close(self)
End session, and kill gr1c child process.
Method Details

iswinning(self, state)

 

Return True if given state is in winning set, False otherwise.

state should be a dictionary with keys of variable names (strings) and values of the value taken by that variable in this state, e.g., as in nodes of the Automaton class.

env_next(self, state)

 

Return list of possible next environment moves, given current state.

Format of given state is same as for iswinning method.

sys_nextfeas(self, state, env_move, goal_mode)

 

Return list of next system moves consistent with some strategy.

Format of given state and env_move is same as for iswinning method.

sys_nexta(self, state, env_move)

 

Return list of possible next system moves, whether or not winning.

Format of given state and env_move is same as for iswinning method.

getvars(self)

 

Return string of environment and system variable names in order.

Indices are indicated in parens.

reset(self, spec_filename=None)

 

Quit and start anew, reading spec from file with given name.

If no filename given, then use previous one.