REM Analyse RedMixer Soup - 3/1/09 WTN REM REM This program scans a RedMixer soup directory (maximum 46x77, REM minimum 10x10 warriors) and writes statistics to a file... REM Number of members, min/avg/max generation, min/avg/max size, REM how many members have scores and of those avg/max wins and REM avg/max accumulated score (wins * average score). REM Dumps an ascii picture of the soup depicting sizes using REM the same method used by RedMixer (1-9,A-Z,a-z,punctuation) REM Labeling is for tiny warriors for sizes 1-20. REM Prompts for soup directory path\name, just enter to exit. REM After analysing prompts for report name, just enter for console. REM If error occurs prompts to try again. REM DIM ws%(46, 77) tryagain: xmax = 0: ymax = 0: members = 0 mingen = 1E+09: maxgen = 0: accgen& = 0 minlen = 1E+09: maxlen = 0: acclen& = 0 scoreentries = 0 maxwins = 0: accwins& = 0: maxwinsname$ = "" maxtotal = 0: acctotal& = 0: maxtotalname$ = "" LINE INPUT "Soup directory: "; soup$ soup$ = LTRIM$(RTRIM$(soup$)) IF soup$ = "" THEN GOTO endprogram ON ERROR GOTO badfile SHELL "dir /b " + soup$ + "\*.red > _salist_" OPEN "_salist_" FOR INPUT AS #1 WHILE NOT EOF(1) LINE INPUT #1, warrior$ OPEN soup$ + "\" + warrior$ FOR INPUT AS #2 members = members + 1 warlen = 0: gen = 0: wins = 0 WHILE NOT EOF(2) LINE INPUT #2, warline$ IF LEFT$(warline$, 12) = ";generation " THEN gen = VAL(MID$(warline$, 13)) IF MID$(warline$, 4, 1) = "." THEN warlen = warlen + 1 IF LEFT$(warline$, 6) = ";wins " THEN wins = VAL(MID$(warline$, 7)) IF LEFT$(warline$, 7) = ";score " THEN score = VAL(MID$(warline$, 8)) WEND CLOSE #2 IF gen < mingen THEN mingen = gen IF gen > maxgen THEN maxgen = gen accgen& = accgen& + gen IF warlen < minlen THEN minlen = warlen IF warlen > maxlen THEN maxlen = warlen acclen& = acclen& + warlen ypos = VAL(LEFT$(warrior$, 2)) xpos = VAL(MID$(warrior$, 4, 2)) IF ypos > ymax THEN ymax = ypos IF xpos > xmax THEN xmax = xpos ws%(ypos, xpos) = warlen IF wins > 0 THEN scoreentries = scoreentries + 1 totalscore = wins * score accwins& = accwins& + wins acctotal& = acctotal& + totalscore IF wins = maxwins THEN maxwinsname$ = maxwinsname$ + " " + warrior$ IF wins > maxwins THEN maxwins = wins: maxwinsname$ = warrior$ IF totalscore = maxtotal THEN maxtotalname$ = maxtotalname$ + " " + warrior$ IF totalscore > maxtotal THEN maxtotal = totalscore: maxtotalname$ = warrior$ END IF WEND CLOSE #1 KILL "_salist_" IF members = 0 THEN PRINT "Invalid directory. Try again? "; GOTO promptfortryagain ELSE LINE INPUT "Soup report name: "; report$ report$ = LTRIM$(RTRIM$(report$)) IF report$ = "" THEN report$ = "CON:" OPEN report$ FOR OUTPUT AS #3 avggen = accgen& / members avglen = acclen& / members PRINT #3, "Number of members ="; members PRINT #3, "Minimum generation ="; mingen PRINT #3, "Average generation ="; avggen PRINT #3, "Maximum generation ="; maxgen PRINT #3, "Minimum length ="; minlen PRINT #3, "Average length ="; avglen PRINT #3, "Maximum length ="; maxlen IF scoreentries > 0 THEN avgwins = accwins& / scoreentries avgtotal = acctotal& / scoreentries PRINT #3, "Number of members with scores ="; scoreentries PRINT #3, "Average number of wins ="; avgwins PRINT #3, "Maximum number of wins ="; maxwins; " by "; maxwinsname$ PRINT #3, "Average accumulated score ="; avgtotal PRINT #3, "Maximum accumulated score ="; maxtotal; " by "; maxtotalname$ END IF PRINT #3, "" PRINT #3, "Sizes of soup warriors... (1-9, A-J for 1-20)" PRINT #3, "."; : FOR i = 1 TO xmax: PRINT #3, "-"; : NEXT i: PRINT #3, "." FOR y = 1 TO ymax PRINT #3, "|"; FOR x = 1 TO xmax s = ws%(y, x) char$ = CHR$(126) IF s > 0 AND s < 10 THEN char$ = CHR$(s + 48) IF s > 9 AND s < 36 THEN char$ = CHR$(s + 55) IF s > 35 AND s < 62 THEN char$ = CHR$(s + 61) IF s > 61 AND s < 77 THEN char$ = CHR$(s - 29) IF s > 76 AND s < 84 THEN char$ = CHR$(s - 19) IF s > 83 AND s < 87 THEN char$ = CHR$(s + 39) PRINT #3, char$; NEXT x PRINT #3, "|" NEXT y PRINT #3, "`"; : FOR i = 1 TO xmax: PRINT #3, "-"; : NEXT i: PRINT #3, "'" CLOSE #3 END IF GOTO endprogram badfile: RESUME badfile1 badfile1: CLOSE : PRINT "Error. Try again? "; promptfortryagain: LINE INPUT a$: a$ = LEFT$(LTRIM$(UCASE$(a$)), 1) IF a$ = "Y" THEN GOTO tryagain endprogram: SYSTEM