Darwinbots Forum
General => Announcements => Topic started by: Numsgil on November 24, 2006, 05:14:31 AM
-
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;
}
-
It's a good idea;
I run the application file Darwinbots.exe yes? Gives me
"An error occured Darwinbots cannot continue Path not found Darwinbots 76 0"
Opens 'Darwinbots 2.42.9f files\DarwinbotsII' which freezes.
-
It gives me the same problem but I've just been ignoring it. I definately think it's something in the way that Darwinbots handles arguments.
It shouldn't freeze though. You should be able to start a new simulation.
-
Maybe it's just a temprary freeze then, as soon as it doesn't open instantly I shut the program down.
-
I'll play with it when I have a good opportunity to. I've been using the program on my laptop with great personal success, even with the little snag that it gives weird errors when you first start the application.