code/mkCAvid/makeCAvid.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Data Structures

struct  CA
 Represents a cellular automaton. More...

Defines

#define IMAGE_DIRECTORY   "images.temp"
#define PGM_FILE_PATTERN   "step_%i.pgm"
#define JPG_FILE_PATTERN   "step_%i.jpg"
#define VIDEO_FILENAME   "CA.avi"
#define CA_ITERATIONS   2000

Functions

void createVideo (int width, int height)
void simulate (CA *ca, int *rule)
void outputImages (CA *ca, int nimage)
int * getRule (char *file)
 Pulls a rule for the CA from a specified file.
CAgetInitCA (char *file, int size)
 Pulls a CA of specified size from a file given by the specified file name.
void usage ()
CAcreateCA (int size)
 Creates a new CA ready for use, all malloc'd and all.
void printInternalCA (CA *ca)
 Prints to stdout our internal representation of the specified CA.
void printCA (CA *ca)
 Prints to stdout the CA in its normal form.
int step (CA *curr, CA *next, int *rule)
 Performs the transition for one generation of the CA to the next, based on the specified rule set.
void toPGM (CA *ca, char *file)
int finished (CA *ca)
 Indicates whether or not a CA has been completedly classified, i.e.
int main (int argc, char **argv)

Variables

int removePGMs = 1
 Indicates whether or not to remove the PGM images that are created during the video creation process.

Define Documentation

#define CA_ITERATIONS   2000

Definition at line 13 of file makeCAvid.c.

#define IMAGE_DIRECTORY   "images.temp"

Definition at line 9 of file makeCAvid.c.

#define JPG_FILE_PATTERN   "step_%i.jpg"

Definition at line 11 of file makeCAvid.c.

#define PGM_FILE_PATTERN   "step_%i.pgm"

Definition at line 10 of file makeCAvid.c.

#define VIDEO_FILENAME   "CA.avi"

Definition at line 12 of file makeCAvid.c.


Function Documentation

CA* createCA ( int  size  ) 

Creates a new CA ready for use, all malloc'd and all.

Parameters:
size The desired dimension of the new CA.
See also:
freeCA()
Returns:
The newly created CA.

Definition at line 245 of file makeCAvid.c.

void createVideo ( int  width,
int  height 
)

Definition at line 120 of file makeCAvid.c.

int finished ( CA ca  ) 

Indicates whether or not a CA has been completedly classified, i.e.

whether or not the CA is either all ones or all zeros.

Parameters:
ca The CA for which to determine whether or not it is fully classified.
Returns:
A zero or one indicating whether or not the specified CA is fully classified.

Definition at line 232 of file makeCAvid.c.

CA* getInitCA ( char *  file,
int  size 
)

Pulls a CA of specified size from a file given by the specified file name.

The CA should all be on one line and just be a string of ones and zeros with no separation.

Parameters:
file The name of the file that contains the CA configuration.
size The size of the CA in the file.
Returns:
A pointer to the CA that was pulled from the file.

Definition at line 192 of file makeCAvid.c.

int* getRule ( char *  file  ) 

Pulls a rule for the CA from a specified file.

The rule should be contained entirely on one line.

Parameters:
file The name of the file that contains the rule.
Returns:
A pointer to an array of integers, which is really the ruleset.

Definition at line 167 of file makeCAvid.c.

int main ( int  argc,
char **  argv 
)

Definition at line 42 of file makeCAvid.c.

void outputImages ( CA ca,
int  nimage 
)

Definition at line 142 of file makeCAvid.c.

void printCA ( CA ca  ) 

Prints to stdout the CA in its normal form.

Parameters:
ca The CA to print to the screen.
See also:
printInternalCA()

Definition at line 293 of file makeCAvid.c.

void printInternalCA ( CA ca  ) 

Prints to stdout our internal representation of the specified CA.

Parameters:
ca The CA whose internal representaiton will be printed.
See also:
printCA()

Definition at line 280 of file makeCAvid.c.

void simulate ( CA ca,
int *  rule 
)

Definition at line 95 of file makeCAvid.c.

int step ( CA curr,
CA next,
int *  rules 
)

Performs the transition for one generation of the CA to the next, based on the specified rule set.

The current CA is passed and remains unmodified, with its next generation being put into the CA, next.

Parameters:
curr The current generation.
next The next generation.
rules The rule set that governs how a CA should be updated.
See also:
stepWithCount()

Definition at line 307 of file makeCAvid.c.

void toPGM ( CA ca,
char *  file 
)

Definition at line 330 of file makeCAvid.c.

void usage (  ) 

Definition at line 220 of file makeCAvid.c.


Variable Documentation

int removePGMs = 1

Indicates whether or not to remove the PGM images that are created during the video creation process.

Definition at line 25 of file makeCAvid.c.


Generated on Mon Apr 12 21:34:48 2010 for CS523: Complex Adaptive Systems, Spring 2010, Assignment 2 by  doxygen 1.6.1