understanding first premise using preferential preference

122 views
Skip to first unread message

kartik vermun

unread,
Apr 16, 2017, 2:04:11 PM4/16/17
to PyKE
I am trying to understand the first premise in pyke. 
Assume I have various shapes of various colors-
source.source_value(circle,red)
source.source_value(circle,green)
source.source_value(circle,blue)

and I also have a preference as blue,green,red.
If there's a shape in blue I'll keep it, else will search for green else finally red.
I have the following rule:

select_shape_colors
    foreach
        source.source_value($shape,$color)
    $color_preference = get_color_preference()
    forall $color in color_preference
        first
            source.source_value($shape2,$color2)
    assert
        source.final_shape_color($shape2,$color2)

fc_extras
    def get_color_preference():
        return ('blue','green','red')


however the rule fails due to syntax and logical errors. Does anyone have any idea what I'm doing wrong?

Thanks

Reply all
Reply to author
Forward
0 new messages