Skip to content

Commit

Permalink
allow setting a random seed, also include the windows steam directory…
Browse files Browse the repository at this point in the history
… as default in params
  • Loading branch information
comnom committed Dec 1, 2017
1 parent 8ae4ef6 commit d4c7d83
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 1 addition & 2 deletions core/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
from .ESParserPy.dataNode import DataNode

import random
import time



def Mission(params, allShips):
print("Building mission...")
root = DataNode()

uID = time.time()
uID = params.uID
mission = DataNode(tokens=["mission", "Gauntlet ({})".format(uID)])
root.Append(mission)

Expand Down
6 changes: 5 additions & 1 deletion core/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@


class Params(object):
def __init__(self, rootPath, dataNode):
def __init__(self, rootPath, uID, dataNode):
self.rootPath = rootPath
self.uID = uID
self.gamePath = ""

self.usePlugins = False
Expand Down Expand Up @@ -98,6 +99,9 @@ def Load(self, dataNode):
if child.Token(0) == "exclude":
for grand in child.Begin():
self.excludeShips.append(grand.Token(0))
elif key == "seed":
if node.Size() >= 2:
self.uID = node.Value(1)
else:
print("Unrecognized token " + key + " in params.txt")

7 changes: 6 additions & 1 deletion generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
from core.ESParserPy.getSources import GetSources

import os
import random
import sys
import uuid


def Init(params):
Expand Down Expand Up @@ -109,9 +111,11 @@ def Init(params):
input("Press enter to abort.")
sys.exit("Aborting...")

uID = uuid.uuid4().int
paramsFile = DataFile(thisDir + "/params.txt")
params = Params(thisDir, paramsFile.root)
params = Params(thisDir, uID, paramsFile.root)
paramsFile.root.Delete()
random.seed(params.uID)

if not params.gamePath.endswith("data"):
if params.gamePath.endswith("/") or params.gamePath.endswith("\\"):
Expand Down Expand Up @@ -169,3 +173,4 @@ def Init(params):
print("Done!")

input("Press enter to close.")

12 changes: 9 additions & 3 deletions params.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# "plugin path" The path to the plugin directory. Use forward slashes: /

paths
"game path" ""
"game path" "C:/Program Files (x86)/Steam/steamapps/common/Endless Sky/data"
"use plugins" 0
"plugin path" ""

Expand All @@ -42,7 +42,7 @@ galaxy
checkpoints 1
min 3
max 6
"healthpack frequency" 4000
"healthpack frequency" 8000


# "size":
Expand Down Expand Up @@ -81,7 +81,8 @@ weights


# Ships that won't be used to build the fleets.
# Ships with no category or a zero weight are excluded by default.
# Ships with no category or a zero weight are excluded by default.

ships
exclude
Boxwing
Expand All @@ -94,3 +95,8 @@ ships
"Surveillance Drone"
"Void Sprite"
"Void Sprite (Infant)"

# The "seed" for the random number generator. This is the number in () next
# to the mission name in mission.txt. If empty, the seed will be random.

seed ""

0 comments on commit d4c7d83

Please sign in to comment.