Skip to content

Commit

Permalink
Fix wire loss to be exponential
Browse files Browse the repository at this point in the history
  • Loading branch information
voidsong-dragonfly committed Jun 13, 2024
1 parent 4376fc6 commit 8af913e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ record OutputData(double amount, Path path, EnergyConnector output)
for(Connection c : path.conns)
{
currentPoint = c.getOtherEnd(currentPoint);
//TODO use Blu's loss formula
availableFactor -= getBasicLoss(c);
// We use exponential loss here so there is still some power at arbitrarily far distances
availableFactor *= (1-getBasicLoss(c));
double availableAtPoint = atSource*availableFactor;
transferredNextTick.addTo(c, availableAtPoint);
if(!currentPoint.equals(path.end))
Expand Down Expand Up @@ -344,7 +344,7 @@ public int hashCode()
public Path append(Connection next, boolean isPathToSink)
{
ConnectionPoint newEnd = next.getOtherEnd(end);
double newLoss = loss+getBasicLoss(next);
double newLoss = loss+(1-loss)*getBasicLoss(next);
Connection[] newPath = Arrays.copyOf(conns, conns.length+1);
newPath[newPath.length-1] = next;
return new Path(newPath, start, newEnd, newLoss, isPathToSink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public static class Wires
// Split: Color in client, all others in server
energyWireConfigs.put(
IEWireType.COPPER,
new EnergyWireConfig(builder, "copper", 16, 2048, 0.05)
new EnergyWireConfig(builder, "copper", 16, 2048, 0.0125)
);
energyWireConfigs.put(
IEWireType.ELECTRUM,
new EnergyWireConfig(builder, "electrum", 16, 8192, 0.025)
new EnergyWireConfig(builder, "electrum", 16, 8192, 0.003)
);
energyWireConfigs.put(
IEWireType.STEEL,
new EnergyWireConfig(builder, "hv", 32, 32768, 0.025)
new EnergyWireConfig(builder, "hv", 32, 32768, 0.0008)
);
wireConfigs.put(
IEWireType.STRUCTURE_ROPE,
Expand Down Expand Up @@ -129,10 +129,10 @@ public EnergyWireConfig(Builder builder, String name, int defLength, int defRate
super(builder, name, defLength, false);
this.transferRate = builder.comment("The transfer rate of "+name+" wire in IF/t")
.defineInRange("transferRate", defRate, 0, Integer.MAX_VALUE);
this.lossRatio = builder.comment("The percentage of power lost every 16 blocks of distance in "+name+" wire")
.defineInRange("loss", defLoss, 0, 1);
this.lossRatio = builder.comment("The percentage of received power lost every 16 blocks of distance in "+name+" wire. This means exponential loss!")
.defineInRange("distanceLoss", defLoss, 0, 1);
this.connectorRate = builder
.comment("In- and output rates of "+name+" wire connectors. This is independant of the transferrate of the wires.")
.comment("In- and output rates of "+name+" wire connectors. This is independent of the transfer rate of the wires.")
.defineInRange("wireConnectorInput", defRate/8, 0, Integer.MAX_VALUE);
builder.pop();
}
Expand Down

0 comments on commit 8af913e

Please sign in to comment.