Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/out/
2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
Binary file removed out/production/JavaPlayground/Simulation/Main.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed out/production/JavaPlayground/Simulation/Utils.class
Binary file not shown.
16 changes: 16 additions & 0 deletions src/Simulation/Entity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package Simulation;

public class Entity {
// survival rate when enemy met
public float survivalRate;

// petition to notify danger when enemy met
public float dangerNotifyChance;

// number of entities born on reproduction
public int reproductionCountMin;
public int reproductionCountMax;

public int nutrientsNecessaryForReproduction;
public int currentNutrients;
}
54 changes: 50 additions & 4 deletions src/Simulation/Main.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,56 @@
package Simulation;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicReferenceArray;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");

final Simulation simulation = new Simulation(20, 20);
simulation.simulate(50);

public static void main(String[] args) throws InterruptedException {
final Simulation simulation = new Simulation();
simulation.setData(20, 20, 10);
simulation.simulate(10);
simulation.printData();

// fix seed
// final ThreadLocal<Random> random = ThreadLocal.withInitial(Random::new);
// random.get().setSeed(50);
// final ThreadLocalRandom random = ThreadLocalRandom.current();
// random.setSeed(50);

// final Random random = Utils.random;
// random.setSeed(500);
// final ArrayList<Integer> objects = new ArrayList<>();
// final ArrayList<Thread> threads = new ArrayList<>();
//
// for (int i = 0; i < 10; i++) {
// objects.add(i);
// }
//
// for (int i = 0; i < 10; i++) {
// final ArrayList<Object> clone = new ArrayList<>(objects);
//
// for (Object object : clone) {
// final Thread thread = new Thread(() -> {
// final float randomFloat = random.nextFloat();
// if (randomFloat > 0.5f) {
// objects.remove(object);
// }
// });
// threads.add(thread);
// thread.start();
// }
//
// for (Thread thread : threads) {
// thread.join();
// }
//
// Collections.sort(objects);
// System.out.println("objects = " + objects);
// }
}
}
Loading