:: Benchmarks all warriors in current directory :: and produces a report file containing: :: time, date and pmars comline used :: sorted scores, filenames and warrior names :: for each warrior a listing and performance chart :: QBASIC and PMARS must be installed in a path dir :: Edit the block below to set the pmars command line, :: rounds, benchmark directory and report file name. :: last old mod Aug 24 2000 by WTN :: :: adapted to DosEmu/FreeDos, fixed up 2/17/09 WTN... :: added set testall=testall.bat then %0 replaced with %testall% :: calls testaset.bat to override settings in the batch file :: added code to sort the warriors in the report by filename :: replaced bench report code with code that handles more rounds :: @echo off if .%1==.Battle goto battlewarrior if .%1==.Test goto testwarrior :: set testall to this batch's filename... set testall=testall.bat :: ----------------------------- (prev defaults) :: set to benchmark directory... set test=c:\warbench\800 :: set to rounds... set rnds=100 :: pmars command line... (note: coresize=800, fixed sequence) set pmars=pmars -b -l 20 -d 20 -s 800 -p 800 -c 8000 -r %rnds% -f :: name of report file... set report=warbench.txt :: ----------------------------- (calls testaset.bat to override) call testaset.bat :: if exist %test%\*.red goto testok echo no test redcode goto end :testok echo. echo Creating warrior benchmark report, don't press any keys... echo. :: initiate report file echo Warrior Benchmarks>%report% echo.|time|find "Cur">>%report% echo.|date|find "Cur">>%report% echo Comline: %pmars%>>%report% echo.>>%report% :: initiate temp report file echo ------------------------------------------------>report$$ :: remove existing score results file, will :: use to build sorted report if exist results$ del results$ :: loop thru all redcode in current dir :: for %%a in (*.red) do call %testall% Test %%a :: need to sort the warriors in the report, nicer... if exist testa$$.bat del testa$$.bat for %%a in (*.red) do echo call %testall% Test %%a >> testa$$.bat sort < testa$$.bat > testa$$$.bat call testa$$$.bat del testa$$*.bat :: turn into a report sort/r>%report% echo.>>%report% type report$$>>%report% del results$ del report$$ :: done... cls goto end :: batch sub.. :: test warrior specified in %2 against *.red in %test% :testwarrior if exist battle$1.out del battle$1.out for %%b in (%test%\*.red) do call %testall% Battle %2 %%b del score$$ :: create and qbasic program to chart performance :: gets name from file %2 :: writes bench results to battle$1.out :: appends score and warrior info to results$ :: modified to permit higher rounds echo> rank$.bas :on error goto Q echo>>rank$.bas open "%2" for input as #1::n$="Anonymous" echo>>rank$.bas while eof(1)=0:line input #1,a$ echo>>rank$.bas if left$(a$,6)=";name " then n$=right$(a$,len(a$)-6) echo>>rank$.bas wend:close #1 echo>>rank$.bas :on error goto X echo>>rank$.bas open "battle$1.out" for input as #1 echo>>rank$.bas open "score$2" for output as #2 echo>>rank$.bas ? #2, "Opponent Scores Results Performance of ";n$ 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)+" ",5):os$=left$(str$(os)+" ",5) echo>>rank$.bas re$=right$(c$,len(c$)-8):re$=left$(re$+" ",13) echo>>rank$.bas ? #2,w$;ms$;os$;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:resume Y echo>>rank$.bas Y:? #2,"--------------- --------- ----------- ---------=---------=---------=---------=" echo>>rank$.bas if not no=0 then echo>>rank$.bas s=int(((ts/no)/(%rnds%/100))*10)/10 echo>>rank$.bas ? #2,"Adjusted Score:";s echo>>rank$.bas :on error goto Q echo>>rank$.bas open "results$" for append as #3 echo>>rank$.bas s$=ltrim$(rtrim$(str$(s))) echo>>rank$.bas if instr(s$,".")=0 then s$=s$+".0" echo>>rank$.bas s$=right$("00"+s$,5):? #3,s$,"%2",n$ echo>>rank$.bas end if echo>>rank$.bas Q:close:system qbasic /run rank$.bas del rank$.bas :: let user know something is happening echo. type score$2 echo. :: add redcode listing and bench results :: to the temp report file... echo.>>report$$ echo Warrior %2>>report$$ echo.>>report$$ type %2>>report$$ echo.>>report$$ type score$2>>report$$ echo.>>report$$ echo ------------------------------------------------>>report$$ del score$2 del battle$1.out goto end :: batch sub - run the battle using pmars :battlewarrior >score$$ %pmars% %2 %3 type score$$ type score$$>>battle$1.out :end