Login

Username:

Password:


Lost Password?
Forum Index   -   Topic Index
   General
     Match Time Suggestion Script
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
FireHorse
Posted on: 2010/2/7 12:54
Webmaster
Joined: 1970/1/1
From:
Posts: 1
Match Time Suggestion Script
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 ERRORFormat #findmatchtime XYZ ABC | halt }
  
var %team1 = $2
  
var %team2 = $3
  
if ( $readini(teamstats.iniGrade, $2) == $null ) { mstat *s3 No team $2 listed please try again halt }
  if ( 
$readini(teamstats.iniGrade, $3) == $null ) { mstat *s3 No team $3 listed please try again halt }
  var %
team.grade $readini(teamstats.iniGrade, %team1)
  
$fmt_getplayers_fromteam(%team.grade, %team1)
  var %
team.grade $readini(teamstats.iniGrade, %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 $+ $$+ /team.ini
  
var %team2file teamtimes $+ $$+ /team.ini
  
var %1
  
while $ini(%team1filehours, %y) {
    var %
team1hrs $ini(%team1filehours, %y)
    if (
$readini(%team1filehours, %team1hrs) > 1) {
      var %
team1hr $readini(%team1filehours, %team1hrs)
      var %
team2hr $readini(%team2filehours, %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 attendanceare as follows: (Times in GMT +10)

    if (
$lines(comparedteamtime.txt) > 0) { 
      var %

      
while $lines(comparedteamtime.txt) > $calc( %) { 
        var %
fmt.bestslot $gettok($read(comparedteamtime.txt,%m), 332)
        var %
fmt.bestday $gettok(%fmt.bestslot158)
        var %
fmt.besthr $gettok(%fmt.bestslot258)
        var %
team1playercount $gettok($read(comparedteamtime.txt,%m), 132)
        var %
team2playercount $gettok($read(comparedteamtime.txt,%m), 232)
        
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 %
1
  
while $ini($1players, %n) {
    var %
fmt.player $ini($1players, %n)
    .
remove teamtimes $+ $$+ / $+ %fmt.player $+ .ini
    inc 
%n
  
}
  var %
1
  
while $ini($2players, %m) {
    var %
fmt.player $ini($2players, %m)
    .
remove teamtimes $+ $$+ / $+ %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 %
1
  
while $ini(grades.ini,$1,%x) { 
    if ( 
$readini(grades.ini, $1,$ini(grades.ini, $1,%x))  == $) {
      var %
this.player $ini(grades.ini,$1,%x)
      
$write_avail_times(%this.player, $2)
    }
    
inc %x
  
}
}

this alias takes params of player teamreads 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 %
1
  mkdir teamtimes 
$+ $2
  
var %timeCats $ini(PlayTimes.ini0)
  while %
$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 $+ $$+ / $+ $$+ .ini %this.day %this.time %thisplayerplayed
      writeini teamtimes 
$+ $$+ / $+ team.ini Players $$1
      
var %thisteamplayed $readini(teamtimes $+ $$+ / $+ team.inihours, %this.day $+ $chr(58) $+ %this.time)
      if (%
thisteamplayed == $null) {
        
writeini teamtimes $+ $$+ / $+ team.ini hours %this.day $+ $chr(58) $+ %this.time 1
      
}
      else {
        
inc %thisteamplayed
        writeini teamtimes 
$+ $$+ / $+ team.ini hours %this.day $+ $chr(58) $+ %this.time %thisteamplayed
      
}
    }
    
inc %z
  
}
}

On *:TEXT:#bestmatchtime*:#: {
  
if ( $readini(teamstats.iniGrade, $2) == $null ) { mstat *s3 No team $2 listed please try again halt }
  var %
bmt.team = $2
  
var %team.grade $readini(teamstats.iniGrade, %bmt.team)
  
$bmt_getplayers_fromteam(%team.grade, %bmt.team)
  
$bmt_showtimes(%bmt.team)
}

alias bmt_showtimes {
  var %
1
  
while $ini(bmtteam/team.inihours, %y) {
    var %
teamhrs $ini(bmtteam/team.inihours, %y)
    if (
$readini(bmtteam/team.inihours, %teamhrs) > 1) {
      var %
teamhr $readini(bmtteam/team.inihours, %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 attendanceare as follows: (Times in GMT +10)

    if (
$lines(teamtimes.txt) > 0) { 
      var %

      
while $lines(teamtimes.txt) > $calc( %) { 
        var %
bmt.bestslot $gettok($read(teamtimes.txt,%m), 232)
        var %
bmt.bestday $gettok(%bmt.bestslot158)
        var %
bmt.besthr $gettok(%bmt.bestslot258)
        var %
teamplayercount $gettok($read(teamtimes.txt,%m), 132)
        
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 %
1
  
while $ini(grades.ini,$1,%x) { 
    if ( 
$readini(grades.ini, $1,$ini(grades.ini, $1,%x))  == $) {
      var %
this.player $ini(grades.ini,$1,%x)
      
$bmt_write_avail_times(%this.player, $2)
    }
    
inc %x
  
}
}
alias bmt_write_avail_times {
  var %
1
  mkdir bmtteam
  
var %timeCatagorys $ini(PlayTimes.ini0)
  while %
$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/ $+ $$+ .ini %this.day %this.time %thisplayerplayed
      writeini bmtteam
/ $+ team.ini Players $$1
      
var %thisteamplayed $readini(bmtteam/ $+ team.inihours, %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 %
1
  
while $ini(bmtteam/team.iniplayers, %n) {
    var %
bmt.player $ini(bmtteam/team.iniplayers, %n)
    .
remove bmtteam/ $+ %bmt.player $+ .ini
    inc 
%n
  
}
  if (
$exists(bmtteam/team.ini)) .remove bmtteam/team.ini
  rmdir bmtteam
}
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post