home *** CD-ROM | disk | FTP | other *** search
- /* Cell Proj 1.0 */
-
- #include "Cell_Proto.h"
- #include "Cell_Definitions.h"
- #include "Cell_Variables.h"
-
- DoCellularAutomata()
- {
- int a, b;
- int count;
- int lifeSum[ NUMBER_OF_CELLS ];
- short itemType;
- Rect itemRect;
- Handle itemHandle;
- Str255 textOverPop, textOverExp;
-
- GetDialogItem( gCellInfoDialog, OVER_POP_ITEM, &itemType, &itemHandle,
- &itemRect );
- GetDialogItemText( itemHandle, textOverPop );
- StringToNum( textOverPop, &gOverPop );
-
- GetDialogItem( gCellInfoDialog, OVER_EXP_ITEM, &itemType, &itemHandle,
- &itemRect );
- GetDialogItemText( itemHandle, textOverExp );
- StringToNum( textOverExp, &gOverExp );
-
- for ( count = 0; count < NUMBER_OF_CELLS; count++ ) /* add up pnts around the pixel */
- {
- lifeSum[ count ] = 0;
-
- if ( count - 100 < 0 )
- lifeSum[ count ] += gCellStatus[ count + 900 ];
- else
- lifeSum[ count ] += gCellStatus[ count - 100 ]; /* pnt directly above it */
-
- if ( count - 99 < 0 )
- lifeSum[ count ] += gCellStatus[ count + 901 ];
- else
- lifeSum[ count ] += gCellStatus[ count - 99 ]; /* pnt directly above it */
-
- if ( count - 101 < 0 )
- lifeSum[ count ] += gCellStatus[ count + 899 ];
- else
- lifeSum[ count ] += gCellStatus[ count - 101 ]; /* pnt directly above it */
-
-
-
- if ( count + 99 > 9999 )
- lifeSum[ count ] += gCellStatus[ count - 901 ];
- else
- lifeSum[ count ] += gCellStatus[ count + 99 ]; /* pnt directly above it */
-
- if ( count + 101 > 9999 )
- lifeSum[ count ] += gCellStatus[ count - 899 ];
- else
- lifeSum[ count ] += gCellStatus[ count + 101 ]; /* pnt directly above it */
-
- if ( count + 100 > 9999 )
- lifeSum[ count ] += gCellStatus[ count - 900 ];
- else
- lifeSum[ count ] += gCellStatus[ count + 100 ]; /* pnt directly above it */
-
-
-
- if ( count == 0 )
- lifeSum[ count ] += gCellStatus[ 9999 ];
- else
- lifeSum[ count ] += gCellStatus[ count - 1 ]; /* pnt directly above it */
-
- if ( count == 9999 )
- lifeSum[ count ] += gCellStatus[ 0 ];
- else
- lifeSum[ count ] += gCellStatus[ count + 1 ]; /* pnt directly above it */
-
- GraphResults( count, lifeSum );
- }
- MoveRsltsTo_gCellStatus( lifeSum );
- }
-
- GraphResults( count, lifeSum )
- int count;
- int *lifeSum;
- {
- if ( lifeSum[ count ] <= gOverExp )
- {
- GraphDead( count );
- lifeSum[ count ] = 0;
- }
- if ( lifeSum[ count ] > gOverExp && lifeSum[ count ] < gOverPop )
- {
- GraphAlive( count );
- lifeSum[ count ] = 1;
- }
- if ( lifeSum[ count ] >= gOverPop )
- {
- GraphDead( count );
- lifeSum[ count ] = 0;
- }
- }
-
- GraphDead( count )
- int count;
- {
- int x, y;
-
- x = count / 100;
- y = count - ( 100 * x );
-
- SetPort ( gCellWindow );
- PenNormal ();
- ForeColor ( whiteColor );
-
- MoveTo ( x, y );
- LineTo ( x, y );
- }
-
- GraphAlive( count )
- int count;
- {
- int x, y;
-
- x = count / 100;
- y = count - ( 100 * x );
-
- SetPort ( gCellWindow );
- PenNormal ();
- ForeColor ( blackColor );
-
- MoveTo ( x, y );
- LineTo ( x, y );
- }
-
- MoveRsltsTo_gCellStatus( lifeSum )
- int lifeSum[];
- {
- int count;
-
- for ( count = 0; count < NUMBER_OF_CELLS; count++ ) /* add up pnts around the pixel */
- {
- gCellStatus[ count ] = lifeSum [ count ];
- }
- }