Attached is an autorunner. It searches the Darwinbots directory for the latest version and runs it. You can also pass simulation files to it and it will pass them on to the Darwinbots program to run. It should make running the latest version much easier. Please give feedback.
To use it, just place it in your Darwinbots directory. Place shortcuts to it on your desktop or wherever.
Here's the source code at the moment:
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <process.h>
#include <direct.h>
#include <assert.h>
using namespace std;
string ProperCase(string name)
{
size_t len = name.length();
if ( len > 0 )
{
name[0] = toupper((unsigned char)name[0]);
for(size_t I = 1; I < len; I++)
name[I] = tolower((unsigned char)name[I]);
}
return name;
}
int main(int argc, char *argv[])
{
char PathBuffer[255];
const string ProgramName = "Darwinbots.exe";
string path = argv[0];
{
_getcwd(PathBuffer, 254);
path = path.substr(0, path.size() - ProgramName.size());
_chdir(path.c_str());
}
system ( "dir darwin*.exe > ExecutableList.txt" );
ifstream in( "ExecutableList.txt" );
//1. Seek until we find something of form Darwin*.exe,
// add it to the list
vector<string> ProgramList;
while(!in.eof())
{
string buffer;
in >> buffer;
buffer = ProperCase(buffer);
if(buffer.substr(0, 6) == "Darwin" &&
buffer.substr(buffer.size() - 4) == ".exe" &&
buffer != ProgramName) //don't run ourselves
{
ProgramList.push_back(buffer);
}
}
in.close();
system ("del ExecutableList.txt");
sort(ProgramList.begin(), ProgramList.end());
/*if(ProgramList.size() == 0)
{
cout << "Couldn't find any programs in path " << endl;
system("dir /ad");
system("pause");
exit(1);
}*/
#if _DEBUG
cout << "Going to run program " << ProgramList.back() << endl;
#endif
vector<string> Buffers(argc);
char CharBuffers[256][256];
{
Buffers[0] = ProgramName + PathBuffer;
for(int I = 0; I < argc; I++)
{
if(I > 0)
Buffers[I] = path + argv[I];
strcpy_s(CharBuffers[I], Buffers[I].c_str());
argv[I] = CharBuffers[I];
}
_execv(ProgramList.back().c_str(), argv);
}
return 0;
}