[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I worked for days, and still no resolution, so...
From: |
Ken Cline |
Subject: |
Re: I worked for days, and still no resolution, so... |
Date: |
Thu, 28 Aug 1997 17:35:22 -0400 (EDT) |
What does the `setStatus:' method look like?
On Thu, 28 Aug 1997 address@hidden wrote:
> All,
> I have an error, I've learned and used gdb and am closer to a solution,
> but still can't nail it. I know theres been some complains about my
> frequent asking of questions, so, I spent lots of time trying to figure
> it out first, I've spent over 20 hours trying to find the error.
>
> When I run the program in gdb, and do a backtrace, after it bombs (with
> segmentation fault),
> I get this as the "cause"
>
> #0 0x807c1da objc_msg_lookup
>
> #1 ????????? -[Problem checkForSolution] .... Problem.m 177.
>
> (and 12 others which are internal to objc and/or swarm.)
>
> Line 177 in Problem.m is :
> foundStatus = [foundObject getStatusZZ];
>
> I did a breakpoint on this line, where I set it up like this:
> break 177 if foundStatus > 4 //4 being "full" the highest of possible
> status value.
>
> And it stops and each time I "print foundStatus" it is a number up to
> 10788.
> This seems wrong to me, and I cant figure out why it get incremented up,
> usually by around 60 to 200 each time.
>
> Any ideas?
>
> Brad.
>
>
> MORE DETAILS FOLLOW, IF YOU NEED THEM...
> (All relevant methods, and the checkForSolution methods follow).
>
> I had to name getStatusZZ that, since there is already a method internal
> to the core libraries called "getStatus".
> getStatusZZ is in both types of agents Problems, and solutions, it is:
>
> -(StatusType) getStatusZZ {
> return status;
> }
>
> //this is a action in ProblemModel.m
>
> [modelActions createActionForEach: problemList message:
> M(checkForSolution)];
>
> //this is defined in Solution.h which is imported into Problem.h
>
> deftype enum {free, owned, empty, partial, full} StatusType;
>
> -checkForSolution {
> int indexX, indexY; // used for loop processing.
> id foundObject; // a pointer to object used to check
> // if consumer or solution.
> StatusType foundStatus; // status of the found object.
> int foundNumber; // varible to hold the currently
> found
> // Solutions Assigned number.
>
>
> //if its status = full, then it doesnt need to run this method since its
> has found its
> //ideal solution.
>
> if (status != full) {
>
> // checks the 9 cells near it, including the one its in. I've tried to
> skip
> //over its own cell, but the problem still exists.
>
> for (indexX = x - 1; indexX <= x + 1; indexX++) {
> for (indexY = y - 1; indexY <= y + 1; indexY++) {
>
> //it assigns that object to a foundObject.
>
> foundObject = [world getObjectAtX: indexX Y: indexY];
>
> //if its not nil, but either a problem or a solution, CAN IT BE ANYTHING
> ELSE?
>
> if (foundObject != nil) {
>
> //This is the problem line, its supposed to get the status from the
> // foundObject.
>
> foundStatus = [foundObject getStatusZZ];
>
> //If its status is free (and thusly it is a solution).
>
> if (foundStatus == free) {
>
> //it checks it assigned number. each solution has a "assigned number",
> while the //problems have an ideal number. Both assigned randomly,
> between a Min and Max.
>
> foundNumber = [foundObject getAssignedNumber];
>
> //checks to see if its number is bigger than its current number but not
> more than its //ideal number.
>
> if ((foundNumber > currentNumber) &&
> (foundNumber <= idealNumber)) {
>
> //if the problems current number is 0, then its empty and should attach
> to this //solution.
> if (currentNumber == 0)
>
> //see below for attach and detach.
>
> [self attach: foundObject];
> else {
> [self detach];
> [self attach: foundObject];
> }
> }
> }
> }
> }
> }
> }
> return self;
> }
>
> //oldSolution is a global varible which is a pointer to a solution
>
> -attach: (Solution *) s {
> oldSolution = s;
> currentNumber = [s getAssignedNumber];
> [oldSolution setStatus: owned];
> if (currentNumber == idealNumber)
> [self setStatus: full];
> else
> [self setStatus: partial];
> return self;
> }
>
> //fee the oldsolution, and change my status to empty.
>
> -detach {
> [oldSolution setStatus: free];
> [self setStatus: empty];
> return self;
> }
>
> ==================================
> 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.
> ==================================
>
_________________________________________________________
Ken Cline address@hidden
SAIC VOICE (410) 571-0413
Annapolis, MD FAX (301) 261-8427
==================================
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.
==================================