swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Selectors


From: Marcello
Subject: Re: [Swarm-Support] Selectors
Date: 09 Jul 2003 16:56:25 +0200

Simplest route sounds good (I thought forEach was faster!) . thanks
I take it as your code is equivalent to this:

id  index=[list begin:[self getZone]]
           while ((tgt=[index next])) [tgt setPayoff: pay];
   [index drop];

Am I right?
cheers
marcello

On Wed, 2003-07-09 at 16:31, Paul Johnson wrote:
> This is a "wrapper" problem. The only valid type of variable in forEach: 
> is an id or pointer. Some people cast integers as pointers to do this 
> kind of thing, but floats are a no-go as far as I understand.  I think 
> in the User Guide's discussion of scheduling it talks about creating 
> wrapper objects to pass variables to and fro. FOr example, you could 
> create a class SwarmFloat, set a value in there, and pass it through the 
> way you want.
> 
> But please just consider taking the simple, direct route: iterate over 
> your list.
> 
> id <Index> index = [list begin: [self getZone]];
> id anObj;
> for (anObj = [index next]; [index getLoc]==Member; anObj = [index next])
> {
>       [anObj setPayoff: pay];
> }
> 
> Marcello wrote:
> > Pardon me the frequency of my questions!
> > 
> > I have a method in a class Agent:
> > 
> > - setPayoff: (float) p {
> > 
> > payoff=p;
> > 
> > return self;
> > }
> > 
> > Now, in another class, I have a List of Agent called "group". I'd like
> > to pass through the list and set the payoff as follows:
> > float pay=10.1;
> > [group forEach: M(setPayoff:): pay ];
> > 
> > If I do that, I get
> > gcc: incompatible type for argument 4 of indirect function call
> > 
> > if I set
> > [group forEach: M(setPayoff:): (id) pay ];
> > id does not work either,
> > 
> > it only works if :
> > [group forEach: M(setPayoff:): (int) pay ];
> > 
> > but then pay is always zero.
> > 
> > Any help?
> > thanks
> > marcello
> 
> 
> -- 
> Paul E. Johnson                       email: address@hidden
> Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
> University of Kansas                  Office: (785) 864-9086
> Lawrence, Kansas 66045                FAX: (785) 864-5700
> 
> _______________________________________________
> Support mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/support
-- 
Marcello Gallucci (Ph.D)
Department of Social Psychology
Free University
Van der Boechorststraat 1
1081 BT Amsterdam (NL)
Tel. +31(0)20 4448846
Fax  +31 (0)20 4448921


reply via email to

[Prev in Thread] Current Thread [Next in Thread]