From 518619603ab3c49b7fdfcf19c439c1a30668164f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 2 Apr 2015 15:28:31 -0600 Subject: Everything works, it could use more stuff. --- src/main.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..ef3f3de --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,95 @@ +#include + +#include "map.h" +#include "cell.h" +#include "position.h" +#include "worm.h" +#include "renderascii.h" +#include "renderpng.h" + +#include +#include + +int main( int argc, char *argv[] ) +{ + srand( time( NULL ) ); + + if( argc <= 2 ) + { + printf( + "Specify dimensions as paramters, and at least two e.g.:\n" + " %s 10 10\n" + " %s 5 5 5\n" + " %s 10 5 8 3\n" + "\n", + argv[0], argv[0], argv[0] + ); + return 0; + } + + Position p( argc-1 ); + bool bOk = false; + for( int j = 0; j < argc-1; j++ ) + { + int tmp = strtol( argv[j+1], NULL, 10 ); + if( tmp > 1 ) + { + bOk = true; + } + p[j] = tmp; + } + if( !bOk ) + { + printf("At least one dimension must be greater than 1.\n"); + return 0; + } + +// Position p( 4, 4, 4, 4, 4 ); +// Position p( 3, 5, 5, 5 ); + Map m( p ); + for( int j = 0; j < p.getDims(); j++ ) + p[j]--; + + int iCount = 2; + Worm **pWorm = new Worm*[iCount]; + pWorm[0] = new Worm( 1, Position( p.getDims() ), m ); + pWorm[1] = new Worm( 2, p, m ); +/* + Position t( p.getDims() ); + pWorm[0] = new Worm( 1, t, m ); + t[0] = p[0]; + pWorm[1] = new Worm( 2, t, m ); + */ + + while( iCount > 0 ) + { + for( int j = 0; j < iCount; j++ ) + { + if( pWorm[j]->timestep() == false ) + { + delete pWorm[j]; + if( j < iCount-1 ) + { + pWorm[j] = pWorm[iCount-1]; + pWorm[iCount-1] = 0; + j--; + } + else + { + pWorm[j] = 0; + } + iCount--; + } + } + } + + m.connect( 1, 2 ); + +// RenderAscii r( m ); + RenderPng r( m ); + r.render(); + + + return 0; +} + -- cgit v1.2.3