Skip to content

Commit

Permalink
Enhancements 2, 3, and 4
Browse files Browse the repository at this point in the history
Implemented MOX fluid-reactor behavior.
Added fields for stopping the
reactor early based on time or temperature.
Added a way to design a
reactor with pre-heated components (e.g. 60k coolant cells that were
heated by fuel rods in another reactor).
  • Loading branch information
MauveCloud committed Feb 24, 2015
1 parent 134b15f commit caa4b0b
Show file tree
Hide file tree
Showing 22 changed files with 463 additions and 42 deletions.
5 changes: 5 additions & 0 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/AdvancedHeatExchanger.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/CoolantCell60k.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/CoolantCell10k.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/Reactor.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/Simulator.java</file>
</group>
</open-files>
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/AdvancedHeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public AdvancedHeatExchanger() {
*/
@Override
public String toString() {
return "Advanced Heat Exchanger";
String result = "Advanced Heat Exchanger";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/AdvancedHeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public AdvancedHeatVent() {
*/
@Override
public String toString() {
return "Advanced Heat Vent";
String result = "Advanced Heat Vent";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/ComponentHeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public ComponentHeatExchanger() {
*/
@Override
public String toString() {
return "Component Heat Exchanger";
String result = "Component Heat Exchanger";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
8 changes: 6 additions & 2 deletions src/Ic2ExpReactorPlanner/CoolantCell10k.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class CoolantCell10k extends ReactorComponent {
*/
private static final String imageFilename = "reactorCoolantSimple.png";

public static final MaterialsList MATERIALS = new MaterialsList("Tin Plate", "Water", 8, "Lapis Lazuli");
public static final MaterialsList MATERIALS = new MaterialsList(5, "Tin Plate", "Distilled Water", "Lapis Lazuli");

/**
* Creates a new instance.
Expand All @@ -27,7 +27,11 @@ public CoolantCell10k() {
*/
@Override
public String toString() {
return "10k Coolant Cell";
String result = "10k Coolant Cell";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/CoolantCell30k.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public CoolantCell30k() {
*/
@Override
public String toString() {
return "30k Coolant Cell";
String result = "30k Coolant Cell";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/CoolantCell60k.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public CoolantCell60k() {
*/
@Override
public String toString() {
return "60k Coolant Cell";
String result = "60k Coolant Cell";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/Ic2ExpReactorPlanner/DualFuelRodMox.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public String toString() {
public void generateHeat() {
int pulses = countNeutronNeighbors() + 2;
int heat = 4 * pulses * (pulses + 1);
final Reactor parentReactor = getParent();
if (parentReactor.isFluid() && (parentReactor.getCurrentHeat() / parentReactor.getMaxHeat()) > 0.5) {
heat *= 2;
}
handleHeat(heat);
applyDamage(1.0);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Ic2ExpReactorPlanner/FuelRodMox.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public String toString() {
public void generateHeat() {
int pulses = countNeutronNeighbors() + 1;
int heat = 2 * pulses * (pulses + 1);
final Reactor parentReactor = getParent();
if (parentReactor.isFluid() && (parentReactor.getCurrentHeat() / parentReactor.getMaxHeat()) > 0.5) {
heat *= 2;
}
handleHeat(heat);
applyDamage(1.0);
}
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/HeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public HeatExchanger() {
*/
@Override
public String toString() {
return "Heat Exchanger";
String result = "Heat Exchanger";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/HeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public HeatVent() {
*/
@Override
public String toString() {
return "Heat Vent";
String result = "Heat Vent";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/LzhCondensator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public LzhCondensator() {
*/
@Override
public String toString() {
return "LZH-Condensator";
String result = "LZH-Condensator";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/OverclockedHeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public OverclockedHeatVent() {
*/
@Override
public String toString() {
return "Overclocked Heat Vent";
String result = "Overclocked Heat Vent";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions src/Ic2ExpReactorPlanner/QuadFuelRodMox.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public String toString() {
public void generateHeat() {
int pulses = countNeutronNeighbors() + 3;
int heat = 8 * pulses * (pulses + 1);
final Reactor parentReactor = getParent();
if (parentReactor.isFluid() && (parentReactor.getCurrentHeat() / parentReactor.getMaxHeat()) > 0.5) {
heat *= 2;
}
handleHeat(heat);
applyDamage(1.0);
}
Expand Down
60 changes: 54 additions & 6 deletions src/Ic2ExpReactorPlanner/Reactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class Reactor {

private double ventedHeat = 0.0;

private boolean fluid = false;

public ReactorComponent getComponentAt(int row, int column) {
if (row >= 0 && row < grid.length && column >= 0 && column < grid[row].length) {
return grid[row][column];
Expand Down Expand Up @@ -166,6 +168,9 @@ public String getCode() {
final ReactorComponent component = grid[row][col];
final int id = ComponentFactory.getID(component);
result.append(String.format("%02X", id));
if (component != null && component.getInitialHeat() > 0) {
result.append(String.format("(h%s)", Integer.toString((int)component.getInitialHeat(), 36)));
}
}
}
return result.toString();
Expand All @@ -177,15 +182,58 @@ public String getCode() {
*/
public void setCode(String code) {
int pos = 0;
if (code.length() == 108 && code.matches("[0-9A-Fa-f]+")) {
for (int row = 0; row < grid.length; row++) {
for (int col = 0; col < grid[row].length; col++) {
int id = Integer.parseInt(code.substring(pos, pos + 2), 16);
setComponentAt(row, col, ComponentFactory.createComponent(id));
pos += 2;
int[][] ids = new int[grid.length][grid[0].length];
char[][] paramTypes = new char[grid.length][grid[0].length];
int[][] params = new int[grid.length][grid[0].length];
if (code.length() >= 108 && code.matches("[0-9A-Za-z()]+")) {
try {
for (int row = 0; row < grid.length; row++) {
for (int col = 0; col < grid[row].length; col++) {
ids[row][col] = Integer.parseInt(code.substring(pos, pos + 2), 16);
// setComponentAt(row, col, ComponentFactory.createComponent(id));
pos += 2;
if (pos < code.length() && code.charAt(pos) == '(') {
paramTypes[row][col] = code.charAt(pos + 1);
int tempPos = pos + 2;
StringBuilder param = new StringBuilder(10);
while (code.charAt(tempPos) != ')') {
param.append(code.charAt(tempPos));
tempPos++;
}
params[row][col] = Integer.parseInt(param.toString(), 36);
pos = tempPos + 1;
}
}
}
for (int row = 0; row < grid.length; row++) {
for (int col = 0; col < grid[row].length; col++) {
final ReactorComponent component = ComponentFactory.createComponent(ids[row][col]);
if (paramTypes[row][col] == 'h') {
component.setInitialHeat(params[row][col]);
}
setComponentAt(row, col, component);
}
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}

/**
* Checks whether the reactor is to simulate a fluid-style reactor, rather than a direct EU-output reactor.
* @return true if this was set to be a fluid-style reactor, false if this was set to be direct EU-output reactor.
*/
public boolean isFluid() {
return fluid;
}

/**
* Sets whether the reactor is to simulate a fluid-style reactor, rather than a direct EU-output reactor.
* @param fluid true if this is to be a fluid-style reactor, false if this is to be direct EU-output reactor.
*/
public void setFluid(boolean fluid) {
this.fluid = fluid;
}

}
23 changes: 22 additions & 1 deletion src/Ic2ExpReactorPlanner/ReactorComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ReactorComponent {
private int row = -10;
private int column = -10;

private double initialHeat = 0.0;
private double currentHeat = 0.0;
private double maxHeat = 1.0;

Expand Down Expand Up @@ -131,7 +132,7 @@ public final double getCurrentHeat() {
* Resets heat to 0 (used when resetting simulation).
*/
public final void clearCurrentHeat() {
currentHeat = 0.0;
currentHeat = initialHeat;
}

/**
Expand Down Expand Up @@ -230,5 +231,25 @@ public boolean isBroken() {
public MaterialsList getMaterials() {
return null;
}

/**
* Gets the initial heat previously set for the component.
* @return the initial heat.
*/
public double getInitialHeat() {
return initialHeat;
}

/**
* Set the initial heat of the component, as long as the component can accept heat,
* and the initial heat greater than or equal to zero and less than the max heat.
* If any condition is false, the value is ignored.
* @param initialHeat the initial heat to set
*/
public void setInitialHeat(double initialHeat) {
if (this.isHeatAcceptor() && initialHeat >= 0 && initialHeat < this.getMaxHeat()) {
this.initialHeat = initialHeat;
}
}

}
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/ReactorHeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public ReactorHeatExchanger() {
*/
@Override
public String toString() {
return "Reactor Heat Exchanger";
String result = "Reactor Heat Exchanger";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/Ic2ExpReactorPlanner/ReactorHeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public ReactorHeatVent() {
*/
@Override
public String toString() {
return "Reactor Heat Vent";
String result = "Reactor Heat Vent";
if (getInitialHeat() > 0) {
result += String.format(" (initial heat: %,d)", (int)getInitialHeat());
}
return result;
}

@Override
Expand Down
Loading

0 comments on commit caa4b0b

Please sign in to comment.