// leader agent /* * By Joao Leite * Based on implementation developed by Rafael Bordini, Jomi Hubner and Maicon Zatelli */ /* quadrant allocation */ score(miner1,0). score(miner2,0). score(miner3,0). score(miner4,0). winning(leader,0). /* rules */ +dropped[source(A)] : score(A,S) & winning(L,SL) & S+1>SL <- -score(A,S); +score(A,S+1); -+winning(A,S+1); -dropped[source(A)]; .print("Agent ",A," is winning with ",S+1," pieces of gold"); .broadcast(tell,winning(A,S+1)). +dropped[source(A)] : score(A,S) <- -score(A,S); +score(A,S+1); -dropped[source(A)]; .print("Agent ",A," has dropped ",S+1," pieces of gold"). /* end of simulation plans */ @end[atomic] +end_of_simulation(S,_) : true <- .print("-- END ",S," --"); .abolish(init_pos(S,_,_)).