package net.perdue.setisim; /** * COPYRIGHT 2002 TIM PERDUE * RELEASED UNDER GPL (GNU General Public License) * * PLEASE CONTRIBUTE YOUR CHANGES TO tim@perdue.net * * Creation date: (9/13/2002 6:46:09 PM) * @author: Tim Perdue */ import java.util.*; /* DRAKE'S EQUATION N=R*fs*fp*ne*fl*fi*fc*L R=Rate of Star Formation 20 fs=Suitable Star Fraction 0.1 fp=Suitable Planet Fraction 0.5 ne=Number of suitable in each system 1 fl=fraction with life 0.5 fi=fraction with intelligence 1 fc=fraction with communication 0.5 L=Lifespan 10,000 A new civilization is added each time R*fs*fp*ne*fl*fi*fc > 0 From then on, the civilization calculates itself to see if it destroys itself or how far away from its base it has moved Multiple the number of civilizations by granularity to get real number */ public class Galaxy { //Drake's variables static double N=0; private int R = 20; private double fs = 0.1; private double fp = 0.5; private int ne = 1; private double fl = 0.5; private double fi = 1; private double fc = 0.5; private int L = 500; //Run-time variables private Vector Civilizations = new Vector(10000); //fraction of speed of light at which a technical civilization expands private double speed = 0.10; //after this number of years of survival, a civilization will last forever private int permanenceThreshold = 1000; //start the simulation at this year of the galaxy's life private double year = 2000000000; private double speedFactor = 100; //radius of galaxy (light years) private int radius = 50000; //random number generator private java.util.Random random = new Random(); private int deadCount = 0; private int liveCount = 0; /** * Galazy constructor comment. */ public Galaxy() { super(); //calc(); } /** * Insert the method's description here. * Creation date: (9/13/2002 7:51:48 PM) */ public void calc() { /* This may be mathematically and statistically fucked */ //R*fs*fp*ne*fl*fi*fc > 1 if (N == 0) { N = R * getSpeedFactor() * fs * fp * ne * fl * fi * fc; } double rnd; Civilization civ=null; int live=0; int dead=0; rnd = random.nextDouble(); if (rnd < N) { getCivilizations().addElement(new Civilization(this)); //System.out.println("Succeeded " + N + " " + rnd + " " + (long) year); } else { //System.out.println("Failed " + N + " " + rnd + " " + (long) year); } Enumeration e = getCivilizations().elements(); while (e.hasMoreElements()) { try { civ=(Civilization) e.nextElement(); civ.calc(); if (civ.getEndYear() == 0) { live++; } else { dead++; } } catch (Exception ex) { ex.printStackTrace(); } } setDeadCount(dead); setLiveCount(live); year = year + getSpeedFactor(); } /** * Insert the method's description here. * Creation date: (9/13/2002 6:58:19 PM) * @return java.util.Vector */ public java.util.Vector getCivilizations() { return Civilizations; } /** * Insert the method's description here. * Creation date: (9/16/2002 4:45:17 PM) * @return int */ public int getDeadCount() { return deadCount; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:55:51 PM) * @return double */ public double getFc() { return fc; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:55:33 PM) * @return double */ public double getFi() { return fi; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:55:13 PM) * @return double */ public double getFl() { return fl; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:53:06 PM) * @return double */ public double getFp() { return fp; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:51:34 PM) * @return double */ public double getFs() { return fs; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:56:13 PM) * @return int */ public int getL() { return L; } /** * Insert the method's description here. * Creation date: (9/16/2002 4:45:27 PM) * @return int */ public int getLiveCount() { return liveCount; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:54:56 PM) * @return int */ public int getNe() { return ne; } /** * Insert the method's description here. * Creation date: (9/13/2002 7:11:40 PM) * @return int */ public int getPermanenceThreshold() { return permanenceThreshold; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:50:53 PM) * @return int */ public int getR() { return R; } /** * Insert the method's description here. * Creation date: (9/13/2002 9:22:24 PM) * @return int */ public int getRadius() { return radius; } /** * Insert the method's description here. * Creation date: (9/13/2002 8:12:09 PM) * @return java.util.Random */ public java.util.Random getRandom() { return random; } /** * Insert the method's description here. * Creation date: (9/13/2002 7:10:21 PM) * @return double */ public double getSpeed() { return speed; } /** * Insert the method's description here. * Creation date: (9/14/2002 9:12:03 PM) * @return double */ public double getSpeedFactor() { return speedFactor; } /** * Insert the method's description here. * Creation date: (9/13/2002 7:25:17 PM) * @return double */ public double getYear() { return year; } /** * Insert the method's description here. * Creation date: (9/13/2002 8:33:11 PM) * @param args java.lang.String[] */ public static void main(String[] args) { System.out.println("Starting"); new Galaxy(); System.out.println("Done"); } /** * Insert the method's description here. * Creation date: (9/16/2002 4:45:17 PM) * @param newDeadCount int */ private void setDeadCount(int newDeadCount) { deadCount = newDeadCount; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:55:51 PM) * @param newFc double */ public void setFc(double newFc) { fc = newFc; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:55:33 PM) * @param newFi double */ public void setFi(double newFi) { fi = newFi; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:55:13 PM) * @param newFl double */ public void setFl(double newFl) { fl = newFl; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:53:06 PM) * @param newFp double */ public void setFp(double newFp) { fp = newFp; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:51:34 PM) * @param newFs double */ public void setFs(double newFs) { fs = newFs; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:56:13 PM) * @param newL int */ public void setL(int newL) { L = newL; } /** * Insert the method's description here. * Creation date: (9/16/2002 4:45:27 PM) * @param newLiveCount int */ private void setLiveCount(int newLiveCount) { liveCount = newLiveCount; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:54:56 PM) * @param newNe int */ public void setNe(int newNe) { ne = newNe; } /** * Insert the method's description here. * Creation date: (9/13/2002 7:11:40 PM) * @param newPermanenceThreshold int */ public void setPermanenceThreshold(int newPermanenceThreshold) { permanenceThreshold = newPermanenceThreshold; } /** * Insert the method's description here. * Creation date: (9/13/2002 6:50:53 PM) * @param newR int */ public void setR(int newR) { R = newR; } /** * Insert the method's description here. * Creation date: (9/13/2002 9:22:24 PM) * @param newRadius int */ public void setRadius(int newRadius) { radius = newRadius; } /** * Insert the method's description here. * Creation date: (9/13/2002 7:10:21 PM) * @param newSpeed double */ public void setSpeed(double newSpeed) { speed = newSpeed; } /** * Insert the method's description here. * Creation date: (9/14/2002 9:12:03 PM) * @param newSpeedFactor double */ public void setSpeedFactor(double newSpeedFactor) { speedFactor = newSpeedFactor; } /** * Insert the method's description here. * Creation date: (9/13/2002 7:25:17 PM) * @param newYear double */ public void setYear(double newYear) { year = newYear; } }