When is the Redo-port called with new variables in Trace/0 and when not?

后端 未结 2 1922
忘了有多久
忘了有多久 2020-12-22 04:17

During my implementation of the Adventure game in Prolog I was wondering when the redo-port is called with new variables during backtracking and when it is called with the s

2条回答
  •  无人及你
    2020-12-22 04:56

    This is just a comment posted as a answer because it has a picture.

    If you use the graphical debugger you can see when choice points are created.

    ?- gtrace.
    true.
    
    [trace] ?- (location(X,Y),door(kitchen,Y)).
    

    In the following image of the debugger I highlighted the choice point with a green rectangle.

    To exit out of trace mode in top-level enter nodebug.

    [trace] ?- nodebug.
    true.
    
    ?- 
    

    Note: It is the choice points that lead to using the redo port.
    Note: Another way to debug prolog is via use of failure slice. Also read questions tagged with failure slice

提交回复
热议问题