Im working on a softball scheduling scipt and ive come to a standstill...the script has these conditions: This league has 32 teams. 6 diamonds 4 games per diamond Each team must play two games every other week. Each team must play the same number or games No duplicate match-ups. Must work with even or odd number of teams. Must work with any number of diamonds. Attached is the script so far...but it only goes to week 4...anyone have any suggestions?
okay, im stumped why wont this work? <html> <head> <style>body{font:10pt Tahoma;}</style> <body> <?php $teams = 32; $weeks = 8; $diamonds = 6; $diamond_slots = 4; $i=1; $j=1; $week=1; $d=1; //create arrays for diamonds e.g. diamond_slot1[0]=>diamond# [1]=>number of slots used while ($d <= $diamonds): $d_slot = "diamond_slot".$d; $$d_slot = array($d, 0); $d++; endwhile; print "Week ".$week.":<br>"; print "<b>Diamond - Slot - Team1 - Team2</b><br>"; while ($j <= 24){ $diamond_rnd = rand(1,$diamonds); $diamond_slot_rnd = rand(1,$diamond_slots); $d_slot = "diamond_slot".$diamond_rnd; //check for slots over 4 //WHY WONT THIS CATCH ANYTHING OVER 4??? // *************************************** while((${$d_slot}[1]) > $diamond_slots){ $diamond_rnd = rand(1,$diamonds); $diamond_slot_rnd = rand(1,$diamond_slots); $d_slot = "diamond_slot".$diamond_rnd; } // randomize teams & check to make sure they arent the same. $team1_rnd = rand(1,$teams); $team2_rnd = rand(1,$teams); while ($team1_rnd == $team2_rnd){ $team1_rnd = rand(1,$teams); $team2_rnd = rand(1,$teams); } // insert random numbers into array $game2 = "game".$j; if (is_array(${$game2}) == FALSE){ $game = "game".$j; $$game = array($diamond_rnd, $diamond_slot_rnd, $team1_rnd, $team2_rnd); print_r(${$game}); print $j."<br>"; $d_slot = "diamond_slot".$diamond_rnd; ${$d_slot}[1] = ${$d_slot}[1] + 1; $j++; }else{ // check to see if theres an identical array $result = array_diff_assoc($newarr,${$game2}); if (count($result)>0): $j++; print "nothing"; elseif(count($result==0)): $game = "game".$j; $$game = array($diamond_rnd, $diamond_slot_rnd, $team1_rnd, $team2_rnd); print_r(${$game}); print $j."<br>"; $d_slot = "diamond_slot".$diamond_rnd; ${$d_slot}[1] = ${$d_slot}[1] + 1; $j++; endif; } } ?> PHP: