Guest User

Untitled

a guest
Jan 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class Main {
  4. private static ArrayList<Faltung> faltungen;
  5. private static final int NUMBER_ACIDS = 20;
  6. private static int maxEnergy = -1;
  7. static Koordinatensystem bestFaltung;
  8.  
  9. public static void main(String[] args) {
  10. faltungen = new ArrayList<Faltung>();
  11. generate();
  12. for(Faltung f : faltungen) {
  13. Koordinatensystem s = new Koordinatensystem(f);
  14. if(maxEnergy == -1 || s.getEnergy() > maxEnergy) {
  15. maxEnergy = s.getEnergy();
  16. bestFaltung = s;
  17. }
  18. }
  19. System.out.println("Best is with: " + bestFaltung.getEnergy() + " energy!");
  20. bestFaltung.print();
  21.  
  22. }
  23.  
  24. private static void generate() {
  25. ArrayList<Aminosaeure> temp = new ArrayList<Aminosaeure>();
  26. for (int i = 0; i < 100; i++) {
  27. temp = new ArrayList<Aminosaeure>();
  28. for (int j = 0; j < NUMBER_ACIDS; j++) {
  29. Aminosaeure a = new Aminosaeure();
  30. a.setColor(randomColor());
  31. if(j < 19)
  32. a.setDirection(randomDirection());
  33. temp.add(a);
  34. }
  35. Faltung f = new Faltung(temp);
  36. faltungen.add(f);
  37. }
  38. }
  39.  
  40.  
  41. private static int randomColor() {
  42. return (int) (Math.random() * 100) % 2;
  43. }
  44.  
  45. private static int randomDirection() {
  46. return (int) (Math.random() * 100) % 3;
  47. }
  48.  
  49. private static void print() {
  50. for (Faltung f : faltungen) {
  51. System.out.println("---- FALTUNG ----");
  52. for (Aminosaeure a : f.getSaeuren()) {
  53. System.out.println(a.getColor() + " "
  54. + computeDirection(a.getDirection()) + " ");
  55. }
  56. System.out.println("---- ENDE FALTUNG ----");
  57. }
  58. }
  59.  
  60. private static String computeDirection(int direction) {
  61. switch (direction) {
  62. case Direction.LEFT:
  63. return "Links";
  64. case Direction.RIGHT:
  65. return "Rechts";
  66. case Direction.STRAIGHT:
  67. return "Geradeaus";
  68. default:
  69. return "Null";
  70. }
  71. }
  72. }
Add Comment
Please, Sign In to add comment