swarm-hackers
[Top][All Lists]
Advanced

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

Re: [swarm-hackers] A new (non-framework-related) problem...


From: Scott Christley
Subject: Re: [swarm-hackers] A new (non-framework-related) problem...
Date: Thu, 12 Nov 2009 18:48:58 -0800


You need to check if the *new* position is already occupied by another object, before you place the object there; your code isn't doing that.  Also, firstTime will never get set to false because the IF statement has the wrong _expression_, should probably be "if (firstTime)"

You should use YES and NO for the ObjC BOOL data type, TRUE and FALSE are probably ok, but I'm not sure how they are defined, as far as I know they are not defined by the ObjC runtime.

Scott

On Nov 12, 2009, at 5:58 PM, Nima Talebi wrote:

I'm getting a continuous stream of warnings like this in my vastly modified version of heatbugs (as part of a learning process for myself, and working towards deciding what to do for my thesis next semester)...

...
Grid2d: you're overwriting object 26c128 at (82,45) with object 0x26ebc8 (Heatbug).
Grid2d does not support two objects in one place.
*** execution continuing...
*** event raised for warning: WarningMessage
Grid2d: you're overwriting object 26e4d8 at (62,78) with object 0x270208 (Heatbug).
Grid2d does not support two objects in one place.
*** execution continuing...
*** event raised for warning: WarningMessage
Grid2d: you're overwriting object 274b48 at (112,2) with object 0x273a68 (Heatbug).
Grid2d does not support two objects in one place.
*** execution continuing...
*** event raised for warning: WarningMessage
Grid2d: you're overwriting object 2375f8 at (57,14) with object 0x26e668 (Heatbug).
....


I have assert statements prior to every single move that a heatbug makes...

- (void)setX:(int)inX andY:(int)inY {
    static BOOL firstTime = TRUE;
    if((inX != [self x]) && (inY != [self y])) {
        // Update heat where we were sitting.
        [heatSpace addHeat:[self outputHeat] X:[self x] Y:[self y]];
       
        NSString *s = [NSString stringWithFormat:@"Found agent %@ here, expected %@ (self)",
                       [world getObjectAtX:[self x] Y:[self y]], self];

        if(!firstTime) {
            NSAssert([world getObjectAtX:[self x] Y:[self y]] == self, s);
        }   
        [world putObject:nil atX:[self x] Y:[self y]];
       
        // And where we're going...
        x = inX;
        y = inY;
        if(!firstTime) {
            NSAssert([world getObjectAtX:[self x] Y:[self y]] == nil, @"shit 2");
            firstTime = FALSE;
        }   
        [world putObject:self atX:[self x] Y:[self y]];
    }   
}



...These never get triggered, so as far as I can tell, the -setX:andY: will only ever work, iff the new position is vacant.  If that is the case however, why am I getting these warnings?

Note: the reason for firstTime is because the initial positioning of the heatbugs from [HeatbugsModel -buildObjects] does no checking for double occupancy.


--
Nima Talebi
web: http://ai.autonomy.net.au/People/Nima
gpg: B51D 1F18 D8E2 B702 B027 23A4 E06B DAC1 BE70 ADC0
_______________________________________________
swarm-hackers mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/swarm-hackers


reply via email to

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