Skip to content

Commit

Permalink
up cnp example
Browse files Browse the repository at this point in the history
  • Loading branch information
jomifred committed Oct 7, 2024
1 parent 1e20c56 commit eb9e6bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 7 additions & 6 deletions examples/contract-net-protocol-er/c.asl
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/* Initial beliefs and rules */

all_proposals_received(CNPId, NP) // NP: number of participants
:- .count(propose(CNPId,_)[source(_)], NO) & // NO: number of proposes received
.count(refuse(CNPId)[source(_)], NR) & // NR: number of refusals received
NP = NO + NR.

/* Initial goals */

Expand Down Expand Up @@ -45,3 +39,10 @@ all_proposals_received(CNPId, NP) // NP: number of participants
}
}.
}

/* Initial beliefs and rules */

all_proposals_received(CNPId, NP) // NP: number of participants
:- .count(propose(CNPId,_)[source(_)], NO) & // NO: number of proposes received
.count(refuse(CNPId)[source(_)], NR) & // NR: number of refusals received
NP = NO + NR.
14 changes: 7 additions & 7 deletions examples/contract-net-protocol-er/c_alt.asl
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
// alternative implementation without .wait(<condition>), see plan for !bid

/* Initial beliefs and rules */

all_proposals_received(CNPId, NP) // NP: number of participants
:- .count(propose(CNPId,_)[source(_)], NO) & // NO: number of proposes received
.count(refuse(CNPId)[source(_)], NR) & // NR: number of refusals received
NP = NO + NR.

/* Initial goals */

!run.
Expand Down Expand Up @@ -54,3 +47,10 @@ all_proposals_received(CNPId, NP) // NP: number of participants
.send(Ag,tell,reject_proposal(Id));
}.
}

/* Initial beliefs and rules */

all_proposals_received(CNPId, NP) // NP: number of participants
:- .count(propose(CNPId,_)[source(_)], NO) & // NO: number of proposes received
.count(refuse(CNPId)[source(_)], NR) & // NR: number of refusals received
NP = NO + NR.

0 comments on commit eb9e6bc

Please sign in to comment.