Java计划生成器输出不够

时间:2013-09-13 23:21:05

标签: java

我正在开发一个java体育计划生成器,我的问题是它没有生成足够的游戏,我(我认为)设置为32天,每个团队每天一个游戏,但由于某种原因从未输出很多,在17-29之间变化。我经历了好几次,但我仍然无法弄清楚问题。请帮忙! 这就是我到目前为止:提前致谢!

    public class FourThirtyTwoSched {
//Who has the team played and how many times
static int[][] schedulePlayed = new int[4][4];

//Has the team played today?
static int[][] playedToday = new int [32][4];
public static void main(String[] args) {
    //Initiate Random objects
    Random rand = new Random(4);
    Random replace = new Random(4);
    //Sets the arrays
    //Column = reference team
    for(int i = 0; i < schedulePlayed.length; i++){
        schedulePlayed[i][0] = 8;
        schedulePlayed[i][1] = 8;
        schedulePlayed[i][2] = 8;
        schedulePlayed[i][3] = 8;
    }
    for(int j = 0; j 
            < 32; j++){
        playedToday[j][0] = 1;
        playedToday[j][1] = 1;
        playedToday[j][2] = 1;
        playedToday[j][3] = 1;
    }

    //Initiate Time
    int day = 0;

        while(day < 32){
        while((playedToday[day][0] + playedToday[day][1] + playedToday[day][2] + playedToday[day][3]) != 0){

        int vs = 0;
        int team = 0;
        vs = rand.nextInt(4);
        team = rand.nextInt(4);
        //ensure random is valid
        while(playedToday[day][vs] == 0 || schedulePlayed[vs][team] == 0 || playedToday[day][team] == 0){
            vs = replace.nextInt(4);
            team = replace.nextInt(4);  }            
        if (playedToday[day][vs] > 0 && schedulePlayed[vs][team] > 0 && playedToday[day][team] > 0){
            //Only prints if not bye
            if (true) {
            System.out.println(team + " v. " + vs);
            }}
    //prevents a team from playing multiple times per day- or against same team more than 8 times
            schedulePlayed[vs][team]--;
            playedToday[day][vs]--;
            playedToday[day][team]--;

        }
        //day count up one
        day++;      
        System.out.println("");
        }

    }
}

0 个答案:

没有答案
相关问题