Skip to main content
. 2024 Mar 8;24(6):1764. doi: 10.3390/s24061764
Algorithm 1 Agent logic to determine an answer to a proposition query

  Input: Information about other agents (proposals, group organization)

  Output: Proposal determined via the algorithm—unchanged or adapted range

  •   1:

    function determineAnswer(peerInfo[])

  •   2:

                              ▹ Compare range overlapping

  •   3:

         lowestOverlapAgents[]←findLowestOverlap(peerInfo[])

  •   4:

         if lowestOverlapAgents[].containsOnly(thisAgent) then

  •   5:

            return newRangeCalculation()               ▹ Agent concedes

  •   6:

         end if

  •   7:

                                 ▹ Compare flexibility rank

  •   8:

         higherFFactorAgent←thisAgent

  •   9:

         sameGroupAgents[]←[]

  • 10:

       for  agentOther in lowestOverlapAgents[] do

  • 11:

            if agentOther.group>thisAgent.group then

  • 12:

               return currentProposal            ▹ Agent does not concede

  • 13:

            else if agentOther.group=thisAgent.group then

  • 14:

               sameGroupAgents.append(agentOther)

  • 15:

            end if

  • 16:

       end for

  • 17:

       if higherFFactorAgent=thisAgent and sameGroupAgents.size()=0 then

  • 18:

            return newRangeCalculation()             ▹ Agent concedes

  • 19:

       end if

  • 20:

                      ▹ Compare distance to next achievable overlap

  • 21:

       mostDistanceAgent←thisAgent

  • 22:

       tieAgents[]←[]

  • 23:

       for  agentOther in sameGroupAgents[] do

  • 24:

            distanceComparison←compareDistanceSum(thisAgent,agentOther)

  • 25:

            if distanceComparison=1 then

  • 26:

               mostDistanceAgent←agentOther

  • 27:

               return currentProposal            ▹ Agent does not concede

  • 28:

            else if distanceComparison=0 then

  • 29:

               tieAgents.append(agentOther)

  • 30:

            end if

  • 31:

       end for

  • 32:

       if len(tieAgents)=0 and mostDistanceAgent=thisAgent then

  • 33:

            return newRangeCalculation()             ▹ Agent concedes

  • 34:

       end if

  • 35:

            ▹ Tie scenario (often in a 1 on 1 situation): compare concession count

  • 36:

       for agentOther in tieAgents[] do

  • 37:

            if thisAgent.roundConcessions>agentOther.roundConcessions then

  • 38:

               return currentProposal            ▹ Agent does not concede

  • 39:

            end if

  • 40:

       end for

  • 41:

       return currentProposal              ▹ Agent does not concede

  • 42:

    end function