// This behaviour regularly increases the buying price. TickerBehaviour adjustPriceBehaviour = ...; // This method returns true if the ISBN is the one of the book to buy and the price // is acceptable. boolean isAcceptable(Constant isbn, Constant price) {...} class PriceProposalSIP extends ApplicationSpecificSIPAdapter { public PriceProposalSIP() { super(BookBuyerCapabilities.this, "(B ??myself (selling_price ??isbn ??price ??seller))"); } protected ArrayList doApply(MatchResult applyResult, ArrayList result, SemanticRepresentation sr) { final Constant isbn = (Constant)applyResult.term("isbn"); final Constant price = (Constant)applyResult.term("price"); if (isAcceptable(isbn, price)) { try { result.add(new SemanticRepresentation((Formula) SLPatternManip.instantiate(I_DONE_SELL_ACTION, "actor", applyResult.term("seller"), "isbn", isbn, "price", price, "buyer", getAgentName()))), } catch(Exception e) {e.printStackTrace();} // After committing to buy the book, the SIP becomes useless mySemanticInterpretationTable.removeSemanticInterpretationPrinciple(this); } return result; } }