Skip to content

Commit

Permalink
Get rid of some options that shouldn't be options
Browse files Browse the repository at this point in the history
  • Loading branch information
ZehMatt committed Aug 25, 2024
1 parent f05da2a commit bdc7f78
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 40 deletions.
17 changes: 7 additions & 10 deletions Mod/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,14 @@ static void InitializeSimulation()
simulation.Reset(config);

// Advance the simulation by specified ticks.
if (config.TicksToAdvanceOnStartup > 0)
{
Logging.Out("Advancing simulation for {0} ticks...", config.TicksToAdvanceOnStartup);
Logging.Out("Advancing simulation for {0} ticks...", Simulation.Limits.TicksToAdvanceOnStartup);

var elapsed = Utils.Measure(() =>
{
simulation.FastAdvance(config.TicksToAdvanceOnStartup);
});
var elapsed = Utils.Measure(() =>
{
simulation.FastAdvance(Simulation.Limits.TicksToAdvanceOnStartup);
});

Logging.Out("... done, took {0}.", elapsed);
}
Logging.Out("... done, took {0}.", elapsed);
}

simulation.EnableAutoSave(simFile, 60.0f);
Expand Down Expand Up @@ -279,7 +276,7 @@ static void GameUpdate()
// Check for pausing.
{
var isPaused = GameManager.Instance.IsPaused();
if (simulation.Config.PauseWithoutPlayers && simulation.PlayerCount == 0)
if (simulation.PlayerCount == 0)
{
isPaused = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Mod/Windows/SimulationMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void RenderUpdate()
UpdateColors();

nextUpdate = DateTime.Now;
nextUpdate = nextUpdate.AddMilliseconds(1000 / 30);
nextUpdate = nextUpdate.AddSeconds(1);

RenderRoadsToTexture();

Expand Down
1 change: 0 additions & 1 deletion Tests/LoadSaveTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ private void CompareSimulations(Simulation simA, Simulation simB)

Assert.AreEqual(configA.RandomSeed, configB.RandomSeed);
Assert.AreEqual(configA.MaxAgents, configB.MaxAgents);
Assert.AreEqual(configA.TicksToAdvanceOnStartup, configB.TicksToAdvanceOnStartup);
Assert.AreEqual(configA.StartAgentsGrouped, configB.StartAgentsGrouped);
Assert.AreEqual(configA.GroupSize, configB.GroupSize);
Assert.AreEqual(configA.StartPosition, configB.StartPosition);
Expand Down
15 changes: 6 additions & 9 deletions Viewer/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,14 @@ private void StartSimulation()

GenerateColorTable();

if (CurrentConfig.TicksToAdvanceOnStartup > 0)
{
Logging.Out("Advancing simulation for {0} ticks...", CurrentConfig.TicksToAdvanceOnStartup);
Logging.Out("Advancing simulation for {0} ticks...", Simulation.Limits.TicksToAdvanceOnStartup);

var elapsed = Utils.Measure(() =>
{
simulation.FastAdvance(CurrentConfig.TicksToAdvanceOnStartup);
});
var elapsed = Utils.Measure(() =>
{
simulation.FastAdvance(Simulation.Limits.TicksToAdvanceOnStartup);
});

Logging.Out("... done, took {0}.", elapsed);
}
Logging.Out("... done, took {0}.", elapsed);

simulation.Start();
updateTimer.Start();
Expand Down
3 changes: 0 additions & 3 deletions WalkerSim/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public class DebugOptions
[XmlElement("MaxAgents")]
public int MaxAgents = 10000;

[XmlElement("TicksToAdvanceOnStartup")]
public int TicksToAdvanceOnStartup = 0;

[XmlElement("StartAgentsGrouped")]
public bool StartAgentsGrouped = true;

Expand Down
1 change: 1 addition & 0 deletions WalkerSim/Simulation.Limits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ internal partial class Simulation
{
public static class Limits
{
public const uint TicksToAdvanceOnStartup = 100;
public const int MinAgents = 1;
public const int MaxAgents = 30000;
public const int MaxQuerySize = 128;
Expand Down
4 changes: 2 additions & 2 deletions WalkerSim/Simulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public void Stop()
Logging.Out("Simulation stopped.");
}

public void FastAdvance(int numTicks)
public void FastAdvance(uint numTicks)
{
var oldScale = TimeScale;
TimeScale = 512.0f;
for (int i = 0; i < numTicks; i++)
for (uint i = 0; i < numTicks; i++)
{
Tick();
}
Expand Down
4 changes: 1 addition & 3 deletions WalkerSim/WalkerSim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
<LogSpawnDespawn>false</LogSpawnDespawn>
</DebugOptions>
<RandomSeed>1337</RandomSeed>
<MaxAgents>6000</MaxAgents>
<TicksToAdvanceOnStartup>100</TicksToAdvanceOnStartup>
<MaxAgents>10000</MaxAgents>
<StartAgentsGrouped>true</StartAgentsGrouped>
<GroupSize>100</GroupSize>
<AgentStartPosition>RandomLocation</AgentStartPosition>
<AgentRespawnPosition>RandomBorderLocation</AgentRespawnPosition>
<PauseWithoutPlayers>true</PauseWithoutPlayers>
<PauseDuringBloodmoon>true</PauseDuringBloodmoon>
<MovementProcessors Group="-1" SpeedScale="1" Color="#80FF80">
<Processor Type="FlockAnyGroup" Distance="50" Power="0.0001" />
Expand Down
13 changes: 2 additions & 11 deletions WalkerSim/WalkerSimSchema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://zeh.matt/WalkerSimSchema"
xmlns="http://zeh.matt/WalkerSimSchema"
elementFormDefault="qualified">
elementFormDefault="qualified"
vc:minVersion="1.1" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning">

<xs:simpleType name="AgentPositionType">
<xs:annotation>
Expand Down Expand Up @@ -179,11 +180,6 @@
<xs:documentation>Agents will be assigned to a group, this specifies how many members a group will have</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="TicksToAdvanceOnStartup" type="xs:int" default="0">
<xs:annotation>
<xs:documentation>In case a new simulation starts this is the amount of ticks it will advance in one go</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="StartAgentsGrouped" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will put agents of the same group closer together at initial start of the simulation</xs:documentation>
Expand All @@ -203,11 +199,6 @@
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="PauseWithoutPlayers" type="xs:boolean">
<xs:annotation>
<xs:documentation>The option specifies if the simulation should be paused when no players are on the server</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="PauseDuringBloodmoon" type="xs:boolean">
<xs:annotation>
<xs:documentation>Specifies if the simulation should be paused during blood moons</xs:documentation>
Expand Down

0 comments on commit bdc7f78

Please sign in to comment.