From: Gulyas L. <gu...@om...> - 2003-01-30 17:36:11
|
Hi Trushar, I think, I've replicated your problem and then solved it. (I was using the version of your project I fixed last time.) The problem seems to be that your GameSpace extends Diffuse2D. Are you sure you want your values to change on their own? In any case, replacing that wirh Object2DTorus solved the problem. I hope this helps. Gulya On Thu, 30 Jan 2003, Trushar Panchal wrote: > Hi Gulyas, > > I have a graph which will tell me and also I count if I encounter a value > from the getValueAgent1 and getValueAgent2 and when I implement that both > agent works through every 400 cells only once I encounter that there are > only 101 non-zero cells. Not sure why. Also I print the values it put as > well which is also upto 101. > > I have also tried the Boolean type for steady and it is working fine as well > but still a bit of confusion on the non-zero values. I tried 50% of > non-zeros but still it won't fill up 200 cells it will do beyond 200 cells. > > Trushar > > -----Original Message----- > From: Gulyas Laszlo [mailto:gu...@om...] > Sent: 30 January 2003 16:19 > To: Trushar Panchal > Subject: RE: [Repast-interest] Grid issue with value display in space > > On Thu, 30 Jan 2003, Trushar Panchal wrote: > > > Hi Gulyas, > > > > My meaning of count here is when I place 30% random values (between 1-10) > I > > am trying to see if there are actually 30% or 120 non-zero values on the > > grid. Which is not the case but there are 101 non-zero values on the grid > > almost all the times. I am keeping the random seed constant so this value > > will be constant. But some changes in the code will change the values and > it > > will be near to 107 but haven't seen 120 non-zero values. So I am not sure > > why it is not doing what I intend to do. > > OK, my question was how do you _know_ that there are only 101-107 non-zero > values? And the meaning of it is that the value 1 might show up as > (almost) black. So you won't see... > > > > > In theory and on paper the code works fine but in practise it is not > > working. I tried as you suggested putting the code in Model class which > gave > > me exactly the same result. > > As it should. > > > > > Also I have started working on my simulation which is further more a step > > where I want to engage both the agent to talk or engage in a game. I want > > that once randomly moving if the agent finds a non-zero cell it will stop > at > > that cell and with the help of the value it is on the cell it will > calculate > > its perception. As I have made agents with different perception I want > them > > to agree on perception. So in order to do this I want randomly one agent > > remains steady at that position and other agent moves towards the steady > > agent with an algorithm I have made for coming closer. Once on the same > cell > > they will calculate the perception which will be different as both are > > different. You can think of one agent has normal eyesight and other is > > colour blind and cannot see red green blue. So they will not agree on > > perception on that cell where they are together. So they start roaming > again > > from the last place they found the non-zero value and do this process > again > > and again. > > > > My question here is if in schedule I am putting things in a step. I am not > > able to get the result I am willing to get. Means the methods that are in > > the schedule will be executed every time or every tick so how is it > possible > > to keep the agent steady at one place during the time when the other agent > > is coming closer to itself. > > You could have a agent variable 'isSteady' (a boolean) and > your step() method could look like the following w.r.t. moving: > > step() { > > if (!isSteady) { > move(); > } > } > > It is vital for me to display the movements of > > the agents on the display as well. I am not able to get around this idea > how > > to do this or a way to schedule this behaviour. > > > > Any suggestion will be very much appreciated. > > > > I hope this helps. > > Gulya > > > > Thanks a lot Gulyas, > > > > Regards > > Trushar > > > > -----Original Message----- > > From: rep...@li... > > [mailto:rep...@li...] On Behalf Of Gulyas > > Laszlo > > Sent: 30 January 2003 12:35 > > To: Trushar Panchal > > Cc: Rep...@li... > > Subject: Re: [Repast-interest] Grid issue with value display in space > > > > Hi Trushar, > > > > What do you mean exactly when you say that you 'count' all the values? > > > > Gulya > > > > > > On Thu, 30 Jan 2003, Trushar Panchal > > wrote: > > > > > > > > > > > Hi Veterans, > > > > > > > > > > > > Back again with some questions. I am a bit confused if I am doing wrong > or > > > it's my code behaving badly. I am still playing around with the > simulation > > > eventually I am trying to make eventually. > > > > > > > > > > > > I did work out a way to put values on the grid of 20x20. Want to put 30% > > of > > > the all 400 values to be a value between 1-10 and remaining 70 % zeros. > > Also > > > got a solution from Gulyas regarding as well. I have implemented it but > > not > > > sure if the problem is with the loop or in the code. > > > > > > > > > > > > In my gameSpace.java where I am putting values on the space my code > looks > > > like this > > > > > > > > > > > > //first filling the grid with zeros > > > > > > for (int x=0; x<getSizeX(); x++) > > > > > > { > > > > > > for (int y=0; y<getSizeY(); y++) > > > > > > { > > > > > > putValueAt(x, y, 0); > > > > > > } > > > > > > } > > > > > > > > > > > > //now putting 400*0.3 which is 120 so it should > in > > > theory have a grid with 120 places filled with a value between 1-10 and > > > remaining 280 zeros > > > > > > //but unfortunately I am not able to get 120 it > is > > > only getting up to say 101 when I count all the values. Gulyas gave me > > this > > > idea > > > > > > for(int i=0; i<120; i++) > > > > > > { > > > > > > int val = > > > gridRandom.nextStaticIntFromTo(1, 10); > > > > > > > > > > > > int xval, yval; > > > > > > do > > > > > > { > > > > > > xval = > > > gridRandom.nextStaticIntFromTo(0, 19); > > > > > > yval = > > > gridRandom.nextStaticIntFromTo(0, 19); > > > > > > } > > > > > > while((int) getValueAt(xval, yval) > != > > > 0); > > > > > > putValueAt(xval, yval, (double) > val); > > > > > > } > > > > > > > > > > > > /* //this was my method initially where I was > putting > > > values randomly in the whole grid and then fill 70% with zeros. But I > > guess > > > it was a bad idea and > > > > > > //was implementing Gulyas recommendation. > > > > > > for (int i=0; i<((xSize*ySize)*0.7); i++) > > > > > > { > > > > > > do > > > > > > { > > > > > > valX = > > > gridRandom.nextIntFromTo(0, xSize-1); > > > > > > > > //System.out.println(valX); > > > > > > valY = > > > gridRandom.nextIntFromTo(0, ySize-1); > > > > > > > > //System.out.println(valY); > > > > > > //System.out.println(i); > > > > > > } > > > > > > while(getValueAt(valX, valY) != > 0.0); > > > > > > //if(getValueAt(valX, valY) == 0) > > > > > > putValueAt(valX, valY, > > > 0.0);//gridRandom.nextIntFromTo(1, 10)); > > > > > > //double val = getValueAt(valX, > valY); > > > > > > //System.out.println(val); > > > > > > } > > > > > > */ > > > > > > > > > > > > Is anyone is able to find out or spot out any problems with my code. I > > have > > > tried to even print lines on cmd and still I am not able to get the > right > > > no. of values on the grid. > > > > > > > > > > > > Thanks for having a look. > > > > > > Thanks > > > > > > Trushar > > > > > > > > > > > > -- -- Laszlo Gulyas las...@sz... AI Laboratory http://www.sztaki.hu/~gulyas/ Computer and Automation Research Inst. H-1111, Budapest, Kende u. 13-17. Hungarian Academy of Sciences * 36 1 209-6194 |