!SDML! 4.1 subStandard64.1 .scotts.moss@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan Universityv0llists84.1~17bruceb.edmonds@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan Universityv  .v0trees114.1: v ~17 v Onegonet234.1%*brucebruce@cfpm.orgv]&w: vtQ3.4c3.53.64.04.1urlAndRedirectingUrl"http"haltInConsequents@ occurrences@ transcripts!errorInAntecedents@web subStandard6Agent numerical safeMultiply Predicate6UniversalAgentrandomNormalPrimitive lowerCasePrimitive signOf  safeInverse randomInteger  safeDivide   CompositeAgent Numberinst backward is ?res 1 / (0.001 + ?num)safeInverse ?res ?num  top-level  GroundTerm Rand randomNumber ?rn ?term\ is ?ri ?from + (truncated ?rn * (?upTo - ?from + 1))#randomInteger ?ri ?from ?upTo ?term "2 args randomInteger ?ri 1 ?upTo ?termrandomInteger ?ri ?upTo ?term % top - level String, primitive "to convert string to lower case quickly" clause first unifyWith: (GPCodeHolder lowerCase: ((clause at: 2) unbindUsing: bindings)) bindings: bindings continuation: continuation. ^Unify the first argument with the product of the remaining arguments.

The remaining arguments can be any combination of matrices and numbers (as long as the number of columns in a preceeding matrix equals the number of rows in the following one). The result is a number if all the remaining arguments are numbers; otherwise the result is a matrix. and is ?max (max (absoluteValue ?arg1) (absoluteValue ?arg2))\ (if greater ?max 1.0e100\ is ?result 1.0e100\ is ?result ?arg1 * ?arg2) safeMultiply ?result ?arg1 ?arg2 0 !-  "comment stating purpose of method" clause first unifyWith: (GPCodeHolder nextNormalRandom) bindings: bindings continuation: continuation5 HUnify the first argument with the absolute value of the second argument. Tif greater ?arg 0\ = ?result 1\ (if less ?arg 0\ = ?result -1\ = ?result 0)signOf ?result ?arg 7 ^Unify the first argument with the product of the remaining arguments.

The remaining arguments can be any combination of matrices and numbers (as long as the number of columns in a preceeding matrix equals the number of rows in the following one). The result is a number if all the remaining arguments are numbers; otherwise the result is a matrix. and absoluteValue ?aarg1 ?arg1\ absoluteValue ?aarg2 ?arg2\ (if thereExists (or greater ?aarg1 1.0e100\ less ?aarg2 1.0e-100)\ is ?result 1.0e100 * (signOf ?arg1) * (signOf ?arg2)\ is ?result ?arg1 / ?arg2)safeDivide ?result ?arg1 ?arg2 <:13.6$-bruceb.edmonds@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan Universityu" :24.1+;CDEv- :3G,3CDEvd+ :4G -CDEv帹 :54.1 "7CDEun Breplace Predicatelists8UniversalAgentlistOflastOf first binarySearchPrimitive  binarySearch third withoutDuplicates  appendedList replaceInList second  notEmpty cummulateList  flattened lists fitnessAgent Listinst}The first list is the second list appended to the third list.

This can be used to join lists together or split them apart. backward  trueappendedList [] [] bottom Gand appendedList ?restList ?rest\ appended ?list ?firstList ?restList'appendedList ?list [?firstList | ?rest] "recurse Term true,third ?third [?first ?second ?third | ?rest] * top-level )  /and length ?list ?len\ index ?list ?len ?itemlastOf ?item ?list 0.  GroundList5 truewithoutDuplicates [] [] 6# =and withoutDuplicates ?rest ?rawRest\ includes ?rest ?first+withoutDuplicates ?rest [?first | ?rawRest] 9recurse - dup Kand withoutDuplicates ?rest ?rawRest\ notInferred includes ?rest ?first6withoutDuplicates [?first | ?rest] [?first | ?rawRest] 9recurse - no dup  GroundTerm5C5 :mappedList ?resulltList ?list [?item ?replacement] replace3replaceInList ?resulltList ?list ?item ?replacement Dtop ) true'second ?second [?first ?second | ?rest] J. 55 and isKindOf ?first List\ notInferred isKindOf ?first String\ flattened ?flattenedFirst ?first\ flattened ?flattenedRest ?rest\ appended ?list ?flattenedFirst ?flattenedRest flattened ?list [?first | ?rest] Ofirst is list jand (or notInferred isKindOf ?first List\ isKindOf ?first String)\ flattened ?flattenedRest ?rest4flattened [?first | ?flattenedRest] [?first | ?rest] Rfirst not list trueflattened [] [] Rempty )  truefirst ?first [?first | ?rest] ]. Numberbb truecummulateList [] [] ?cumm c# Fand is ?newCumm ?first + ?cumm\ cummulateList ?restOp ?rest ?newCumm9cummulateList [?newCumm | ?restOp] [?first | ?rest] ?cumm f' cummulateList ?res ?list 0cummulateList ?res ?list f. bbbbinarySearchPrimitive ?position ?number ?sortedListOfNumbers

The first argument is unified with its position in the second (a list).  primitive "unify the first argument with the maximum depth of tree" clause first unifyWith: (GPCodeHolder findPositionIn: ((clause at: 3) unbindUsing: bindings) of: ((clause at: 2) unbindUsing: bindings)) bindings: bindings continuation: continuationo  truenotEmpty [?something | ?rest] qH }The first list is the second list appended to the third list.

This can be used to join lists together or split them apart. trueappendedList [] [] u# Gand appendedList ?restList ?rest\ appended ?list ?firstList ?restList'appendedList ?list [?firstList | ?rest] x' b  and greater ?length 0\ includes ?sourceList ?item\ is ?lengthMinus ?length - 1\ listOf ?restList ?lengthMinus ?sourceList\ = ?list [?item | ?restList] listOf ?list ?length ?sourceList }' truelistOf [] 0 ?sourceList # bbbb5 >and length ?list ?top\ index ?list ?top ?biggest\ max ?max ?biggest ?number\ = ?list [?smallest | ?rest]\ min ?min ?number ?smallest\ appended ?searchListMax ?list [?max]\ appended ?searchList [?min] ?searchListMax\ is ?upper ?top + 1\ binarySearch ?posPlus ?number 1 ?upper ?searchList\ is ?pos ?posPlus - 1binarySearch ?pos ?number ?list!initiate binary search for number topLevel >and is ?lowerPlus ?lower + 1\ less ?lowerPlus ?upper\ is ?middle (truncated (?lower + ?upper) / 2)\ index ?list ?middle ?value\ (or (and notInferred less ?number ?value\ binarySearch ?pos ?number ?middle ?upper ?list)\ (and less ?number ?value\ binarySearch ?pos ?number ?lower ?middle ?list))-binarySearch ?pos ?number ?lower ?upper ?list recursive step is ?upper ?lower + 1/binarySearch ?upper ?number ?lower ?upper ?list bottom step CCCC 5if = ?old ?match\ = ?new ?replacement\ = ?new ?old%replace ?new ?old ?match ?replacement H:13.1b4-bruceb.edmonds@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan Universityv :23.1b46(v>:33.4a"&v2:43.4a#53vE~:54.1 -*v:64.1 "9t+:74.1 . scotts.moss@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan Universityv'ftrees11AgentlabelOf PredicateUniversalAgent allLabels  isSubTreeOf  maxDepth  mappedLeaves  includesLeaf isTree  subTreeOf  modifyBranch nodeListPrimitive isLeaf  branches leafOf nodeOf hasLeaf  noBranches  mappedLabels  randomTree maxDepthPrimitive subTree graft randomNodeChoice branch fixedRandomCrossover tree  hasBranches  allLeaves mappedLeafLabels leafListPrimitive fixedRandomNodeChoice label  crossover allLeafLabels fixedRandomTree  nodeList inst GroundListNumbernoBranches ?num ?tree backward length ?branches ?num$noBranches ?num [?label | ?branches] 3 top-level 0/0/0/03graft ?resultTree ?originalTree ?posList ?graftTree2  and branch ?branch ?firstPos ?originalTree\ graft ?resultSubTree ?branch ?restPosList ?graftTree\ modifyBranch ?resultTree ?originalTree ?firstPos ?resultSubTreeEgraft ?resultTree ?originalTree [?firstPos | ?restPosList] ?graftTree 97 true,graft ?graftTree ?originalTree [] ?graftTree 9bottom /0hasBranches ?tree2% true1hasBranches [?label ?firstBranch | ?restBranches] C7 0/00/0/0/0jcrossover ?firstChildTree ?secondChildTree ?firstPosList ?secondPosList ?firstParentTree ?secondParentTree2+ and subTree ?firstGraft ?firstParentTree ?firstPosList\ subTree ?secondGraft ?secondParentTree ?secondPosList\ graft ?firstChildTree ?firstParentTree ?firstPosList ?secondGraft\ graft ?secondChildTree ?secondParentTree ?secondPosList ?firstGraftjcrossover ?firstChildTree ?secondChildTree ?firstPosList ?secondPosList ?firstParentTree ?secondParentTree H7 / GroundTerm0/0*fixedRandomNodeChoice ?posList ?tree ?term2) 6fixedRandomChoice ?posList ?pl ?term nodeOf ?pl ?tree*fixedRandomNodeChoice ?posList ?tree ?term N7 0/0"nodeList ?listOfNodePosLists ?tree2. 8sortedList ?list ?nodePosList nodeOf ?nodePosList ?treenodeList ?list ?tree S7 M/0label ?label ?list2* truelabel ?label [?label | ?rest] X7 /00allLabels ?labelList ?tree2  trueallLabels [?label] [?label] ]leaf and = ?branches [?something | ?rest]\ mappedList ?resultList ?branches allLabels\ randomList ?subLeafList ?lb true (and includes ?resultList ?list\ includes ?list ?lb)\ appended ?labelList [?label] ?subLeafList)allLabels ?labelList [?label | ?branches] ` recusive /M/MsubTreeOf ?subTree ?tree2 Mand includes [?firstBranch | ?branches] ?branch\ subTreeOf ?subTree ?branch4subTreeOf ?subTree [?label ?firstBranch | ?branches] grecurse truesubTreeOf [?label] [?label] ja 0/1/0/0/MgrandomTree ?tree ?maxDepth ?nodeList ?terminalList ?term

