Handy Corewars Batches... FILTERWC.BAT - battles everything in a directory against a do-nothing test warrior and copies the warriors that get a perfect score to another directory. Edit to specify the directories, set to examine "warcode" and to copy good code to "filtered". Requires pmars.exe, edit if not on path. DELDUPRC.BAT - compares the non-comment parts of a group of files to identify and remove duplicate warriors. Edit to specify file mask, set to "filtered\*.red". EVALWARS.BAT - battles a directory of redcode against warriors in a test directory and scores to a file. Edit to specify directories and default rounds, set to examine "filtered" against "c:\wilkies" at 50 rounds. When done, calls scorelog.bat to score to BATTLE.TXT Requires pmars.exe, edit if not on path. SCORELOG.BAT - scores and sorts a pmars log file to the screen or a file, uses qbasic. TESTWAR.BAT - evaluates the performance of a single warrior against warriors in a test directory then charts and scores the results either to the screen or a file. Edit to specify benchmark directory and default rounds, set to "c:\wilkies", 100 rounds. Requires pmars and qbasic. To use, copy to a path directory or use Windows 95's file options to add to right-click choices for .RED files. Syntax details (if any) are listed in the batch code. Although not really specific to evolved warriors, the default set statements are set up to examine the output of RedMaker, assuming the evolved warriors are in "warcode" and the good code will be placed in "filtered". The sequence is as follows... Run REDMAKER for awhile to make warriors in "warcode" Run FILTERWC to copy the functional code in "warcode" to "filtered" Run DELDUPRC to delete duplicate warriors in "filtered" Run EVALWARS to benchmark warriors in "filtered" Examine report... maybe something cool evolved, verify with TESTWAR Note - EVALWARS and TESTWAR must be edited to specify the directory that contains the benchmark warriors, or copy them to C:\WILKIES Note on using TESTWAR.BAT - this is a general-purpose warrior benchmarking batch, unlike the others it can't be double-clicked without parms. For best results and access to command line parms, copy to a path directory. Don't know what a path dir is... type path at a prompt and pick one, these dirs are searched when you enter a command. Syntax: TESTWAR warrior.ext [#rounds [report.ext]] For example, use a command like TESTWAR DA.RED 100 DA.REP to test warrior da.red at 100 rounds and write report to da.rep file. If you use Windows 95, you can add options that appear when you right-click .RED files, handy commands to add are... Run Warrior drive:dir\PMARSV.EXE -b -l 500 -d 500 Test Warrior drive:dir\TESTWAR.BAT To add commands for any file type, load up explorer and View|Options then click on File Types. Click New Type, enter something like Redcode Warrior for description, .RED for extension. If it says RED files are already associated, find it and Edit instead. Under the actions you can select New for each thing you want to do, like run pmarsv or testwar, perhaps set the default "open" action to load notepad.exe or a viewer. These batches were made by Terry Newton, wtnewton@nc5.infi.net -------------------------------------------------------- FILTERWC BAT 793 03-24-98 3:51p filterwc.bat -------------------------------------------------------- :: tests warriors for functionality :: copies good code to another directory @echo off if .%1==.Test goto %1 :: evolved warriors directory... set wardir=warcode :: save directory... set savedir=filtered :: pmars command line... set pmars=pmars -b -r 3 -c 40000 -s 8000 :: perfect result set perfect=3 0 0 :: still target... echo> testwar$.$ ;assert 1 echo>>testwar$.$ jmp 0 :: ------------------------------ echo Testing... Don't press any key... if not exist %savedir%\nul md %savedir% for %%a in (%wardir%\*.red) do call %0 Test %%a if exist score!$# del score!$# del testwar$.$ goto end :test echo Testing %2 >score!$# %pmars% %2 testwar$.$ find "%perfect%"nul if not errorlevel 1 echo ******* Saving %2 if not errorlevel 1 copy %2 %savedir%>nul :end -------------------------------------------------------- DELDUPRC BAT 944 03-25-98 3:31p delduprc.bat -------------------------------------------------------- :: find duplicate files not counting comment differences :: this version deletes the duplicate files @echo off if .%1==.GoTo goto %2 :: set to files to look at... set mask=filtered\*.red if not .%1==. set mask=%1 %2 %3 %4 %5 %6 %7 %8 %9 if not exist %tmp%\nul set tmp= echo Searching for duplicates in %mask% echo Please wait... (or your files will be hidden) for %%a in (%mask%) do call %0 GoTo 1 %%a attrib %mask% -h set mask= if not exist %tmp%\compare$.tm? echo no files to compare if not exist %tmp%\compare$.tm? goto done del %tmp%\compare$.tm1 del %tmp%\compare$.tm2 goto done :1 attrib %3 +h for %%b in (%mask%) do call %0 GoTo 2 %3 %%b goto done :2 find /v ";"<%3>%tmp%\compare$.tm1 find /v ";"<%4>%tmp%\compare$.tm2 fc %tmp%\compare$.tm1 %tmp%\compare$.tm2|find "FC: no diff">nul if errorlevel 1 echo %3 and %4 are different if errorlevel 1 goto done echo Duplicate: %3 and %4, deleting %4 del %4 :done -------------------------------------------------------- EVALWARS BAT 961 03-25-98 4:06p evalwars.bat -------------------------------------------------------- :: evalwars [rounds] :: a batch for testing redcode warriors :: calls scorelog.bat when done :: hardcode warrior directories below @echo off if .%1==.Sub goto %2 :: default rounds per battle... set rounds=50 if not .%1==. set rounds=%1 :: set to directory to test... set dir1=filtered :: set to benchmark directory... set dir2=c:\wilkies :: battle filename... set outfile=battle.out :: scores filename... set scofile=battle.txt :: change to ..=c:\pmarsdir\pmars.. if not on path set pmars=pmars -b -r %rounds% rem>%outfile% echo Testing %dir1% against %dir2% at %rounds% rounds echo Don't press any key... if you do enter 'continue' for %%a in (%dir1%\*.red) do call %0 Sub 1 %%a if exist score$!.tmp del score$!.tmp call scorelog.bat %outfile% %scofile% type %scofile%|more goto end :1 for %%b in (%dir2%\*.red) do call %0 Sub 2 %3 %%b goto end :2 >score$!.tmp %pmars% %3 %4 type score$!.tmp>>%outfile% type score$!.tmp :end -------------------------------------------------------- SCORELOG BAT 2,409 03-03-98 12:27p scorelog.bat -------------------------------------------------------- :: Takes raw score data and creates sorted score file, :: normalized 0-300. If no outfile types results to screen. :: Requires QBasic. Last mod Mar 3 98 @echo off if .%1==. echo SCORELOG file [outfile] if .%1==. echo as in SCORELOG temp.out score.fil if .%1==. goto quit if not exist %1 echo nothing to score if not exist %1 goto quit echo Scoring battles, please wait... echo> score$.bas :on error goto donefile echo>>score$.bas dim war$(500),score(500),plays(500):maxwar=0 echo>>score$.bas open "%1" for input as #1 echo>>score$.bas L:line input #1,a$:if instr(a$, "Results:")=0 goto L echo>>score$.bas close #1:x=instr(a$," "):y=instr(x+1,a$," ") echo>>score$.bas z=instr(y+1,a$," "):q=val(mid$(a$,x,y-x)) echo>>score$.bas r=val(mid$(a$,y,z-y)):s=val(right$(a$,len(a$)-z)) echo>>score$.bas rounds=q+r+s:if rounds=0 goto done echo>>score$.bas for i=1 to 500:war$(i)="":score(i)=0:plays(i)=0:next i echo>>score$.bas open "%1" for input as #1 echo>>score$.bas floop:line input #1,a$:a$=ltrim$(rtrim$(a$)) echo>>score$.bas p=instr(a$," scores "):if p=0 goto floop echo>>score$.bas name$=left$(a$,p) echo>>score$.bas if maxwar=0 then echo>>score$.bas war$(0)=name$:j=0:maxwar=1 echo>>score$.bas else echo>>score$.bas j=maxwar:for i=0 to maxwar-1 echo>>score$.bas if name$=war$(i) then j=i:i=maxwar-1 echo>>score$.bas next i echo>>score$.bas end if echo>>score$.bas if j=maxwar then war$(maxwar)=name$:maxwar=maxwar+1 echo>>score$.bas u$=right$(a$,3):sp=instr(u$," ") echo>>score$.bas if (sp=0)=0 then u$=right$(u$,len(u$)-sp) echo>>score$.bas plays(j)=plays(j)+1:score(j)=score(j)+val(u$):goto floop echo>>score$.bas donefile:close #1:resume writeresults echo>>score$.bas writeresults:on error goto done echo>>score$.bas open "score$.tmp" for output as #1 echo>>score$.bas if maxwar=0 then goto done echo>>score$.bas for i=0 to maxwar-1 echo>>score$.bas ws=int(((score(i)/plays(i))/rounds)*1000)/10+1000.01 echo>>score$.bas wscore$=str$(ws):mid$(wscore$,2,1)=" " echo>>score$.bas mid$(wscore$,8,1)=" ":print #1,wscore$,war$(i):next i echo>>score$.bas done:close #1:system qbasic /run score$.bas del score$.bas if not exist score$.tmp echo ERROR if not exist score$.tmp goto quit sort /R < score$.tmp > score$.out del score$.tmp if not .%2==. copy score$.out %2>nul if not .%2==. goto notype type score$.out|more pause :notype del score$.out :quit -------------------------------------------------------- TESTWAR BAT 2,465 03-24-98 2:30p testwar.bat -------------------------------------------------------- :: usage: testwar warrior [rounds] [outfile] :: charts warrior performance using qbasic :: edit to specify test directory @echo off if .%1==.Sub goto process if .%1==. echo no warrior specified if .%1==. goto end :: set to benchmark directory... set test=c:\wilkies :: default rounds... set rnds=100 if not .%2==. set rnds=%2 :: pmars command line... set pmars=pmars -b -r %rnds% :: listing program... (types if empty) set list= if exist %1 goto fileok echo file not found goto end :fileok if exist %test%\*.red goto testok echo no test redcode goto end :testok echo Testing... rem>battle$1.out for %%a in (%test%\*.red) do call %0 Sub %1 %%a del score$$ echo>name.bat @echo off echo>>name.bat set name=%%1 find ";name"<%1>getname$.bat call getname$.bat del getname$.bat del name.bat echo>rank$.bas :on error goto X echo>>rank$.bas open "battle$1.out" for input as #1:open "score$2" for output as #2 echo>>rank$.bas ? #2, "Battle details for warrior %name%":? #2,"" echo>>rank$.bas ? #2, "Opponent Scores Results Performance of %name%" echo>>rank$.bas ? #2, "-------- ------ ------- ---------=---------=---------=---------=" echo>>rank$.bas L:line input #1,a$:if instr(a$,"scores ")=0 goto L echo>>rank$.bas line input #1,b$:line input #1,c$:if instr(a$,"%name%")=0 goto L echo>>rank$.bas w$=left$(b$,instr(b$," by ")):w$=left$(w$+" ",15)+" " echo>>rank$.bas ms=val(right$(a$,len(a$)-instr(a$,"scores ")-6)):ts=ts+ms echo>>rank$.bas os=val(right$(b$,len(b$)-instr(b$,"scores ")-6)):no=no+1 echo>>rank$.bas ms$=left$(str$(ms)+" ",4):os$=left$(str$(os)+" ",4) echo>>rank$.bas re$=right$(c$,len(c$)-8):re$=left$(re$+" ",12) echo>>rank$.bas ? #2,w$;os$;ms$;" ";re$;:if os+ms=0 or ms=0 goto N echo>>rank$.bas ra=(ms/(%rnds%*3))*40:for z=1 to ra:? #2,"*";:next z echo>>rank$.bas N:? #2,"":goto L echo>>rank$.bas X:? #2,"-------- ------ ------- ---------=---------=---------=---------=" echo>>rank$.bas if not no=0 then ? #2,"":? #2,"Adjusted Score:";int(((ts/no)/(%rnds%/100))*10)/10 echo>>rank$.bas close #1:close #2:system qbasic /run rank$.bas del rank$.bas if not .%3==. copy score$2 %3>nul if not .%3==. goto notype if not .%list%==. call %list% score$2 if not .%list%==. goto notype type score$2|more :notype del score$2 del battle$1.out goto end :process >score$$ %pmars% %2 %3 type score$$ type score$$>>battle$1.out :end -------------------- end of batch code ------------------- License Information ------------------- This software is distributed under the terms of the GNU General Public License published by the Free Software Foundation. I'm not going to reprint the legaleeze here, basically what it means is if it works, great, if it breaks your system, too bad (but email me and I'll try to help) and if you distribute it or modified copies you should include or make available the source code and a notice of these terms. If you wish to make money with it, you can't, you have to give it away. My apologies for my loose translation of the terms, the actual text of the license takes precedence.