From 7561ceb4ee6acba33bad215883067b4c143429af Mon Sep 17 00:00:00 2001 From: div0 Date: Tue, 9 Jun 2009 19:25:16 +0000 Subject: [PATCH] random bot choice should be better git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6950 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- misc/tools/midi2cfg-ng.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/misc/tools/midi2cfg-ng.pl b/misc/tools/midi2cfg-ng.pl index 83e4253ee..48ab1dd78 100755 --- a/misc/tools/midi2cfg-ng.pl +++ b/misc/tools/midi2cfg-ng.pl @@ -71,6 +71,11 @@ for my $track(0..@$tracks-1) @allmidievents = sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @allmidievents; +sub unsort(@) +{ + return map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, rand] } @_; +} + @@ -315,7 +320,7 @@ sub busybot_note_on($$$) my $overflow = 0; - for(@busybots_allocated) + for(unsort @busybots_allocated) { my $canplay = busybot_note_on_bot $_, $time, $channel, $note, 0; if($canplay > 0) @@ -328,7 +333,7 @@ sub busybot_note_on($$$) # wrong } - for(map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, rand] } keys %$busybots) + for(unsort keys %$busybots) { next if $busybots->{$_}->{count} <= 0; my $bot = Storable::dclone $busybots->{$_}; -- 2.39.2