(?nodeList = pairs of [label noOfBranches])2- dand greater ?depth 0\ fixedRandomChoice [?label ?noBranches] ?node ?term includes ?nodeList ?node\ is ?newDepth ?depth - 1\ sortedList ?pairList ?pair (and inInterval ?branchNo 1 ?noBranches\ fixedRandomTree ?branch ?newDepth ?nodeList ?terminalList [?branchNo | ?term]\ = ?pair [?branchNo ?branch])\ mappedList ?branches ?pairList secondIfixedRandomTree [?label | ?branches] ?depth ?nodeList ?terminalList ?term p7 >fixedRandomChoice ?label ?lb ?term includes ?terminalList ?lb8fixedRandomTree [?label] 0 ?nodeList ?terminalList ?term sA /M/MsubTreeOf ?subTree ?tree2 and notInferred = ?subTree [?label ?firstBranch | ?branches]\ includes [?firstBranch | ?branches] ?branch\ isSubTreeOf ?subTree ?branch6isSubTreeOf ?subTree [?label ?firstBranch | ?branches] wk trueisSubTreeOf ?tree ?tree za 0/0>the first argument is unified with a list of nodes in the tree primitive "unify the first argument with a list of leaves in argument 2" clause first unifyWith: (GPCodeHolder nodeList: (clause at: 2)) bindings: bindings continuation: continuation /00leafOf ?leaf ?tree2 6and includes ?branches ?branch\ leafOf ?leaf ?branch!leafOf ?leaf [?label | ?branches] 7 trueleafOf [?label] [?label] a /0Mbranches ?branchList ?tree2 true+branches ?branchList [?label | ?branchList] 7 /00/0/ (?nodeList = pairs of [label noOfBranches])2 Xand greater ?depth 0\ randomChoice [?label ?noBranches] ?node ?term includes ?nodeList ?node\ is ?newDepth ?depth - 1\ sortedList ?pairList ?pair (and inInterval ?branchNo 1 ?noBranches\ randomTree ?branch ?newDepth ?nodeList ?terminalList [?term ?branchNo]\ = ?pair [?branchNo ?branch])\ mappedList ?branches ?pairList secondDrandomTree [?label | ?branches] ?depth ?nodeList ?terminalList ?term 7 9randomChoice ?label ?lb ?term includes ?terminalList ?lb3randomTree [?label] 0 ?nodeList ?terminalList ?term A 0/M/0/14modifyBranch ?newTree ?tree ?branchNumber ?newBranch2  :53.4a#57*+,v) :64.1 -,*+,vh :74.1 ";*+,vE : 84.1 .#scotts.moss@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan UniversityvL : 94.1} *+,v : 10B~1;*+,v= 'Objectnegonet23 IndicatorChainLinkActionEndorsementSchemeStateMessage Agreement Endorsement TextTypeAgent Negotiator LoopingAgentParallelCompositeAgentModelsplitBy PredicateUniversalAgentnegotiatorStartInfo#%Type%maxOf#%parseGoalBracketsList#%subSet#% nextWillHold#%offer#% averageOf#%doneBy#% splitAtFirst#%overallStateValuation#%perceivedAction#% treeToClause#% previously#% randomOneOf#% onlyLast#%parseACondition#%parseNegation#%parseAnAction#%cleanUp#% parseRest#%linkEnd#% '% stripFront#%tabledAgreementActions#%weightedIndicatorValue#% negotiator#%strip#%'%tabledAgreement#%findAgreementName#% chosenChain#%request#% linkSign#% equalSet#%EndorsementScheme'%calcChainLength#%asSet#%responsiveThreat#%product#%negotiatorInfo#%XXX#%butLast#%viewpointsFileName#%myState#%replaceInGoal#%action#%tabledAgreementAims#%possibleAgreement#%stripCR#%splitIntoAgents#%parseNodeString#% sumOfAllWeightedIndicatorValues#% chainValue#%stateValuationExpression#%linkCondition#%link#%power#%agreed#%valueStateExpression#%linkToActions#%'%actionsInCondition#%findPossibleChain#%stripLeadingSpaces#%'%indicatorWeighting#%state#%parseAgentString#% linkStart#%totalOf#%positiveActionInCondition#% parseLinks#%splitIntoNodes#%chainOriginator#% stripSpaces#%myOfferOfAgreement#% chainLinks#%parseBrackets#% indicator#%unchangedFromLast#%findAgreementSet#% '% preparse#%negativeActionInCondition#% stripLine#%reverseParsed#%accessibleStateInOneStep#%myConditionalOffer#%splitByAtLeastOneOf#%negotiatorDescription#%accessibleStateInNSteps#%parseStartString#%currentlyHolds#%tabledAgreementText#% '% iAgreeTo#% replaceAll#% '%union#%differenceSet#%findMatchingBracket#% actionPhase#%saidBy#%statesReachableInNSteps#%replaceStringeByFunctorsInTree#% sourceOf#%'% parseALink#% broadcast#%possibleAction#%parseIndicatorString#%conditionalOffer#%iHaveAgreedTo#% currentValue#%message#%minOf#% stripBack#%parseValuationExpressionString#%'% previous#%chain#% splitAtPos#% toBeDoneBy#%saidTo#%div#% stripComment#%parseCondition#%asPrintedList#%parseGoalBrackets#%do#% numSteps#%consideredChain#%offerOfAgreement#%singlePrinted#% pairList#%model %associatedText#%stateValuation#%'% valueState#%indicatorValue#%setSize#% parseActions#% intersection#% triedChain#%stripTrailingSpaces#% standard!negotiationCycle TimeLevel!run! actionCycle! numerical!text!sets!miscellaneous!R!communication!stages!initialisation!ontological items!parsing!lists! doNothing  nullLink   viewpointRdecision makinggoal% eternity trueactiveSubAgent modelactivate modelR!finalchair time actionCycle 10final actionCyclemax final action cycle and last negotiationCycle (message ?from ?to (offerOfAgreement ?agentActionList ?endList))\ asSet ?actions ?agentActionList\ asSet ?ends ?endList\ generatedInstance ?agreementName Agreement (wrt [run actionCycle] ?agentActionList ?ends)\ sortedList ?opStringList ?string (and includes ?agentActionList [?agent ?actionList]\ printed ?agentString ?agent\ asPrintedList ?agentActionString ?actionList\ appended ?string ?agentString " will do " ?agentActionString)\ asPrintedList ?opString ?opStringList ";"\ asPrintedList ?endString ?endList\ appended ?text ?opString " in order to achieve: " ?endString\ includes ?agentActionList [?agent ?anActionList]and every negotiationCycle (and tabledAgreement ?agreementName\ tabledAgreementAims ?agreementName ?endList\ tabledAgreementActions ?agreementName ?agent ?anActionList\ tabledAgreementText ?agreementName ?text) and
myOfferOfAgreement ?agentOfferList ?endStates\
sortedList ?opStringList ?string
(and
includes ?agentOfferList [?agent ?actionList]\
printed ?agentString ?agent\
asPrintedList ?agentActionString ?actionList\
appended ?string ?agentString " will do " ?agentActionString)\
asPrintedList ?opString ?opStringList ";"\
asPrintedList ?endString ?endStates\
= ?text ?opString " in order to achieve: " ?endString "."\
table agreement TthereExists and toBeDoneBy ?agent ?action\ notInferred doneBy ?agent ?action"every negotiationCycle actionPhaseR {and final negotiationCycle\ agreed ?name\ tabledAgreementActions ?name ?agent ?actionList\ includes ?actionList ?action2and every actionCycle (toBeDoneBy ?agent ?action)I report ?agent " is committed to " ?action "."\ post commitments from agreementR and last (notInferred and message ?from ?to ?content\ notInferred last (message ?from ?to ?content))\ last (notInferred and agreed ?name\ notInferred last (agreed ?name))and final negotiationCyclea report "Negotiation round ends since nobodoy has anything else to offer"\final negotiation cycle and tabledAgreement ?name\ notInferred (and tabledAgreementActions ?name ?agent ?list\ notInferred message ?agent ?other (iAgreeTo ?name))*and agreed ?name\ final negotiationCycleG report "Agreement has been reached on: " ?name\'all agree then final negotiation cycle falseGreport "--------------------------------------------------------------"?and
time negotiationCycle ?neg\
greater ?neg 1\announce round falseGreport ?agreementName " consisting of: " ?text " has just been tabled."and
tabledAgreementText ?agreementName ?text\
notInferred
last negotiationCycle (tabledAgreementText ?agreementName ?text)\announce tabled agreement time negotiationCycle 10final negotiationCyclemax final negotiation cycle finishing! true final run final run! time actionCycle ?negTreport "==========================================================================="#time actionCycle ?neg\announce negotiation session nlast actionCycle (and notInferred actionPhase\ unchangedFromLast actionCycle (message ?from ?to ?message))/and every negotiationCycle (final actionCycle)and
last actionCycle (notInferred
or
doneBy ?name ?actions\
agreed ?agreement)\
notInferred
(or
doneBy ?name ?actions)\
agreed ?agreement\
final actionCycleinit! trueand timeLevels [run actionCycle negotiationCycle]\ initialTime run 1\ initialTime actionCycle 1\ initialTime negotiationCycle 1timeparse viewpoints! parameters and thereExists indicator ?indicator\ negotiatorInfo ?negotiator ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?nodeInfo [?name ?description ?indicatorList ?actionList ?linkList]\ cleanUp ?cleanedName ?name\ cleanUp ?cleanedDescription ?description\ namedInstance ?state State ?cleanedName\ includes ?actionList [?actionStr ?actionDesc]\ namedInstance ?action Action ?actionStrVevery actionCycle (and state ?state ?cleanedDescription\ action ?action ?actionDesc)initialise nodes with actions and thereExists state ?state ?description\ negotiatorStartInfo ?negotiator ?startList\ (if = ?startList []\ (and negotiatorInfo ?negotiator ?indicatorInfo ?indicatorExpression ?nodeInfo\ lastOf [?name ?description ?indicatorList ?actionList ?linkList] ?nodeInfo\ cleanUp ?cleanedName ?name\ namedInstance ?state State ?cleanedName)\ (and includes ?startList ?name\ cleanUp ?cleanedName ?name\ namedInstance ?state State ?cleanedName))8at ?negotiator (all actionCycle (currentlyHolds ?state))1and
thereExists
state ?state ?description\
negotiatorInfo ?negotiator ?indicatorInfo ?indicatorExpression ?nodeInfo\
lastOf [?name ?description ?indicatorList ?actionList ?linkList] ?nodeInfo\
cleanUp ?cleanedName ?name\
namedInstance ?state State ?cleanedName\
 initial node &and thereExists indicator ?indicator\ negotiatorInfo ?negotiator ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?nodeInfo [?name ?description ?indicatorList [] ?linkList]\ cleanUp ?cleanName ?name\ cleanUp ?cleanedDescription ?description\ namedInstance ?state State ?cleanName9every actionCycle (and state ?state ?cleanedDescription)!initialise nodes without actions and viewpointsFileName ?viewpointsFileName\ fileContents ?viewpointsFileName ?rawString\ preparse ?string ?rawString\ splitIntoAgents ?list ?string\ mappedList ?parsedList ?list parseAgentString\ includes ?parsedList ?agentInfo\ = [?name ?description ?indicatorInfo ?indicatorExpression ?nodeInfo ?startList] ?agentInfo\ cleanUp ?cleanName ?name\ namedInstance ?negotiator Negotiator ?cleanNameand negotiatorInfo ?negotiator ?indicatorInfo ?indicatorExpression ?nodeInfo\ negotiatorStartInfo ?negotiator ?startList\ every actionCycle (and negotiator ?negotiator\ negotiatorDescription ?negotiator ?description\ activeSubAgent ?negotiator)and
