Hi Everyone
I spent the weekend developing a script that makes suggestions for match times between teams
This relies on several items of data
1. every time someone plays it records the day and time
2. this script uses data from individuals not the team however it shares the #members (command) data which is season specific so each season this script will get smarter as everyone plays for their teams
At the moment I still have the old team files loaded so if you want to test the script it will still work for the next couple of days
There are 2 commands #findmatchtime & #bestmatchtime
#bestmatchtime XYZ will show you the best times for that team, as in the most times everyone on that team has played (the players not the team)
#findmatchtime ABC XYZ will compare both teams and list the most suitable times, again based on the current composition of those teams
All times are listed in GMT +10 as it is the bots time zone so I am still trying to work out how I am going to do any conversion, it may not actually be practical
Hopefully this will aid coaches in making suggestions to other teams, I know it is not much but its a start and hopefully may lead to better ideas or improved implementation
the code is posted below in case anyone has some comments on it :)
; this alias takes 2 arguments (teams) and checks all the players in that team
; and writes ini files for each player showing when they have played in the past
; then does a compare of the two teams to make suggestions on possible
; suitable match times
On *:TEXT:#findmatchtime*:#: {
if (!$3) { mstat *s3 ERROR: Format #findmatchtime XYZ ABC | halt }
var %team1 = $2
var %team2 = $3
if ( $readini(teamstats.ini, Grade, $2) == $null ) { mstat *s3 No team $2 listed please try again | halt }
if ( $readini(teamstats.ini, Grade, $3) == $null ) { mstat *s3 No team $3 listed please try again | halt }
var %team.grade = $readini(teamstats.ini, Grade, %team1)
$fmt_getplayers_fromteam(%team.grade, %team1)
var %team.grade = $readini(teamstats.ini, Grade, %team2)
$fmt_getplayers_fromteam(%team.grade, %team2)
$fmt_compare_teams(%team1, %team2)
mstat Order favours 1st team listed: $2
}
alias fmt_compare_teams {
var %team1file = teamtimes $+ $1 $+ /team.ini
var %team2file = teamtimes $+ $2 $+ /team.ini
var %y = 1
while $ini(%team1file, hours, %y) {
var %team1hrs = $ini(%team1file, hours, %y)
if ($readini(%team1file, hours, %team1hrs) > 1) {
var %team1hr = $readini(%team1file, hours, %team1hrs)
var %team2hr = $readini(%team2file, hours, %team1hrs)
if (%team2hr > 1) {
write comparedteamtime.txt %team1hr %team2hr %team1hrs
}
}
inc %y
}
if ($exists(comparedteamtime.txt)) {
filter -fftceu 1 32 comparedteamtime.txt comparedteamtime.txt
mstat *s2 Best Suggested Match times (based on previous attendance) are as follows: (Times in GMT +10)
if ($lines(comparedteamtime.txt) > 0) {
var %m = 1
while $lines(comparedteamtime.txt) > $calc( %m - 1 ) {
var %fmt.bestslot = $gettok($read(comparedteamtime.txt,%m), 3, 32)
var %fmt.bestday = $gettok(%fmt.bestslot, 1, 58)
var %fmt.besthr = $gettok(%fmt.bestslot, 2, 58)
var %team1playercount = $gettok($read(comparedteamtime.txt,%m), 1, 32)
var %team2playercount = $gettok($read(comparedteamtime.txt,%m), 2, 32)
mstat *s2 %fmt.bestday at %fmt.besthr $+ $chr(58) $+ 00 $1 has %team1playercount players - $2 has %team2playercount players
inc %m
}
}
}
else mstat *s3 No Suitable match time found (based on previous history)
if ($exists(comparedteamtime.txt)) .remove comparedteamtime.txt
$cleanup_fmt_folders(%team1file, %team2file, $1, $2)
}
alias cleanup_fmt_folders {
var %n = 1
while $ini($1, players, %n) {
var %fmt.player = $ini($1, players, %n)
.remove teamtimes $+ $3 $+ / $+ %fmt.player $+ .ini
inc %n
}
var %m = 1
while $ini($2, players, %m) {
var %fmt.player = $ini($2, players, %m)
.remove teamtimes $+ $4 $+ / $+ %fmt.player $+ .ini
inc %m
}
if ($exists($1)) .remove $1
if ($exists($2)) .remove $2
rmdir teamtimes $+ $3
rmdir teamtimes $+ $4
}
; this alias takes params of supplied team grade & team and finds each player
; in turn from that team then sends that information to write_avail_times
; so it can be written to an ini file to be evaluated later
alias fmt_getplayers_fromteam {
var %x = 1
while $ini(grades.ini,$1,%x) {
if ( $readini(grades.ini, $1,$ini(grades.ini, $1,%x)) == $2 ) {
var %this.player = $ini(grades.ini,$1,%x)
$write_avail_times(%this.player, $2)
}
inc %x
}
}
; this alias takes params of player & team, reads all the times that player has
; played and creates a folder called teamtimesABC and places an ini file for
; that player within containing a record of the times they have played matches
alias write_avail_times {
var %z = 1
mkdir teamtimes $+ $2
var %timeCats = $ini(PlayTimes.ini, 0)
while %z < $calc(%timeCats + 1) {
var %this.daytime = $ini(PlayTimes.ini, %z)
if ($readini(PlayTimes.ini, %this.daytime, $1) != $null) {
var %this.day = $gettok(%this.daytime,1,58)
var %this.time = $gettok(%this.daytime,2,58)
var %thisplayerplayed = $readini(PlayTimes.ini, %this.day $+ $chr(58) $+ %this.time, $1)
writeini teamtimes $+ $2 $+ / $+ $1 $+ .ini %this.day %this.time %thisplayerplayed
writeini teamtimes $+ $2 $+ / $+ team.ini Players $1 $1
var %thisteamplayed = $readini(teamtimes $+ $2 $+ / $+ team.ini, hours, %this.day $+ $chr(58) $+ %this.time)
if (%thisteamplayed == $null) {
writeini teamtimes $+ $2 $+ / $+ team.ini hours %this.day $+ $chr(58) $+ %this.time 1
}
else {
inc %thisteamplayed
writeini teamtimes $+ $2 $+ / $+ team.ini hours %this.day $+ $chr(58) $+ %this.time %thisteamplayed
}
}
inc %z
}
}
On *:TEXT:#bestmatchtime*:#: {
if ( $readini(teamstats.ini, Grade, $2) == $null ) { mstat *s3 No team $2 listed please try again | halt }
var %bmt.team = $2
var %team.grade = $readini(teamstats.ini, Grade, %bmt.team)
$bmt_getplayers_fromteam(%team.grade, %bmt.team)
$bmt_showtimes(%bmt.team)
}
alias bmt_showtimes {
var %y = 1
while $ini(bmtteam/team.ini, hours, %y) {
var %teamhrs = $ini(bmtteam/team.ini, hours, %y)
if ($readini(bmtteam/team.ini, hours, %teamhrs) > 1) {
var %teamhr = $readini(bmtteam/team.ini, hours, %teamhrs)
write teamtimes.txt %teamhr %teamhrs
}
inc %y
}
if ($exists(teamtimes.txt)) {
filter -fftceu 1 32 teamtimes.txt teamtimes.txt
mstat *s2 Best Suggested Match Time (based on previous attendance) are as follows: (Times in GMT +10)
if ($lines(teamtimes.txt) > 0) {
var %m = 1
while $lines(teamtimes.txt) > $calc( %m - 1 ) {
var %bmt.bestslot = $gettok($read(teamtimes.txt,%m), 2, 32)
var %bmt.bestday = $gettok(%bmt.bestslot, 1, 58)
var %bmt.besthr = $gettok(%bmt.bestslot, 2, 58)
var %teamplayercount = $gettok($read(teamtimes.txt,%m), 1, 32)
mstat *s2 %bmt.bestday at %bmt.besthr $+ $chr(58) $+ 00 $1 has possible %teamplayercount players available
inc %m
}
}
}
else mstat *s3 No Suitable match time found (based on previous history)
if ($exists(teamtimes.txt)) .remove teamtimes.txt
cleanup_bmt_folders
}
alias bmt_getplayers_fromteam {
var %x = 1
while $ini(grades.ini,$1,%x) {
if ( $readini(grades.ini, $1,$ini(grades.ini, $1,%x)) == $2 ) {
var %this.player = $ini(grades.ini,$1,%x)
$bmt_write_avail_times(%this.player, $2)
}
inc %x
}
}
alias bmt_write_avail_times {
var %z = 1
mkdir bmtteam
var %timeCatagorys = $ini(PlayTimes.ini, 0)
while %z < $calc(%timeCatagorys + 1) {
var %this.daytime = $ini(PlayTimes.ini, %z)
if ($readini(PlayTimes.ini, %this.daytime, $1) != $null) {
var %this.day = $gettok(%this.daytime,1,58)
var %this.time = $gettok(%this.daytime,2,58)
var %thisplayerplayed = $readini(PlayTimes.ini, %this.day $+ $chr(58) $+ %this.time, $1)
writeini bmtteam/ $+ $1 $+ .ini %this.day %this.time %thisplayerplayed
writeini bmtteam/ $+ team.ini Players $1 $1
var %thisteamplayed = $readini(bmtteam/ $+ team.ini, hours, %this.day $+ $chr(58) $+ %this.time)
if (%thisteamplayed == $null) {
writeini bmtteam/ $+ team.ini hours %this.day $+ $chr(58) $+ %this.time 1
}
else {
inc %thisteamplayed
writeini bmtteam/ $+ team.ini hours %this.day $+ $chr(58) $+ %this.time %thisteamplayed
}
}
inc %z
}
}
alias cleanup_bmt_folders {
var %n = 1
while $ini(bmtteam/team.ini, players, %n) {
var %bmt.player = $ini(bmtteam/team.ini, players, %n)
.remove bmtteam/ $+ %bmt.player $+ .ini
inc %n
}
if ($exists(bmtteam/team.ini)) .remove bmtteam/team.ini
rmdir bmtteam
}