***************************************************** * * Juggling example for synchronous workbench, * * Chris Tofts 2/7/92 * * Assume all balls have three positions middle, left * and right. Balls can pass through the middle going * to the left and to the right. Record movement as * midl, midr, left, right actions. ***************************************************** **************************** * An ideal juggle **************************** agent Juggle = midl#left:midr#right:Juggle; ********************************** * The behaviour of juggling Balls ********************************** agent Ball = midl:1:left:midr:1:right:Ball; agent B1 = left:midr:1:right:Ball; agent B2 = 1:right:Ball; agent Jug = Ball | B1 | B2; ********************************* * As we want eq Jug Juggle Holds ********************************* eq (Jug, Juggle); ****************************************** * Introduce some hands to do the juggling ****************************************** agent Hand = want#throw:Hand + 1:Hand; agent Left_Hand = Hand [goleft/want,left_throw/throw]; agent Right_Hand = Hand [goright/want,right_throw/throw]; agent NBall = midl#'goleft:1:left#'left_throw:midr#'goright:1:right#'right_throw:NBall; agent NB1 = left#'left_throw:midr#'goright:1:right#'right_throw:NBall; agent NB2 = 1:right#'right_throw:NBall; set L = {left,right,midl,midr}; agent NJug = (NBall | NB1 | NB2 | Left_Hand | Right_Hand) \ L; ********************************* *eq NJug Juggle holds as we want ********************************* eq (NJug, Juggle); ****************************************************** * Now we give the hands the ability to do high throws * * Have a hard or easy throw ******************************************************* agent Var_Hand = want#easy:Var_Hand + want#hard:Var_Hand + 1:Var_Hand; agent Var_Left = Var_Hand[goleft/want,left_easy/easy,left_hard/hard]; agent Var_Right = Var_Hand[goright/want,right_easy/easy,right_hard/hard]; **************************************** * Balls that respond to variable throws ***************************************** agent VBall = midl#'goleft:1:Held_left; agent Held_left = left#'left_easy:Going_r+left#'left_hard:1:1:1:Going_r+1:Held_left; agent Going_r = midr#'goright:1:Held_right; agent Held_right = right#'right_easy:VBall+right#'right_hard:1:1:1:VBall+1:Held_right; agent VB1 = Held_left; agent VB2 = 1:Held_right; agent Varjug = (VBall | VB1 | VB2 | Var_Left | Var_Right) \ L; agent Ojug = (VBall | VB1 | VB2 | Var_Left | Right_Hand[right_easy/right_throw]) \ L; ************************************************************ * Again eq Juggle Varjug holds as does * eq Juggle Ojug * but strongeq Juggle Varjug and strongeq Varjug Ojug do not ************************************************************* * eq (Juggle, Varjug); * eq (Juggle, Ojug); * strongeq (Juggle, Varjug); * strongeq (Varjug, Ojug);