viewpointsFileName ?viewpointsFileName\
fileContents ?viewpointsFileName ?string\
splitIntoAgents ?list ?string\
mappedList ?parsedList ?list parseAgentString\
includes ?parsedList ?agentInfo\
= [?name ?description ?indicatorInfo ?indicatorExpression ?nodeInfo] ?agentInfo\
cleanUp ?cleanName ?name\
namedInstance ?negotiator Negotiator ?cleanName\
 read in file Zand = ?fn "example3-extended"\ appended ?filename ?fn ".txt"\ appended ?opfn ?fn ".res"Oand viewpointsFileName ?filename\ reportToTextFile textReportTranscript ?opfnviewpoint file false.every actionCycle (action ?action ?actionDesc)sand
namedInstance ?action Action "nullAction"\
= ?actionDesc "The null action"\initialise with nullAction and negotiatorInfo ?negotiator ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?indicatorInfo [?indicatorStr ?weightStr]\ namedInstance ?indicator Indicator ?indicatorStr\ parsed ?weightStr ?weight(every actionCycle (indicator ?indicator)initialise indicators ListStringinst#$%$ backward!V /notInferred foundSubList ?pos ?string "Agent:"7splitIntoAgents [?string | ?lastList] ?lastList ?string 'bottom xand splitAtFirst ?firstAgentString ?rest ?string "Agent:"\ splitIntoAgents ?list [?firstAgentString | ?lastList] ?rest'splitIntoAgents ?list ?lastList ?string *recurse }if splitAtFirst ?preamble ?butPreamble ?string "Agent:"\ splitIntoAgents ?list [] ?butPreamble\ error "No Agent in string"splitIntoAgents ?list ?string *top  forward!.R %$ GroundList&!p and findMatchingBracket ?posRBr ?rest\ splitAtPos ?midStr ?tailStr ?rest ?posRBr\ strip ?mid ?midStr\ parseBrackets ?midTree ?mid\ strip ?tail ?tailStr\ parseBrackets ?tailTree ?tail2parseBrackets [?midTree | ?tailTree] [<(> | ?rest]~and
= ?string "sdfsfsdf( sdf sdf ) dsfasf"\
foundSubList ?posBr ?string "("\
notInferred
(and
foundSubList ?posSp ?string " "\
greater ?posBr ?posSp)\
splitAtFirst ?firstStr ?restStr ?string "("\
findMatchingBracket ?posRBr ?restStr\
splitAtPos ?midStr ?tailStr ?restStr ?posRBr\
8first is bracket and notInferred = ?ch <(>\ splitAtFirst ?firstStr ?afterStr ?rest "("\ parseBrackets ?firstList [?ch | ?firstStr]\ parseBrackets ?restTree [<(> | ?afterStr]\ appended ?tree ?firstList ?restTree!parseBrackets ?tree [?ch | ?rest] ;bracket is not first and differenceList ?string ?string "("\ strip ?strippedString ?string\ (if notEmpty ?strippedString\ splitByAtLeastOneOf ?list ?strippedString " "\ = ?list ?strippedString)parseBrackets ?list ?string ; no brackets 7%$&! and cleanUp ?cleanRest ?rest\ findMatchingBracket ?posRBr ?rest\ length ?rest ?posRBr\ butLast ?inside ?cleanRest\ parseGoalBrackets ?tree ?inside%parseGoalBrackets ?tree [<(> | ?rest] F#first and last is matching bracket and notInferred = ?ch <(>\ splitAtFirst ?firstStr ?afterStr ?rest "("\ parseGoalBrackets ?firstList [?ch | ?firstStr]\ parseGoalBracketsList ?restTree [<(> | ?afterStr]\ appended ?tree ?firstList ?restTree%parseGoalBrackets ?tree [?ch | ?rest] Ifunctor and arg list and differenceList ?string ?string "("\ strip ?strippedString ?string\ (if notEmpty ?strippedString\ splitByAtLeastOneOf ?list ?strippedString " "\ = ?list [])\ mappedList ?result ?list replaceInGoal!parseGoalBrackets ?result ?string ID %$$%Integer$%S&! and is ?endFirst ?pos - 1\ is ?startRest ?pos + ?width\ subList ?first ?string 1 ?endFirst\ subList ?rest ?string ?startRest+splitAtPos ?first ?rest ?string ?pos ?width Tat pos &splitAtPos ?first ?rest ?string ?pos 1$splitAtPos ?first ?rest ?string ?pos W3  GroundTermmessage ?from ?to ?message5! ]5!, # ## conditionalOffer ?conditionActionList ?myOfferedActionList

means
I will do ?myOfferedActionList if others do ?conditionActionList5! %$7XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&! "and (if splitAtFirst ?linkStuff ?descStr ?string ":"\ true\ (and = ?linkStuff ?string\ = ?descStr []))\ cleanUp ?description ?descStr\ splitAtFirst ?conditionStr ?DestinationStr ?linkStuff "=>"\ parseACondition ?condition ?conditionStr\ cleanUp ?destination ?DestinationStr9parseALink [?condition ?destination ?description] ?string a3 %$7XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&! and replaceInList ?inlineString ?string \ splitByAtLeastOneOf ?indList ?inlineString " "\ pairList ?list ?indList"parseIndicatorString ?list ?string f3 $TermThis primitive converts the second argument into a string, by printing it in SDML syntax, and unifies the answer with the first argument.

Optional arguments:
3) numeric format, used to print all numbers in the term, which must currently be one of the following (if omitted, normal is assumed):
integer print as integers (rounding to nearest ones)
float print in floating point
'decimal-<n>' print as decimals with <n> decimal places (<n> can be any integer from 1 to 20, but note that SDML floating point numbers only have about 14 significant figures)
normal integer for members of type Integer, otherwise float

4) List of variables. Each element of the list must be a distinct uninstantiated variable; every variable used in the term must be in this list, but not all elements of the list need to be used in the term).

5) List of strings representing variable names. This list should be the same length as the fourth argument.

