-
Notifications
You must be signed in to change notification settings - Fork 0
Velluscinum JaCaMo Chef and Glutton
Velluscinum for JaCaMo | Wiki |
---|
To install JaCaMo-CLI on your computer, see the APT Package for JaCaMo CLI
jacamo app create chefBankGlutton
-
Edit the project file chefBankGlutton/chefBankGlutton.jcm as below:
mas chefBankGlutton { agent bank agent chef agent glutton uses package: velluscinum "com.github.chon-group:Velluscinum:+" }
-
Create the file chefBankGlutton/src/agt/bank.asl with the content below:
Agent bank content file
// Agent bank in project chefBankGlutton /* Initial beliefs and rules */ chainServer("http://testchain.chon.group:9984/"). /* Initial goals */ !createCoin. /* Plans */ +!createCoin :chainServer(Server) <- .print("Creating digital wallet"); .velluscinum.buildWallet(myWallet); .wait(myWallet(PrK,PuK)); .print("Creating and sharing a cryptocurrency"); .velluscinum.deployToken(Server,PrK,PuK,"name:ChainCoin",200,chainCoin); .wait(chainCoin(Coin)); .broadcast(tell,cryptocurrency(Coin)); .broadcast(tell,bankWallet(PuK)); .broadcast(tell,chainServer(Server)); . +!lending(ResquestNumber,ClientWallet,Value)[source(Client)] : chainCoin(Coin) & myWallet(Prk,PuB) & chainServer(Server) <- .print("Hello Agent ",Client,", Wellcome to BanChain! - Please wait while we check the transaction."); .velluscinum.stampTransaction(Server,Prk,PuB,ResquestNumber,loan(Client)); .velluscinum.transferToken(Server,Prk,PuB,Coin,ClientWallet,Value,transactionTransfer); .send(Client,tell,bankAccount(ok)); .
-
Create the file chefBankGlutton/src/agt/chef.asl with the below:
Agent chef content file
// Agent chef in project chefBankGlutton /* Initial beliefs and rules */ lastOrder(0). /* Initial goals */ !createWallet. /* Plans */ +!createWallet <- .print("Creating a digital wallet!"); .velluscinum.buildWallet(myWallet); .wait(myWallet(Priv,Pub)); +chefWallet(Pub); . +!order(Product,Qtd,Payment)[source(Client)]: cryptocurrency(Coin) & chainServer(Server) & myWallet(MyPriv,MyPub) <- ?lastOrder(N); OrderNr=N+1; -+lastOrder(OrderNr); .print("Received the order",OrderNr," ckecking payment..."); .velluscinum.stampTransaction(Server,MyPriv,MyPub,Payment,payment(OrderNr)); +preparingOrder; !cooking(OrderNr,Product,Qtd,Client); -preparingOrder; . +!cooking(OrderNr,Product,Qtd,Client) <- .print("Preparing order Nr ",OrderNr); .wait(1000); .send(Client,tell,delivering(Product,Qtd)); .
-
Create the file chefBankGlutton/src/agt/glutton.asl with the content below:
Agent glutton content file
// Agent glutton in project chefBankGlutton /* Initial beliefs and rules */ foodStock(10). energy(0). /* Initial goals */ !enjoy. /* Plans */ +!requestLend: cryptocurrency(Coin) & bankWallet(BankW) & chainServer(Server) & myWallet(MyPriv,MyPub)<- .print("Requesting Lend"); .velluscinum.deployNFT(Server,MyPriv,MyPub, "name:comilao;address:5362fe5e-aaf1-43e6-9643-7ab094836ff4", "description:Createing Bank Account", account); .wait(account(AssetID)); .velluscinum.transferNFT(Server,MyPriv,MyPub,AssetID,BankW, "description:requesting lend;value_chainCoin:10",requestID); .wait(requestID(PP)); .print("Lend Contract nr:",PP); .send(bank,achieve,lending(PP,MyPub,10)). +!eat: hungry & foodStock(C) & C>3 & energy(E) & E<=10 <- -+foodStock(C-3); -+energy(E+3); .print("Eating........ [Fridge=",C-3,"] [Energy=",E+3,"]"); .wait(1000); !eat. +!eat: energy(E) & E>10 <- .print("Satisfied...... [Energy=",E,"]"); -hungry; !enjoy. +!eat <- ?foodStock(X); .print("I need food..... [Fridge=",X,"]"); .wait(1000); !orderFood. +!enjoy: energy(E) & E>5 <- .print("Enjoying...."); .wait(1000); -+energy(E-3); -hungry; !enjoy. +!enjoy: energy(E) & E<=5<- .print("Tired..... [Energy=",E,"]"); +hungry; !eat. +!orderFood: bankAccount(ok)[source(bank)] & cryptocurrency(Coin) & chainServer(Server) & myWallet(MyPriv,MyPub) & chefWallet(Chef)<- .print("Ordering food....."); .velluscinum.transferToken(Server,MyPriv,MyPub,Coin,Chef,5,payment); .wait(payment(Transfer)); .send(chef,achieve,order(pizza,5,Transfer)); .wait(5000); !eat. +!orderFood: not bankAccount(ok)[source(bank)] <- .wait(5000); .velluscinum.buildWallet(myWallet); !requestLend; .wait(5000); .send(chef,askOne,chefWallet(Chef),Reply); +Reply; !orderFood. -!orderFood: cryptocurrency(Coin) & chainServer(Server) & myWallet(MyPriv,MyPub) <- .velluscinum.tokenBalance(Server,MyPriv,MyPub,Coin,balance). +delivering(Product,Qtd)[source(Chef)] <- ?foodStock(X); -+foodStock(X+Qtd); .print("Wow! Pizza!!!!"); -delivering(Product,Qtd)[source(Chef)]. +balance(T,V)[source(self)]: cryptocurrency(Coin)[source(bank)] & V<5 & Coin==T <- .drop_desire(enjoy); .print("I don't have money! :("); .wait(5000).
jacamo chefBankGlutton/chefBankGlutton.jcm
Velluscinum is licensed under a Creative Commons Attribution 4.0 International License. The licensor cannot revoke these freedoms as long as you follow the license terms:
- Attribution — You must give appropriate credit like below:
Mori Lazarin, N., Machado Coelho, I., Pantoja, C.E., Viterbo, J. (2023). Velluscinum: A Middleware for Using Digital Assets in Multi-agent Systems. In: Mathieu, P., Dignum, F., Novais, P., De la Prieta, F. (eds) Advances in Practical Applications of Agents, Multi-Agent Systems, and Cognitive Mimetics. The PAAMS Collection. PAAMS 2023. Lecture Notes in Computer Science(), vol 13955. Springer, Cham. DOI: https://doi.org/10.1007/978-3-031-37616-0_17
Cite using Bibtex
@InProceedings{velluscinum,
author="Mori Lazarin, Nilson
and Machado Coelho, Igor
and Pantoja, Carlos Eduardo
and Viterbo, Jos{\'e}",
editor="Mathieu, Philippe
and Dignum, Frank
and Novais, Paulo
and De la Prieta, Fernando",
title="{Velluscinum: A Middleware for Using Digital Assets in Multi-agent Systems}",
doi="10.1007/978-3-031-37616-0_17",
booktitle="Advances in Practical Applications of Agents, Multi-Agent Systems, and Cognitive Mimetics. The PAAMS Collection",
year="2023",
publisher="Springer Nature Switzerland",
address="Cham",
pages="200--212",
isbn="978-3-031-37616-0"
}