diff --git a/Cow.java b/Cow.java index 0215ede..f724746 100755 --- a/Cow.java +++ b/Cow.java @@ -73,41 +73,6 @@ } } - public static int getMaxGen() - { - return maxGen; - } - - public int getID() - { - return id; - } - - public int getGeneration() - { - return generation; - } - - public int[] getParents() - { - return parents; - } - - public String getName() - { - return name; - } - - public String getSex() - { - return sex; - } - - public HashMap getTraits() - { - return traits; - } - public String rateCow(String use) { int rating = 0; @@ -150,16 +115,52 @@ private int combineTrait(int fathertrait, int mothertrait) { - //FIXME This should have a higher variance - int newtrait = (int) Math.round((fathertrait+mothertrait)/2); - int quartertrait = (int) Math.round(newtrait*0.25); - int randomfactor = Herd.randomInt(quartertrait*2) - quartertrait; - return newtrait+randomfactor; + int avgtrait = (int) Math.round((fathertrait+mothertrait)/2); + int randomfactor = Herd.randomInt(5) - 2; + int newtrait = avgtrait+randomfactor; + if (newtrait < 0) newtrait = 0; + return newtrait; } public static void resetCounters() { idCounter = 1; maxGen = 1; - } + } + + public static int getMaxGen() + { + return maxGen; + } + + public int getID() + { + return id; + } + + public int getGeneration() + { + return generation; + } + + public int[] getParents() + { + return parents; + } + + public String getName() + { + return name; + } + + public String getSex() + { + return sex; + } + + public HashMap getTraits() + { + return traits; + } + } diff --git a/Cow.java b/Cow.java index 0215ede..f724746 100755 --- a/Cow.java +++ b/Cow.java @@ -73,41 +73,6 @@ } } - public static int getMaxGen() - { - return maxGen; - } - - public int getID() - { - return id; - } - - public int getGeneration() - { - return generation; - } - - public int[] getParents() - { - return parents; - } - - public String getName() - { - return name; - } - - public String getSex() - { - return sex; - } - - public HashMap getTraits() - { - return traits; - } - public String rateCow(String use) { int rating = 0; @@ -150,16 +115,52 @@ private int combineTrait(int fathertrait, int mothertrait) { - //FIXME This should have a higher variance - int newtrait = (int) Math.round((fathertrait+mothertrait)/2); - int quartertrait = (int) Math.round(newtrait*0.25); - int randomfactor = Herd.randomInt(quartertrait*2) - quartertrait; - return newtrait+randomfactor; + int avgtrait = (int) Math.round((fathertrait+mothertrait)/2); + int randomfactor = Herd.randomInt(5) - 2; + int newtrait = avgtrait+randomfactor; + if (newtrait < 0) newtrait = 0; + return newtrait; } public static void resetCounters() { idCounter = 1; maxGen = 1; - } + } + + public static int getMaxGen() + { + return maxGen; + } + + public int getID() + { + return id; + } + + public int getGeneration() + { + return generation; + } + + public int[] getParents() + { + return parents; + } + + public String getName() + { + return name; + } + + public String getSex() + { + return sex; + } + + public HashMap getTraits() + { + return traits; + } + } diff --git a/MooBreeder.java b/MooBreeder.java index cfff0e1..f42421a 100755 --- a/MooBreeder.java +++ b/MooBreeder.java @@ -341,7 +341,8 @@ private void resetGame() { Herd.getInstance().resetHerd(); - updateGUI(); //FIXME ScrollPane disappears? - only until window is resized + updateGUI(); //FIXME JScrollPane sometimes disappears until window is resized + chooseGoal(); } /*