N.B. Printing takes place in the context of the agent for which the clause is being evaluated. Paths (using "@") are printed when necessary.&! Vand isKindOf ?term String\ strip ?intString ?term <'>\ strip ?string ?intString <">singlePrinted ?term ?term lstring and notInferred isKindOf ?term String\ printed ?rawString ?term\ strip ?intString ?rawString <'>\ strip ?string ?intString <">singlePrinted ?string ?term o not string 7775!L 5!R 7%$XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&!W Oif splitAtFirst ?nodeStuff ?restStringList ?nodeString "Indicators:"\ (and (if splitAtFirst ?nameStr ?descriptionStr ?nodeStuff ":"\ (and stripLine ?name ?nameStr\ stripLine ?description ?descriptionStr\ (if splitAtFirst ?indicatorStuff ?restStuff ?restStringList " "\ (and cleanUp ?cleanIndicatorStuff ?indicatorStuff\ parseIndicatorString ?indicatorList ?cleanIndicatorStuff\ parseRest ?actionList ?linkList ?restStuff)\ = ?indicatorStuff ?restStuff))\ error "No : to indicate node description"))\ error "No Indicators: in string"UparseNodeString [?name ?description ?indicatorList ?actionList ?linkList] ?nodeString x3 # # responsiveThreat ?othersActionList ?myResponseActionList

