swarm-support
[Top][All Lists]
Advanced

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

FoodSpace Problems


From: Stacy Oerder
Subject: FoodSpace Problems
Date: Tue, 7 May 2002 11:53:35 +0200

Hi

Thanks for previous advice with regards to the values stored in
foodspace, after taking into account that foodspace should have
integers, my problem diminshed but didn't solve totally. Included below
are a copy of my foodspace.h and foodspace.m files. Using my variables
declared in my prey.scm file my foodspace correctly reads in my original
food value but is still not reading in the size of my world and I'm
having a problem with my -addFood method as it doesn't seem to register
my foodvalue at the xy position which is initially the original food and
then changes each time step as food is added and eaten. If anyone has
any suggestions I'd greatly appreciate it, I am a new user and some of
the use of the language may be incorrect. I have tried to follow
existing examples in the writing of my code to date.

//FoodSpace.h      


#import <space/Discrete2d.h>
#import <space.h>

typedef int FoodValue;

@interface FoodSpace : Discrete2d {
}
int x, y;
int worldXSize, worldYSize;
int foodHere;
int extraFood;
int origFood;
int newFood;

-setOriginalFood: (int) origFood;
-addFood: (FoodValue)newFood X: (int) x Y: (int) y;

@end


//FoodSpace.m       

#import "FoodSpace.h"
#import <random.h>

@implementation FoodSpace

-setOriginalFood: (int) origFood {
        for (x = 0; x<worldXSize; x++)
                for (y = 0; y<worldYSize; y++)
                        [self putValue: origFood atX: x Y: y];
        return self;
        }

-addFood: (FoodValue) newFood X: (int) x Y: (int) y {
        foodHere = [self getValueAtX: x Y: y];
        newFood = foodHere + extraFood;
        [self putValue: newFood atX: x Y: y];
        
        return self;
}



@end




Regards
Stacy Oerder



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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