Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class Main {
- private static ArrayList<Faltung> faltungen;
- private static final int NUMBER_ACIDS = 20;
- private static int maxEnergy = -1;
- static Koordinatensystem bestFaltung;
- public static void main(String[] args) {
- faltungen = new ArrayList<Faltung>();
- generate();
- for(Faltung f : faltungen) {
- Koordinatensystem s = new Koordinatensystem(f);
- if(maxEnergy == -1 || s.getEnergy() > maxEnergy) {
- maxEnergy = s.getEnergy();
- bestFaltung = s;
- }
- }
- System.out.println("Best is with: " + bestFaltung.getEnergy() + " energy!");
- bestFaltung.print();
- }
- private static void generate() {
- ArrayList<Aminosaeure> temp = new ArrayList<Aminosaeure>();
- for (int i = 0; i < 100; i++) {
- temp = new ArrayList<Aminosaeure>();
- for (int j = 0; j < NUMBER_ACIDS; j++) {
- Aminosaeure a = new Aminosaeure();
- a.setColor(randomColor());
- if(j < 19)
- a.setDirection(randomDirection());
- temp.add(a);
- }
- Faltung f = new Faltung(temp);
- faltungen.add(f);
- }
- }
- private static int randomColor() {
- return (int) (Math.random() * 100) % 2;
- }
- private static int randomDirection() {
- return (int) (Math.random() * 100) % 3;
- }
- private static void print() {
- for (Faltung f : faltungen) {
- System.out.println("---- FALTUNG ----");
- for (Aminosaeure a : f.getSaeuren()) {
- System.out.println(a.getColor() + " "
- + computeDirection(a.getDirection()) + " ");
- }
- System.out.println("---- ENDE FALTUNG ----");
- }
- }
- private static String computeDirection(int direction) {
- switch (direction) {
- case Direction.LEFT:
- return "Links";
- case Direction.RIGHT:
- return "Rechts";
- case Direction.STRAIGHT:
- return "Geradeaus";
- default:
- return "Null";
- }
- }
- }
Add Comment
Please, Sign In to add comment