means
If others do ?othersActionList I will do ?myResponseActionList5!J 5!A 775!A %7$%$&! trueasPrintedList [] [] ?sep empty singlePrinted ?string ?first#asPrintedList ?string [?first] ?sep one and asPrintedList ?stringRest [?second ?third | ?rest] ?sep\ singlePrinted ?string1 ?first\ appended ?string ?string1 ?sep " " ?stringRest:asPrintedList ?string [?first ?second ?third | ?rest] ?sep many pand singlePrinted ?string1 ?first\ singlePrinted ?string2 ?second\ appended ?string ?string1 " and " ?string2+asPrintedList ?string [?first ?second] ?sep two asPrintedList ?string ?term ","asPrintedList ?string ?term 3 &!M .error "You have left an XXX marker in a rule!"XXX 3 5!^ 7%7%7&! and asSet ?set1 ?list1\ asSet ?set2 ?list2\ sortedList ?intersection ?memb (and includes ?set1 ?memb\ includes ?set2 ?memb)(intersection ?intersection ?list1 ?list2 3 7%7%7&! pairList ?pairList [] ?listpairList ?pairList ?list 3 4pairList ?pairList [[?first ?second] | ?soFar] ?rest2pairList ?pairList ?soFar [?first ?second | ?rest] / truepairList ?soFar ?soFar [] falsepairList + 7%7%7&!] Fand asSet ?set ?list\ sortedList ?pset ?subSet subSet ?subSet ?setpower ?pset ?list 3 %7%77&! falseJreplaceStringeByFunctorsInTree ?resultTree ?tree ?listOfStringFunctorPairs 3 $% Character%$&! )stripBack ?strippedString ?string !stripBack ?strippedString ?stringDefault strip is a space 3 aand reversed ?rev ?string\ stripFront ?revResult ?rev ?ch\ reversed ?strippedString ?revResult%stripBack ?strippedString ?string ?ch main ]%]&!2 Aor notInferred isKindOf ?object List\ isKindOf ?object StringtreeToClause ?object ?object is not a list dand mappedList ?listOfClauseArgs ?args treeToClause\ clauseList ?clause ?functor ?listOfClauseArgs'treeToClause ?clause [?functor | ?args] is branch $5!z $5!O %7%$7%$&!" fif notInferred foundSubList ?pos ?string ?mark\ = ?list [?string]\ splitBy ?list [] ?string ?marksplitBy ?list ?string ?mark 3 and splitAtFirst ?first ?rest ?string ?mark\ appended ?nextListSoFar ?listSoFar [?first]\ splitBy ?list ?nextListSoFar ?rest ?mark&splitBy ?list ?listSoFar ?string ?mark / Xand notInferred foundSubList ?pos ?string ?mark\ appended ?list ?listSoFar [?string]&splitBy ?list ?listSoFar ?string ?mark + %$$&!u Qand stripCR ?res1 ?string\ stripComment ?res2 ?res1\ stripSpaces ?result ?res2stripLine ?result ?string 3 7%$XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&!| fand replaceInList ?inlineString ?string \ splitByAtLeastOneOf ?indList ?inlineString " "!parseStartString ?indList ?string 3 7%7&!* and subSet ?subSetRest ?rest\ (or = ?list1 ?subSetRest\ (if includes ?subSetRest ?first\ = ?list1 ?subSetRest\ = ?list1 [?first | ?subSetRest]))subSet ?list1 [?first | ?rest] / true subSet [] [] + %$$&! and reversed [?last | ?rest] ?string\ (if = ?last \ stripLeadingSpaces ?revResult ?rest\ = ?revResult [?last | ?rest])\ reversed ?result ?revResult#stripTrailingSpaces ?result ?string 3 truestripTrailingSpaces [] [] %7%7&!F land asSet ?set1 ?list1\ asSet ?set2 ?list2\ differenceList [] ?set1 ?set2\ differenceList [] ?set2 ?set1equalSet ?list1 ?list2 3 %77%7&! ~and asSet ?set1 ?list1\ asSet ?set2 ?list2\ sortedList ?union ?memb (or includes ?set1 ?memb\ includes ?set2 ?memb)union ?union ?list1 ?list2 3 %77%7&! Oand asSet ?set1 ?list1\ asSet ?set2 ?list2\ differenceList ?diff ?set1 ?set2!differenceSet ?diff ?list1 ?list2 3 %$7XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&! fand splitBy ?actionStringList ?string "Action:"\ mappedList ?actions ?actionStringList parseAnActionparseActions ?actions ?string 3  5!R Number%7&! )and asSet ?set ?list\ length ?set ?sizesetSize ?size ?list 3 %$7XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&!j [and splitBy ?linkStringList ?string "Link:"\ mappedList ?links ?linkStringList parseALinkparseLinks ?links ?string 3 %7%77&!K and asSet ?set1 ?list1\ asSet ?set2 ?list2\ sortedList ?product ?pair (and includes ?set1 ?memb1\ includes ?set2 ?memb2\ = ?pair [?memb1 ?memb2])product ?product ?list1 ?list2 3 ]5!D 5!? %7%7%$77ZparseRest ?actionList ?linkList ?restStuff&!: ~if splitAtFirst ?actionStuff ?linkStuff ?string "Link:"\ (and parseLinks ?linkList ?linkStuff\ (if splitAtFirst ?preAction ?postAction ?actionStuff "Action:"\ parseActions ?actionList ?postAction\ = ?actionList []))\ (and = ?linkList []\ (if splitAtFirst ?preAction ?postAction ?string "Action:"\ parseActions ?actionList ?postAction\ = ?actionList []))'parseRest ?actionList ?linkList ?string 3 #$%$%#$&!k .notInferred foundSubList ?pos ?string "Node:"6splitIntoNodes [?string | ?lastList] ?lastList ?string + tand splitAtFirst ?firstNodeString ?rest ?string "Node:"\ splitIntoNodes ?list [?firstNodeString | ?lastList] ?rest&splitIntoNodes ?list ?lastList ?string "/ splitIntoNodes ?list [] ?stringsplitIntoNodes ?list ?string "3 %77&!I true asSet [] [] *+ and isKindOf ?first List\ notInferred isKindOf ?first String\ asSet ?firstAsSet ?first\ asSet ?restAsSet ?rest\ (if includes ?restAsSet ?firstAsSet\ = ?set ?restAsSet\ = ?set [?firstAsSet | ?restAsSet])\ sortedList ?sortedSet ?m includes ?set ?m!asSet ?sortedSet [?first | ?rest] -first is list and (or notInferred isKindOf ?first List\ isKindOf ?first String)\ asSet ?restAsSet ?rest\ (if includes ?restAsSet ?first\ = ?set ?restAsSet\ = ?set [?first | ?restAsSet])\ sortedList ?sortedSet ?m includes ?set ?m!asSet ?sortedSet [?first | ?rest] -first is not list #5!S %$%$7%7&!y rand appended ?doubleMark ?mark ?mark\ replaceAll ?result ?string ?doubleMark ?mark\ splitBy ?list ?result ?mark'splitByAtLeastOneOf ?list ?string ?mark 83 %7%7%77&! and foundSubList ?pos ?old ?search\ splitAtFirst ?left ?right ?old ?search\ appended ?protoNew ?left ?replacement ?right\ replaceAll ?new ?protoNew ?search ?replacement)replaceAll ?new ?old ?search ?replacement = found one +notInferred foundSubList ?pos ?old ?search)replaceAll ?old ?old ?search ?replacement @none _and foundSubList ?pos ?replacement ?search\ error "Infinite search and replace"\ = ?new ?old)replaceAll ?new ?old ?search ?replacement @error %$]&!Q objectName ?functor ?stringreplaceInGoal ?functor ?string Kfunctor 5and parsed ?string ?object\ isKindOf ?object NumberreplaceInGoal ?object ?string Nnumber yand thereExists (and indicator ?indicator\ printed ?string ?indicator)\ namedInstance ?object Indicator ?stringreplaceInGoal ?object ?string Nq S%$%S&! truefindMatchingBracket 0 ?string 0 X at position and greater ?level 0\ (if = ?char <(>\ is ?nextLevel ?level + 1\ (if = ?char <)>\ is ?nextLevel ?level - 1\ is ?nextLevel ?level))\ findMatchingBracket ?posMinus ?rest ?nextLevel\ is ?pos ?posMinus + 1/findMatchingBracket ?pos [?char | ?rest] ?level [recurse forward empty string "findMatchingBracket ?pos ?string 1 findMatchingBracket ?pos ?string [3 %$$&! if minValue ?minHashPos ?hashPos index ?string ?hashPos <#>\ (and is ?end ?minHashPos - 1\ subList ?result ?string 1 ?end)\ = ?result ?stringstripComment ?result ?string e end in cr %$7&!7 Cif = [<-> | ?rest] ?string\ = ?list [not ?rest]\ = ?list ?stringparseNegation ?list ?string k3 $5!~ 5! ]%$&!v parsed ?string ?termreverseParsed ?term ?string r3 %$$&!s `and splitByAtLeastOneOf ?list ?string " "\ mappedList ?commentlessList ?list stripComment\ mappedList ?cleanedList ?commentlessList [" " " "] replaceAll\ mappedList ?strippedList ?cleanedList strip\ mappedList ?listWithCR ?strippedList [" "] appended\ appendedList ?preparsedString ?listWithCR\ replaceAll ?finalString ?preparsedString " " " "preparse ?finalString ?string w3 %$$&!m Oand stripTrailingSpaces ?result1 ?string\ stripLeadingSpaces ?result ?result1stripSpaces ?result ?string |3 7%$XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&!8 nand splitAtFirst ?actionStr ?descStr ?string ":"\ cleanUp ?action ?actionStr\ cleanUp ?description ?descStr,parseAnAction [?action ?description] ?string`and
= ?action "action"\
= ?description "description"\
3 7%$XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&!f if splitAtFirst ?agentStuff ?nodeStringList ?agentString "Node:"\ (and splitIntoNodes ?nodeList ?nodeStringList\ mappedList ?nodeListList ?nodeList parseNodeString\ (if splitAtFirst ?agentName ?restAgentStuff ?agentStuff ":"\ (and cleanUp ?name ?agentName\ (if splitAtFirst ?agentDescription ?indicatorStuff ?restAgentStuff "IndicatorWeights:"\ (and (if splitAtFirst ?indicatorWeightStuff ?afterStateVal ?indicatorStuff "StateValuationClause:"\ (and (if splitAtFirst ?indicatorExpressionStuff ?initialNodes ?afterStateVal "InitialNodes:"\ (and cleanUp ?cleanInitialNodes ?initialNodes\ parseStartString ?startList ?cleanInitialNodes)\ (and = ?startList []\ = ?indicatorExpressionStuff ?afterStateVal))\ cleanUp ?description ?agentDescription\ cleanUp ?indicatorString ?indicatorWeightStuff\ parseIndicatorString ?indicatorList ?indicatorString\ cleanUp ?indicatorExpression ?indicatorExpressionStuff)\ error "No indicator expression in string"))\ error "No IndicatorWeights in string"))\ error "No : after agent name"))\ error "No Node: in string"oparseAgentString [?name ?description ?indicatorList ?indicatorExpression ?nodeListList ?startList] ?agentStringif
splitAtFirst ?agentStuff ?nodeStringList ?agentString "Node:"\
(and
splitIntoNodes ?nodeList ?nodeStringList\
mappedList ?nodeListList ?nodeList parseNodeString\
(if
splitAtFirst ?agentName ?restAgentStuff ?agentStuff ":"\
(and
cleanUp ?name ?agentName\
(if
splitAtFirst ?agentDescription ?indicatorStuff ?restAgentStuff "IndicatorWeights:"\
(and
cleanUp ?description ?agentDescription\
cleanUp ?indicatorString ?indicatorStuff\
parseIndicatorString ?indicatorList ?indicatorString)\
error "No IndicatorWeights: in string"))\
error "No : after agent name"))\
error "No Node: in string"\
†3 $5!q 7%7&!N 9and reversed [?last | ?rest] ?list\ reversed ?res ?restbutLast ?res ?list Œ3 %$$&!c truestripLeadingSpaces [] [] ‘ Xif = ?first \ stripLeadingSpaces ?stripped ?rest\ = ?stripped [?first | ?rest]-stripLeadingSpaces ?stripped [?first | ?rest] ”3 %$$%$&!9 Zand replaceAll ?new ?lines " " " "\ cleanUp ?cleaned [] ?new\ stripLine ?final ?cleanedcleanUp ?final ?lines ™3 and splitAtFirst ?line ?rest ?lines " "\ stripLine ?strippedLine ?line\ (if = ?strippedLine []\ = ?nextCleanedSoFar ?cleanedSoFar\ appended ?nextCleanedSoFar ?cleanedSoFar " " ?strippedLine)\ cleanUp ?cleaned ?nextCleanedSoFar ?rest%cleanUp ?cleaned ?cleanedSoFar ?lines œ/ and notInferred includes ?lines \ stripLine ?strippedLine ?lines\ (if = ?strippedLine []\ = ?cleaned ?cleanedSoFar\ appended ?cleaned ?cleanedSoFar " " ?strippedLine)%cleanUp ?cleaned ?cleanedSoFar ?lines œ+ 7%$XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&!6 gand replaceInList ?inlineString ?string \ cleanUp ?cleanString ?inlineString\ (if foundSubList ?pos ?cleanString " and "\ (and splitBy ?list ?cleanString " and "\ mappedList ?dashList ?list cleanUp\ mappedList ?conditionArgs ?dashList parseNegation\ = ?condition [and | ?conditionArgs])\ parseNegation ?condition ?cleanString)"parseACondition ?condition ?string ¤3 %%QThe first argument is unified with the modulus of the second and third arguments.&! :and mod ?rem ?num ?denom\ is ?res (?num - ?rem) / ?denomdiv ?res ?num ?denom ©3 7%$&!) $and cleanUp [<(> | ?rest] ?string\ strip ?strippedRest ?rest\ findMatchingBracket ?posRBr ?strippedRest\ splitAtPos ?firstStr ?restStr ?strippedRest ?posRBr\ parseGoalBrackets ?firstTree ?firstStr\ parseGoalBracketsList ?restTreeList ?restStr\ appended ?list [?firstTree] ?restTreeList#parseGoalBracketsList ?list ?stringE splitAtFirst ?firstStr ?afterStr ?string "("\ ® first and rest - first bracket and cleanUp [?firstCh | ?rest] ?string\ notInferred = ?firstCh <(>\ strip ?strippedRest ?rest\ splitAtFirst ?firstStr ?afterStr ?strippedRest "("\ parseGoalBrackets ?firstTree ?firstStr\ parseGoalBracketsList ?restTreeList ?afterStr\ appended ?list ?firstTree ?restTreeList#parseGoalBracketsList ?list ?string ±!firstand rest - no first bracket trueparseGoalBracketsList [] [] ± ^and notEmpty ?string\ differenceList ?string ?string "("\ parseGoalBrackets ?result ?string%parseGoalBracketsList ?result ?string ±D 75!&  $5!R %%Clause&!r ^and sortedList ?list ?clause ?clause\ last ?timeLevel (sortedList ?list ?clause ?clause)$unchangedFromLast ?timeLevel ?clause 3 args Sand sortedList ?list ?clause ?clause\ last (sortedList ?list ?clause ?clause)unchangedFromLast ?clause 2 args $5!e %%$$&!@ %strip ?strippedString ?string strip ?strippedString ?stringDefault strip is a space 3 eand stripFront ?frontStrippedString ?string ?ch\ stripBack ?strippedString ?frontStrippedString ?ch!strip ?strippedString ?string ?ch main %$%$&!< *stripFront ?strippedString ?string "stripFront ?strippedString ?stringDefault strip is a space 3 qif = ?first ?ch\ (and stripFront ?resultRest ?rest ?ch\ = ?result ?resultRest)\ = ?result [?first | ?rest]'stripFront ?result [?first | ?rest] ?ch / truestripFront [] [] ?sep %$$$%$&!/ hand foundSubList ?pos ?string ?mark\ length ?mark ?width\ splitAtPos ?first ?rest ?string ?pos ?width'splitAtFirst ?first ?rest ?string ?mark 3 $%$&!U jand reversed [?last | ?rest] ?string\ (if = ?last \ reversed ?result ?rest\ = ?result ?string)stripCR ?result ?string i true stripCR [] [] # 5!= ]%$XparseAgentString ?name ?description ?indicatorString ?nodeStringList ?agentString\&! zand replaceInList ?inlineString ?string \ parseGoalBrackets ?tree ?inlineString\ treeToClause ?clause ?tree.parseValuationExpressionString ?clause ?string 3 7#5! %7%7&!B and asSet ?actions ?agentOfferList\ asSet ?ends ?endStates\ generatedInstance ?agreementName Agreement (wrt [run actionCycle] ?actions ?ends);findAgreementName ?agreementName ?agentOfferList ?endStates 3 &5 6last (and ?clause\ notInferred previously ?clause)onlyLast ?clause without timelevel &3 last (mostRecent ?n ?clause)previously ?clause talklistenact, 4last negotiationCycle (message ?other self ?message)saidBy ?other ?message _and myConditionalOffer ?otherActions ?myActions ?endStateList\ notEmpty ?otherActions\ notEmpty ?myActions\ notInferred last negotiationCycle (saidTo ?other (conditionalOffer ?otherActions ?myActions ?endStateList))\ asPrintedList ?otherString ?otherActions\ asPrintedList ?actionString ?myActions\ asPrintedList ?endStateString ?endStateListand broadcast (conditionalOffer ?otherActions ?myActions ?endStateList)\ report self ": I will " ?actionString " if others " ?otherString "."and
broadcast (conditionalOffer ?otherActions ?myActions ?endStateList)\
report self ": I will " ?actionString " if others " ?otherString " to achieve " ?endStateString "."\
conditional offer and notInferred actionPhase\ numSteps ?n\ findPossibleChain ?linkList ?n\ generatedInstance ?chain Chain (wrt [run] ?linkList)\ notInferred previous (triedChain ?chain)9and consideredChain ?chain\ chainLinks ?chain ?linkListhevery negotiationCycle (and
consideredChain ?chain\
chainLinks ?chain ?linkList)\
considered chains, and notInferred actionPhase\ randomList ?saidList ?item true (and mostRecent negotiationCycle ?n (saidBy ?agent (conditionalOffer ?othersActions ?theirActions ?endStateList))\ = ?item [?agent ?othersActions ?theirActions ?endStateList])\ notEmpty ?saidList\ subSet ?subListOfSaidList ?saidList\ thereExists includes ?subListOfSaidList [self | ?rest]\ notInferred (and includes ?subListOfSaidList [?agent1 ?othersActions1 ?theirActions1 ?endStateList1]\ thereExists (and includes ?othersActions1 ?oneOfOthersActions1\ notInferred (and includes ?subListOfSaidList [?agent2 ?othersActions2 ?theirActions2 ?endStateList2]\ includes ?theirActions2 ?oneOfOthersActions1)))$possibleAgreement ?subListOfSaidListand
randomList ?saidList ?item true
(and
mostRecent negotiationCycle ?n (saidBy ?agent (conditionalOffer ?othersActions ?theirActions ?endStateList))\
= ?item [?agent ?othersActions ?theirActions ?endStateList])\
notEmpty ?saidList\
subSet ?subListOfSaidList ?saidList\
thereExists
includes ?subListOfSaidList [self | ?rest]\
includes ?subListOfSaidList [self ?othersActions1 ?theirActions1 ?endStateList1]\
(if
notEmpty ?othersActions1\
(and
includes ?othersActions1 ?otherAction1\
includes ?subListOfSaidList [?agent2 ?othersActions2 ?theirActions2 ?endStateList2]\
includes ?theirActions2 ?otherAction1))\
find any agreements and myConditionalOffer [] ?myActions ?endStateList\ notEmpty ?myActions\ notInferred last negotiationCycle (saidTo ?other (conditionalOffer [] ?myActions ?endState))\ asPrintedList ?actionString ?myActions\ asPrintedList ?endStateString ?endStateListand broadcast (conditionalOffer [] ?myActions ?endStateList)\ report self ": I will " ?actionString " to achieve " ?endStateString "."wand
broadcast (offer ?myActions)\
report self ": I will do " ?myActions "."\
unconditional offer false=report self ": I suggest the following agreement: " ?text "."cand
myOfferOfAgreement ?agentOfferList ?endStates\
notInferred
last negotiationCycle (myOfferOfAgreement ?agentOfferList ?endStates)\
sortedList ?opStringList ?string
(and
includes ?agentOfferList [?agent ?actionList]\
printed ?agentString ?agent\
asPrintedList ?agentActionString ?actionList\
appended ?string ?agentString " will do " ?agentActionString)\
asPrintedList ?opString ?opStringList ";"\
asPrintedList ?endString ?endStates\
appended ?text ?opString " in order to achieve: " ?endString\
say agreement to agents and toBeDoneBy self ?action\ currentlyHolds ?state\ possibleAction ?state ?action\ notInferred last actionCycle (doneBy self ?action)yand do ?action\ every actionCycle (doneBy self ?action)\ report self " has done " ?action "."\ final negotiationCycle#peform committments where possible pand currentlyHolds ?endState\ stateValuationExpression ?clause\ valueStateExpression ?value ?endState ?clausecurrentValue ?valuecurrent value, and notInferred actionPhase\ saidBy ?agent (conditionalOffer ?wishList [] ?endStateList1)\ notInferred = ?agent self\ currentlyHolds ?currentState\ sortedList ?myActions ?possAction (and possibleAction ?currentState ?possAction\ includes ?wishList ?possAction)\ notEmpty ?myActions\ saidBy self (conditionalOffer ?myWishList [] ?endStateList2)\ appended ?endStates ?endStateList1 ?endStateList24myConditionalOffer ?myWishList ?myActions ?endStatesconsider requests and chosenChain ?chain\ chainLinks ?chain ?linkList\ lastOf ?lastLink ?linkList\ linkEnd ?lastLink ?endState\ currentlyHolds ?thisState\ notInferred = ?endState ?thisState\ mappedList ?positiveActionSets ?linkList linkToActions\ flattened ?actionList ?positiveActionSets\ sortedList ?myActions ?action (and includes ?actionList ?action\ possibleAction ?aState ?action)\ differenceList ?othersActions ?actionList ?myActionsand every negotiationCycle (myConditionalOffer ?othersActions ?myActions [?endState])\ every negotiationCycle (triedChain ?chain)and
chosenChain ?chain\
chainLinks ?chain ?linkList\
lastOf ?lastLink ?linkList\
linkEnd ?lastLink ?endState\
currentlyHolds ?thisState\
notInferred
= ?endState ?thisState\
mappedList ?positiveActionSets ?linkList linkToActions\
flattened ?actionList ?positiveActionSets\
sortedList ?myActions ?action
(and
includes ?actionList ?action\
possibleAction ?thisState ?action)\
differenceList ?othersActions ?actionList ?myActions\
 make offer, message self ?other ?message/every negotiationCycle (saidTo ?other ?message)remember what I said and last negotiationCycle (myOfferOfAgreement ?actionList ?endList)\ findAgreementName ?name ?actionList ?endList\ tabledAgreement ?name\ tabledAgreementActions ?name ?agent ?actions\ notInferred last negotiationCycle (iHaveAgreedTo ?name)Nand broadcast (iAgreeTo ?name)\ every negotiationCycle (iHaveAgreedTo ?name)agree +and broadcast ?message\ negotiator ?other5every negotiationCycle (message self ?other ?message). notInferred
= ?other self\
broadcast messages  and consideredChain ?chain\ chainLinks ?chain ?linkList\ (if notEmpty ?linkList\ (and lastOf ?lastLink ?linkList\ linkEnd ?lastLink ?endState)\ currentlyHolds ?endState)\ stateValuationExpression ?clause\ valueStateExpression ?value ?endState ?clausechainValue ?chain ?valuevalueState value chains, and myConditionalOffer ?othersList [] ?endStateList\ notEmpty ?othersList\ notInferred last negotiationCycle (saidTo ?other (conditionalOffer ?othersList [] ?endStateList))\ asPrintedList ?otherString ?othersList\ asPrintedList ?endStateString ?endStateListand broadcast (conditionalOffer ?othersList [] ?endStateList)\ report self ": Can someone please " ?otherString " so we can achieve " ?endStateString "?"and
broadcast (request ?othersList)\
report self ": Can someone please do " ?othersList "?"\
request actions and myOfferOfAgreement ?agentOfferList ?endStates\ notInferred last negotiationCycle (myOfferOfAgreement ?agentOfferList ?endStates)\ mappedList ?toList ?agentOfferList first\ includes ?agentOfferList [?toAgent | ?rest]Cmessage self ?toAgent (offerOfAgreement ?agentOfferList ?endStates)post agreement to agents nand currentValue ?currentValue\ maxValue ?max ?value (and consideredChain ?chain\ chainValue ?chain ?value\ greater ?value ?currentValue)\ sortedList ?maxChainPairs ?pair (and consideredChain ?chain\ chainValue ?chain ?max\ calcChainLength ?len ?chain\ = ?pair [?len ?chain])\ mappedList [?chosenChain | ?restChain] ?maxChainPairs secondchosenChain ?chosenChainChoose chain by

1. one reaches max valued state (must be more than current)

2. one with fewest num positive acitons

3. random

PS. could be made more efficient by storing considered chain lengths choose chain, Fand possibleAgreement ?list\ mappedList ?toList ?list first\ mappedList ?endStateList ?list lastOf\ flattened ?flatEndStateList ?endStateList\ asSet ?endStates ?flatEndStateList\ sortedList ?agentOfferList ?pair (and includes ?list [?agent ?otherActions ?theirActions ?stateList]\ = ?pair [?agent ?theirActions])Fevery negotiationCycle (myOfferOfAgreement ?agentOfferList ?endStates)agreement offer <and broadcast (iAgreeTo ?name)\ tabledAgreementActions ?name self ?myActions\ sortedList ?othersActions ?act (and tabledAgreementActions ?name ?agent ?actions\ notInferred = ?agent self\ includes ?actions ?act)\ notEmpty ?myActions\ = ?othersActions []\ asPrintedList ?myActionsString ?myActions(report self ": I will " ?myActionsString"report that agree - unconditional tand broadcast (iAgreeTo ?name)\ tabledAgreementActions ?name self ?myActions\ sortedList ?othersActions ?act (and tabledAgreementActions ?name ?agent ?actions\ notInferred = ?agent self\ includes ?actions ?act)\ notEmpty ?myActions\ notEmpty ?othersActions\ asPrintedList ?myActionsString ?myActions\ asPrintedList ?othersActionsString ?othersActionsOreport self ": I agree to " ?myActionsString " if others " ?othersActionsString report that agree - conditional do actions doneBy ?agent ?action0every negotiationCycle (perceivedAction ?action)Xperceive actionsW and notInferred (and linkCondition ?link ?clause\ ?clause\ linkStart ?link ?start\ last actionCycle (currentlyHolds ?start))\ last actionCycle (currentlyHolds ?end)*every negotiationCycle (nextWillHold ?end)and
notInferred
(and
linkCondition ?link ?clause\
?clause\
linkStart ?link ?start\
last actionCycle (currentlyHolds ?start))\
last actionCycle (currentlyHolds ?end)\

Not needed because of the prevalence of the nullActionX no actionsW and linkSign ?link true\ currentlyHolds ?start\ linkStart ?link ?start\ linkCondition ?link ?clause\ ?clause\ linkEnd ?link ?end\ notInferred (and linkSign ?anotherLink false\ currentlyHolds ?anotherStart\ linkStart ?anotherLink ?anotherStart\ linkCondition ?anotherLink ?anotherClause\ ?anotherClause\ linkEnd ?anotherLink ?end)\ associatedText ?end standard ?endText\ (if notEmpty ?endText\ = ?rep ?endText\ = ?rep ?end)/and every negotiationCycle (nextWillHold ?end)VnullAction will ensure that states persist unless this is blocked with a negative linkXeffect of actionsWreport 6if nextWillHold ?state\ true\ currentlyHolds ?state,report "(State of " self ") is: " ?state "."f final statee carry over Qand notInferred perceivedAction ?action\ last actionCycle (triedChain ?chain)*every negotiationCycle (triedChain ?chain)l haveTriedk &last actionCycle (nextWillHold ?state).every negotiationCycle (currentlyHolds ?state)l}k initialise falseevery actionCycle (and possibleAction ?state ?action\ associatedText ?action standard "The null action"\ perceivedAction ?action)Xand
myState ?state\
namedInstance ?action Action "nullAction"\uactions - null actiont and = ?inintNumSteps 2+every actionCycle (numSteps ?inintNumSteps)uparamst falseevery actionCycle (and link ?link\ linkStart ?link ?state\ linkCondition ?link ?actionCondition\ linkEnd ?link ?state\ associatedText ?link standard ?linkDescr\ linkSign ?link true) and
myState ?state\
= ?linkDescr "null link"\
= ?actionConditionList "nullAction"\
generatedInstance ?link Link [?state ?actionConditionList ?state ?linkDescr]\
parseCondition ?actionCondition ?actionConditionList\ulinks - null actiont and negotiatorInfo self ?indicatorInfo ?indicatorExpressionString ?nodeInfo\ parseValuationExpressionString ?clause ?indicatorExpressionString4every actionCycle (stateValuationExpression ?clause)uindicator expressiont and negotiatorInfo self ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?nodeInfo [?stateStr ?desc ?indicatorValues ?actionInfo ?linkInfo]\ cleanUp ?cleanedStateStr ?stateStr\ namedInstance ?state State ?cleanedStateStr\ includes ?actionInfo [?actionStr ?actionDescrStr]\ cleanUp ?cleanedActionStr ?actionStr\ cleanUp ?cleanedActionDescrStr ?actionDescrStr\ namedInstance ?action Action ?cleanedActionStroevery actionCycle (and possibleAction ?state ?action\ associatedText ?action standard ?cleanedActionDescrStr)uactionst and negotiatorInfo self ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?nodeInfo [?stateStr ?desc ?indicatorValues ?actionInfo ?linkInfo]\ cleanUp ?cleanedStateStr ?stateStr\ namedInstance ?state State ?cleanedStateStr\ includes ?linkInfo [?actionConditionList ?destinationStr ?linkDescr]\ cleanUp ?cleanedDestinationStr ?destinationStr\ (if = [<-> | ?rootDestinationStr] ?cleanedDestinationStr\ = ?sign false\ (and = ?rootDestinationStr ?cleanedDestinationStr\ = ?sign true))\ namedInstance ?destination State ?rootDestinationStr\ generatedInstance ?link Link [?state ?actionConditionList ?destination ?linkDescr]\ parseCondition ?actionCondition ?actionConditionListevery actionCycle (and link ?link\ linkStart ?link ?state\ linkCondition ?link ?actionCondition\ linkEnd ?link ?destination\ associatedText ?link standard ?linkDescr\ linkSign ?link ?sign)ulinkst and negotiatorInfo self ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?nodeInfo [?stateStr ?desc ?indicatorValues ?actionInfo ?linkInfo]\ cleanUp ?cleanedStateStr ?stateStr\ cleanUp ?cleanedDesc ?desc\ namedInstance ?state State ?cleanedStateStr\ includes ?indicatorValues [?indicatorStr ?valueStr]\ namedInstance ?indicator Indicator ?indicatorStr\ parsed ?valueStr ?valueevery actionCycle (and myState ?state\ associatedText ?state standard ?cleanedDesc\ stateValuation ?state ?indicator ?value)ustates and indicatorst and negotiatorInfo self ?indicatorInfo ?indicatorExpression ?nodeInfo\ includes ?indicatorInfo [?indicatorStr ?weightStr]\ namedInstance ?indicator Indicator ?indicatorStr\ parsed ?weightStr ?weight9every actionCycle (indicatorWeighting ?indicator ?weight)uindicator weightst  ]5[  5R 7% &` [and linkCondition ?link ?cond\ actionsInCondition ?positiveActions ?negativeActions ?cond$linkToActions ?positiveActions ?link Ø3  GroundClause5- 5X ]5 ]5 5+  5\ 5  5Y 5} %S#%& and greater ?n 0\ is ?nMinus ?n - 1\ sortedList ?nextStates ?st (and linkStart ?link ?fromState\ linkEnd ?link ?nextState\ statesReachableInNSteps ?nextListOfStates ?nextState ?nMinus\ includes ?nextListOfStates ?st)@statesReachableInNSteps [?fromState | ?nextStates] ?fromState ?n ç/ true3statesReachableInNSteps [?startState] ?startState 0 ê+ 3statesReachableInNSteps ?lsitOfStates ?startState 11statesReachableInNSteps ?lsitOfStates ?startState ê3 soleBoolean 5E %5> 5P $]5 5Z %#%]&_ total ?total ?weightedValue and indicatorWeighting ?indicator ?weight\ stateValuation ?state ?indicator ?value\ is ?weightedValue ?value * ?weightBvalueStateExpression ?total ?state sumOfAllWeightedIndicatorValues ùX yand stateValuation ?state ?indicator ?value\ indicatorWeighting ?indicator ?weight\ is ?weightedValue ?value * ?weightNvalueStateExpression ?weightedValue ?state (weightedIndicatorValue ?indicator) ü> and notInferred isKindOf ?clause Number\ clauseList ?clause randomOneOf [?arg1]\ valueStateExpression ?list ?state ?arg1\ randomList [?value | ?rest] ?val (wrt [run actionCycle negotiationCycle] ?state ?clause ?list) includes ?list ?val*valueStateExpression ?value ?state ?clause ü4 and notInferred isKindOf ?clause Number\ clauseList ?clause totalOf [?arg1]\ valueStateExpression ?list ?state ?arg1\ total ?value ?val includes ?list ?val*valueStateExpression ?value ?state ?clause üh and notInferred isKindOf ?clause Number\ clauseList ?clause averageOf [?arg1]\ valueStateExpression ?list ?state ?arg1\ average ?value ?val includes ?list ?val*valueStateExpression ?value ?state ?clause ü- and notInferred isKindOf ?clause Number\ clauseList ?clause maxOf [?arg1]\ valueStateExpression ?list ?state ?arg1\ maxValue ?value ?val includes ?list ?val*valueStateExpression ?value ?state ?clause ü( and notInferred isKindOf ?clause Number\ clauseList ?clause minOf [?arg1]\ valueStateExpression ?list ?state ?arg1\ minValue ?value ?val includes ?list ?val*valueStateExpression ?value ?state ?clause ü 7and notInferred isKindOf ?clause Number\ clauseList ?clause accessibleStateInOneStep [?arg1]\ statesReachableInNSteps ?listOfStates ?state 1\ sortedList ?pairList ?pair (and includes ?listOfStates ?st\ valueStateExpression ?val ?st ?arg1\ = ?pair [?st ?val])\ mappedList ?list ?pairList second)valueStateExpression ?list ?state ?clause üaccessibleStateInOneSteps rand notInferred isKindOf ?clause Number\ clauseList ?clause accessibleStateInNSteps [?arg2 ?arg1]\ valueStateExpression ?numSteps ?state ?arg1\ statesReachableInNSteps ?listOfStates ?state ?numSteps\ sortedList ?pairList ?pair (and includes ?listOfStates ?st\ valueStateExpression ?val ?st ?arg2\ = ?pair [?st ?val])\ mappedList ?list ?pairList second)valueStateExpression ?list ?state ?clause ü{ 'stateValuation ?state ?indicator ?value>valueStateExpression ?value ?state (indicatorValue ?indicator) ü and notInferred isKindOf ?clause Number\ clauseList ?clause sum ?argList\ total ?value ?summand (and includes ?argList ?arg\ valueStateExpression ?summand ?state ?arg)*valueStateExpression ?value ?state ?clause üsum and notInferred isKindOf ?clause Number\ clauseList ?clause multiply [?arg1 ?arg2]\ valueStateExpression ?res1 ?state ?arg1\ valueStateExpression ?res2 ?state ?arg2\ multiply ?value ?res1 ?res2*valueStateExpression ?value ?state ?clause ü multiply /and isKindOf ?clause Number\ = ?value ?clause*valueStateExpression ?value ?state ?clause üS % &t sand clauseList ?clause ?and ?argList\ includes ?argList ?subClause\ negativeActionInCondition ?action ?subClause)negativeActionInCondition ?action ?clause and trueHnegativeActionInCondition ?action (notInferred perceivedAction ?action) negative action ò 5C # ## conditionalOffer ?conditionActionList ?myOfferedActionList

means
I will do ?myOfferedActionList if others do ?conditionActionList5x %& total ?total ?weightedVal and stateValuation ?state ?indicator ?val\ indicatorWeighting ?indicator ?weight\ is ?weightedVal ?val * ?weightvalueState ?total ?state&Temporary until proper goals! by weights Ý5 Ý5h 5 %5 Ý54 5 % &H and chainLinks ?chain ?linkList\ mappedList ?actionSetList ?linkList linkToActions\ flattened ?flatList ?actionSetList\ withoutDuplicates ?actionList ?flatList\ length ?actionList ?lencalcChainLength ?len ?chain 3 %The clause is true if the subclause was true at the previous time (at the specified time level, or the lowest one if that argument is omitted).

The first argument can be an uninstantiated variables, in which case the subclause is evaluated at all possible time levels for which a previous time exists. Otherwise the subclause is evaluated for a single stage determined from the time level (if such a stage has been simulated).& Vif time negotiationCycle 1\ last actionCycle ?clause\ last negotiationCycle ?clauseprevious ?clause 3  5;  5 Ý5( Ý%7& Xand mappedList ?clauseArgs ?argList parseCondition\ clauseList ?clause and ?clauseArgs'parseCondition ?clause [and | ?argList] Qand parseCondition ?clauseArg ?arg\ clauseList ?clause notInferred [?clauseArg]!parseCondition ?clause [not ?arg] not rand isKindOf ?string String\ namedInstance ?action Action ?string\ clauseList ?clause perceivedAction [?action]parseCondition ?clause ?string R  5 ]5 òS5 %S7&b falsefindPossibleChain ?chain 0GTo be done depending on previous offered chains! end of offered chain Oand greater ?n 0\ is ?nMinus ?n - 1\ findPossibleChain ?chainSoFar ?nMinus\ reversed ?revChainSoFar ?chainSoFar\ (if = ?revChainSoFar []\ currentlyHolds ?reachedState\ (and = [?lastLink | ?rest] ?revChainSoFar\ linkEnd ?lastLink ?reachedState))\ linkStart ?link ?reachedState\ appended ?nextChain ?chainSoFar [?link]findPossibleChain ?nextChain ?n recurse one step currentlyHolds ?statefindPossibleChain [] 0 currently Holds Hand greater ?n 0\ is ?nMinus ?n - 1\ findPossibleChain ?chain ?nMinusfindPossibleChain ?chain ?n plus smaller ones  5  5chainOriginator 5d 75T SÝ5{ # %# &a and sortedList ?positiveActions ?positiveAction positiveActionInCondition ?positiveAction ?clause\ sortedList ?negativeActions ?negativeAction negativeActionInCondition ?negativeAction ?clauseR 7 5o 77&s false/findAgreementSet ?agentActionList ?endStateList D3 #75n  51: negotiation14.1W;$brucebruce@cfpm.org?Centre for Policy Modelling, Manchester Metropolitan Universityv :K24.1t1bruceb.edmonds@mmu.ac.uk?Centre for Policy Modelling, Manchester Metropolitan Universityv g :K34.1vSTUvid :K44.1y)STUv:negonetLY}'STUu3:ZQY~2STUvvL:ZV4.1$)STUv0A: ZX4.193STUv : Z54.1.STUvh: Z64.1:STUvy8 : Z74.16NOPv_ : Z84.1$NOPvGT{:Z94.1STUvc$d:Z10f:STUv