📄 waltz.drl
字号:
then $edge1.setLabel( Edge.B ); $edge2.setLabel( Edge.B ); modify( $edge1 ); modify( $edge2 );endrule "label fork 1" when Stage( value == Stage.LABELING ) Junction( type == Junction.FORK, $bp:basePoint ) Edge( p1 == $bp, $p1:p2, label == Edge.PLUS ) $edge1: Edge( p1 == $bp, $p2:p2 != $p1, label == Edge.NIL ) $edge2: Edge( p1 == $bp, $p3:p2 != $p1, p2 != $p2 ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );endrule "label fork 2" when Stage( value == Stage.LABELING ) Junction( type == Junction.FORK, $bp:basePoint ) Edge( p1 == $bp, $p1:p2, label == Edge.B ) Edge( p1 == $bp, $p2:p2 != $p1, label == Edge.MINUS ) $edge: Edge( p1 == $bp, $p3:p2 != $p1, p2 != $p2, label == Edge.NIL ) then $edge.setLabel( Edge.B ); modify( $edge );endrule "label fork 3" when Stage( value == Stage.LABELING ) Junction( type == Junction.FORK, $bp:basePoint ) Edge( p1 == $bp, $p1:p2, label == Edge.B ) Edge( p1 == $bp, $p2:p2 != $p1, label == Edge.B ) $edge: Edge( p1 == $bp, $p3:p2 != $p1, p2 != $p2, label == Edge.NIL ) then $edge.setLabel( Edge.MINUS ); modify( $edge );endrule "label fork 4" when Stage( value == Stage.LABELING ) Junction( type == Junction.FORK, $bp:basePoint ) Edge( p1 == $bp, $p1:p2, label == Edge.MINUS ) Edge( p1 == $bp, $p2:p2 != $p1, label == Edge.MINUS ) $edge: Edge( p1 == $bp, $p3:p2 != $p1, p2 != $p2, label == Edge.NIL ) then $edge.setLabel( Edge.MINUS ); modify( $edge );end rule "label arrow 1A" salience 5 when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p1, $label:label -> ( $label.equals(Edge.B) || $label.equals(Edge.MINUS) ) ) $edge1: Edge( p1 == $bp, p2 == $p2, label == Edge.NIL ) $edge2: Edge( p1 == $bp, p2 == $p3 ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( $label ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 1B" when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p1, $label:label -> ( $label.equals(Edge.B) || $label.equals(Edge.MINUS) ) ) $edge1: Edge( p1 == $bp, p2 == $p2 ) $edge2: Edge( p1 == $bp, p2 == $p3, label == Edge.NIL ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( $label ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 2A" salience 5 when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p3, $label:label -> ( $label.equals(Edge.B) || $label.equals(Edge.MINUS) ) ) $edge1: Edge( p1 == $bp, p2 == $p2, label == Edge.NIL ) $edge2: Edge( p1 == $bp, p2 == $p1 ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( $label ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 2B" when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p3, $label:label -> ( $label.equals(Edge.B) || $label.equals(Edge.MINUS) ) ) $edge1: Edge( p1 == $bp, p2 == $p2 ) $edge2: Edge( p1 == $bp, p2 == $p1, label == Edge.NIL ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( $label ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 3A" salience 5 when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p1, label == Edge.PLUS ) $edge1: Edge( p1 == $bp, p2 == $p2, label == Edge.NIL ) $edge2: Edge( p1 == $bp, p2 == $p3 ) then $edge1.setLabel( Edge.MINUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 3B" when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p1, label == Edge.PLUS ) $edge1: Edge( p1 == $bp, p2 == $p2 ) $edge2: Edge( p1 == $bp, p2 == $p3, label == Edge.NIL ) then $edge1.setLabel( Edge.MINUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 4A" salience 5 when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p3, label == Edge.PLUS ) $edge1: Edge( p1 == $bp, p2 == $p2, label == Edge.NIL ) $edge2: Edge( p1 == $bp, p2 == $p1 ) then $edge1.setLabel( Edge.MINUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 4B" when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p3, label == Edge.PLUS ) $edge1: Edge( p1 == $bp, p2 == $p2 ) $edge2: Edge( p1 == $bp, p2 == $p1, label == Edge.NIL ) then $edge1.setLabel( Edge.MINUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );end rule "label arrow 5A" salience 5 when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p2, label == Edge.MINUS ) $edge1: Edge( p1 == $bp, p2 == $p1 ) $edge2: Edge( p1 == $bp, p2 == $p3, label == Edge.NIL ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );endrule "label arrow 5B" when Stage( value == Stage.LABELING ) Junction( type == Junction.ARROW, $bp:basePoint, $p1:p1, $p2:p2, $p3:p3 ) Edge( p1 == $bp, p2 == $p2, label == Edge.MINUS ) $edge1: Edge( p1 == $bp, p2 == $p1, label == Edge.NIL ) $edge2: Edge( p1 == $bp, p2 == $p3 ) then $edge1.setLabel( Edge.PLUS ); $edge2.setLabel( Edge.PLUS ); modify( $edge1 ); modify( $edge2 );end # The conflict resolution mechanism will only execute a production if no# productions that are more complicated are satisfied. This production is# simple, so all of the above dictionary productions will fire before this# change of state productionrule "done labeling" salience -10 when $stage: Stage( value == Stage.LABELING ) then $stage.setValue( Stage.PLOT_REMAINING_EDGES ); modify( $stage ); System.out.println("Stage: plot remaining edges");end# At this point, some labellings may have not been plotted, so plot themrule "plot remaining" when Stage( value == Stage.PLOT_REMAINING_EDGES ) $edge: Edge( plotted == false, $label:label != Edge.NIL, $p1:p1, $p2:p2 ) then System.out.println("Plot "+$label+" "+$p1+" "+$p2); $edge.setPlotted( true ); modify( $edge );end# If we have been un able to label an edge, assume that it is a boundary.# This is a total Kludge, but what the hell. (if we assume only valid drawings# will be given for labeling, this assumption generally is true!)rule "plot boundaries" when Stage( value == Stage.PLOT_REMAINING_EDGES ) $edge: Edge( plotted == false, label == Edge.NIL, $p1:p1, $p2:p2 ) then System.out.println("Plot B "+$p1+" "+$p2); $edge.setPlotted( true ); modify( $edge );end# If there is no more work to do, then we are done and flag it.rule "done plotting" salience -10 when $stage: Stage( value == Stage.PLOT_REMAINING_EDGES ) then $stage.setValue( Stage.DONE ); modify( $stage ); System.out.println("Stage: done");end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -