metametascape
Welcome, Guest
Please Login or Register.
Lost Password?
Re:Rules Generation (1 viewing)
_GEN_GOTOBOTTOM Post Reply

TOPIC: Re:Rules Generation

#67
ecasotti (User)
Expert Boarder
Posts: 38
graphgraph
Rules Generation 2008/01/17 16:56 Karma: 0  
I am trying to create a rule where the first item is to create agents.
The agent is a Building, the rule is on Terrain. I also tried this
with initialize. The generated code for Ascape is as follows:

public void terrainRule() {
Building createAgentsCopy =
(Building) getOneBuilding().getBuilding().getSpace()
.newLocation(false);


}

Is this correct? It seems like it should be something like

public void terrainRule() {
Building createAgentsCopy =
(Building) getOneBuilding().getBuilding().newAgent();

}
  The administrator has disabled public write access.
#68
ecasotti (User)
Expert Boarder
Posts: 38
graphgraph
Re:Rules Generation 2008/01/17 20:23 Karma: 0  
I would like to further elaborate on this problem. Also let me add that I believe
the problem is not limited to Create Agents, but that there also is a problem with
Spacial:Available.

I will include my .metaabm file, and you can see the rules on the Terrain agent.

I had to modify the generated code to be the following:

public void placeCellOccupant() {
if (isBuilding()) {
boolean placeCellOccupantAvailable = isAvailable();

if (placeCellOccupantAvailable == true) {
Building createBuilding =
(Building) getOneBuilding().getBuilding().getSpace()
.newLocation(false);

createBuilding.moveTo(this);

}
}
}

I left the create space generated code alone, and my building appears fine
so again, I could be wrong there. It just *seems* wrong but likely I am wrong.
But the code that I changed above generates available() not isAvailable().

ev
File Attachment:
File name: OneBuilding.txt
File size:18853 bytes
  The administrator has disabled public write access.
#78
miles (Admin)
Admin
Posts: 59
graph
Re:Rules Generation 2008/01/21 03:38 Karma: 1  
Actually the two do pretty much the same thing, newLocation is just more generalized.

ecasotti wrote:

public void terrainRule() {
Building createAgentsCopy =
(Building) getOneBuilding().getBuilding().newAgent();

}
  The administrator has disabled public write access.
#79
miles (Admin)
Admin
Posts: 59
graph
Re:Rules Generation 2008/01/21 03:42 Karma: 1  
Thanks -- I looked at the code, and the first thing is that there is a bug that comes from a somewhat unanticipated usage..that is having a cell check wether it was itself available! There are some other issues that are causing problems though, for example you have evaluations where you really need queries. But I think I understand what you want to do, and it is a totally reasonable thing to want to do, but this may not be the best way to do it. I'll need to work up an example and any necessary fixes. In the meantime this is probably a job for Method.
  The administrator has disabled public write access.
#81
ecasotti (User)
Expert Boarder
Posts: 38
graphgraph
Re:Rules Generation 2008/01/21 12:58 Karma: 0  
Miles

The reason I did it as an evaluation was the query wasn't working
how I expected. Not that it isn't working as you expect, but if
I did just a simple Available query, and did not and it with anything
else, it looks for a random available cell, it does not query if *this*
is available.

I was looking if *this* is available when within the scope of the
agent that fills the grid, and initializing the grid with agents
that are not moving (i.e. buildings, etc).

Likely there is a better way than what I was doing, but it works for me.
  The administrator has disabled public write access.
#84
miles (Admin)
Admin
Posts: 59
graph
Re:Rules Generation 2008/01/21 14:32 Karma: 1  
Right - tbat is what I was trying to say. When you attempt to check for available *and* you are doing so within a host cell rule w/o another select, it doesn't work as expected. That's a bug, though it was clever to do the eval and check for equivalence!
  The administrator has disabled public write access.
_GEN_GOTOTOP Post Reply
© Copyright 2007 Best of Joomla, Powered by FireBoardget the latest posts directly to your desktop