Add simulation defn files
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
All checks were successful
studiorailgun/trpg/pipeline/head This commit looks good
This commit is contained in:
parent
668f73d0a7
commit
e1daee0a1f
3
data/semantic/sent_func/greetings.txt
Normal file
3
data/semantic/sent_func/greetings.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Hello
|
||||
Hi
|
||||
Howdy
|
||||
5
data/sim/creature/elf.json
Normal file
5
data/sim/creature/elf.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name" : "elf",
|
||||
"singular" : "elf",
|
||||
"plural" : "elves"
|
||||
}
|
||||
5
data/sim/creature/human.json
Normal file
5
data/sim/creature/human.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name" : "human",
|
||||
"singular" : "human",
|
||||
"plural" : "humans"
|
||||
}
|
||||
10
data/sim/location/building.json
Normal file
10
data/sim/location/building.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"locations" : [
|
||||
{
|
||||
"name" : "Entrance"
|
||||
}
|
||||
],
|
||||
"dependencies" : [
|
||||
|
||||
]
|
||||
}
|
||||
8
data/sim/location/loc_def.json
Normal file
8
data/sim/location/loc_def.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"locations" : [
|
||||
|
||||
],
|
||||
"dependencies" : [
|
||||
"./data/sim/location/building.json"
|
||||
]
|
||||
}
|
||||
12
data/sim/region/region_def.json
Normal file
12
data/sim/region/region_def.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name" : "world",
|
||||
"childrenMandatory" : [
|
||||
|
||||
],
|
||||
"childrenOptional" : [
|
||||
|
||||
],
|
||||
"dependencies" : [
|
||||
|
||||
]
|
||||
}
|
||||
@ -9,6 +9,7 @@ import org.studiorailgun.ai.knowledge.CSVExport;
|
||||
import org.studiorailgun.ai.knowledge.KnowledgeWeb;
|
||||
import org.studiorailgun.sim.space.World;
|
||||
import org.studiorailgun.sim.character.Character;
|
||||
import org.studiorailgun.sim.config.Config;
|
||||
|
||||
/**
|
||||
* Global variables
|
||||
@ -35,6 +36,11 @@ public class Globals {
|
||||
*/
|
||||
public static Character playerCharacter;
|
||||
|
||||
/**
|
||||
* The simulation config
|
||||
*/
|
||||
public static Config config;
|
||||
|
||||
/**
|
||||
* Initializes the knowledge web
|
||||
*/
|
||||
@ -55,6 +61,9 @@ public class Globals {
|
||||
|
||||
//init convo
|
||||
Globals.conversation = Conversation.parse(Globals.web);
|
||||
|
||||
//load simulation config
|
||||
Globals.config = Config.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public class GreetingEval {
|
||||
*/
|
||||
public static void init(){
|
||||
try {
|
||||
greetingStrings = Files.readAllLines(new File("./data/sentence_function/greetings.txt").toPath());
|
||||
greetingStrings = Files.readAllLines(new File("./data/semantic/sent_func/greetings.txt").toPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -20,6 +20,11 @@ public class CharacterAppearance {
|
||||
*/
|
||||
CharaHead head;
|
||||
|
||||
/**
|
||||
* The race of the character
|
||||
*/
|
||||
String race;
|
||||
|
||||
/**
|
||||
* Gets the height of the character
|
||||
* @return The height of the character
|
||||
@ -68,8 +73,12 @@ public class CharacterAppearance {
|
||||
this.head = head;
|
||||
}
|
||||
|
||||
public String getRace(){
|
||||
return race;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setRace(String race){
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
src/main/java/org/studiorailgun/sim/config/Config.java
Normal file
57
src/main/java/org/studiorailgun/sim/config/Config.java
Normal file
@ -0,0 +1,57 @@
|
||||
package org.studiorailgun.sim.config;
|
||||
|
||||
import org.studiorailgun.sim.config.creature.CreatureDefManager;
|
||||
import org.studiorailgun.sim.config.space.LocationDefinitionManager;
|
||||
import org.studiorailgun.sim.config.space.RegionDefinitionManager;
|
||||
|
||||
/**
|
||||
* Config data for the simulator
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
/**
|
||||
* Manages the creature definitions
|
||||
*/
|
||||
CreatureDefManager creatureDefManager;
|
||||
|
||||
/**
|
||||
* Manages the location definitions
|
||||
*/
|
||||
LocationDefinitionManager locationDefinitionManager;
|
||||
|
||||
/**
|
||||
* Manages the region definitions
|
||||
*/
|
||||
RegionDefinitionManager regionDefinitionManager;
|
||||
|
||||
/**
|
||||
* Initializes the config object
|
||||
* @return The config object
|
||||
*/
|
||||
public static Config init(){
|
||||
Config rVal = new Config();
|
||||
|
||||
|
||||
//load sim data
|
||||
rVal.regionDefinitionManager = RegionDefinitionManager.loadManager();
|
||||
rVal.locationDefinitionManager = LocationDefinitionManager.loadManager();
|
||||
rVal.creatureDefManager = CreatureDefManager.loadManager();
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public CreatureDefManager getCreatureDefManager() {
|
||||
return creatureDefManager;
|
||||
}
|
||||
|
||||
public LocationDefinitionManager getLocationDefinitionManager() {
|
||||
return locationDefinitionManager;
|
||||
}
|
||||
|
||||
public RegionDefinitionManager getRegionDefinitionManager() {
|
||||
return regionDefinitionManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package org.studiorailgun.sim.config.creature;
|
||||
|
||||
/**
|
||||
* Defines a creature
|
||||
*/
|
||||
public class CreatureDef {
|
||||
|
||||
/**
|
||||
* The name of the creature type
|
||||
*/
|
||||
String name;
|
||||
|
||||
/**
|
||||
* The singular word for this type of creature
|
||||
*/
|
||||
String singular;
|
||||
|
||||
/**
|
||||
* The plural word for this type of creature
|
||||
*/
|
||||
String plural;
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSingular() {
|
||||
return singular;
|
||||
}
|
||||
|
||||
public void setSingular(String singular) {
|
||||
this.singular = singular;
|
||||
}
|
||||
|
||||
public String getPlural() {
|
||||
return plural;
|
||||
}
|
||||
|
||||
public void setPlural(String plural) {
|
||||
this.plural = plural;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
package org.studiorailgun.sim.config.creature;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.studiorailgun.FileUtils;
|
||||
|
||||
/**
|
||||
* Manages all the creature definitions
|
||||
*/
|
||||
public class CreatureDefManager {
|
||||
|
||||
/**
|
||||
* Path to the root folder
|
||||
*/
|
||||
static final String ROOT_FOLDER_PATH = "./data/sim/creature";
|
||||
|
||||
/**
|
||||
* Map of creature definition name -> creature definition
|
||||
*/
|
||||
Map<String,CreatureDef> definitions = new HashMap<String,CreatureDef>();
|
||||
|
||||
/**
|
||||
* Loads the location def manager
|
||||
* @return The location def manager
|
||||
*/
|
||||
public static CreatureDefManager loadManager(){
|
||||
CreatureDefManager rVal = new CreatureDefManager();
|
||||
|
||||
File dir = new File(ROOT_FOLDER_PATH);
|
||||
for(File defFile : dir.listFiles()){
|
||||
CreatureDef defn = FileUtils.loadObjectFromFile(defFile, CreatureDef.class);
|
||||
rVal.addDefinition(defn);
|
||||
}
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a location definition to the manager
|
||||
* @param file
|
||||
*/
|
||||
public void addDefinition(CreatureDef file){
|
||||
definitions.put(file.getName(), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location file by its name
|
||||
* @param name The name of the location
|
||||
* @return The definition if it exists, null otherwise
|
||||
*/
|
||||
public CreatureDef getDefinition(String name){
|
||||
return definitions.get(name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package org.studiorailgun.sim.config.space;
|
||||
|
||||
/**
|
||||
* Defines a location
|
||||
*/
|
||||
public class LocationDefinition {
|
||||
|
||||
/**
|
||||
* The name of the location definition
|
||||
*/
|
||||
String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package org.studiorailgun.sim.config.space;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationDefinitionFile {
|
||||
|
||||
/**
|
||||
* The list of locations
|
||||
*/
|
||||
List<LocationDefinition> locations;
|
||||
|
||||
/**
|
||||
* The location files that this file depends on
|
||||
*/
|
||||
List<String> dependencies;
|
||||
|
||||
public List<String> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
public List<LocationDefinition> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package org.studiorailgun.sim.config.space;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.studiorailgun.FileUtils;
|
||||
|
||||
/**
|
||||
* Manages the location definitions
|
||||
*/
|
||||
public class LocationDefinitionManager {
|
||||
|
||||
/**
|
||||
* Path to the root file
|
||||
*/
|
||||
static final String ROOT_FILE_PATH = "./data/sim/location/loc_def.json";
|
||||
|
||||
/**
|
||||
* The definitions
|
||||
*/
|
||||
Map<String,LocationDefinition> definitions = new HashMap<String,LocationDefinition>();
|
||||
|
||||
/**
|
||||
* Loads the location def manager
|
||||
* @return The location def manager
|
||||
*/
|
||||
public static LocationDefinitionManager loadManager(){
|
||||
LocationDefinitionManager rVal = new LocationDefinitionManager();
|
||||
|
||||
LocationDefinitionManager.recursivelyParse(rVal, ROOT_FILE_PATH);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively parses for location definition files
|
||||
* @param manager The manager
|
||||
* @param path The current root path
|
||||
*/
|
||||
private static void recursivelyParse(LocationDefinitionManager manager, String path){
|
||||
LocationDefinitionFile defFile = FileUtils.loadObjectFromFile(new File(path), LocationDefinitionFile.class);
|
||||
for(LocationDefinition def : defFile.getLocations()){
|
||||
manager.addDefinition(def);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a location definition to the manager
|
||||
* @param file
|
||||
*/
|
||||
public void addDefinition(LocationDefinition file){
|
||||
definitions.put(file.getName(), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location file by its name
|
||||
* @param name The name of the location
|
||||
* @return The definition if it exists, null otherwise
|
||||
*/
|
||||
public LocationDefinition getDefinition(String name){
|
||||
return definitions.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package org.studiorailgun.sim.config.space;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Defines a region type
|
||||
*/
|
||||
public class RegionDefinitionFile {
|
||||
|
||||
/**
|
||||
* The name of the region definition
|
||||
*/
|
||||
String name;
|
||||
|
||||
/**
|
||||
* The child regions which are mandatory for this region type
|
||||
*/
|
||||
List<String> childrenMandatory;
|
||||
|
||||
/**
|
||||
* The child regions which are optional for this region type
|
||||
*/
|
||||
List<String> childrenOptional;
|
||||
|
||||
/**
|
||||
* The region files that this file depends on
|
||||
*/
|
||||
List<String> dependencies;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<String> getChildrenMandatory() {
|
||||
return childrenMandatory;
|
||||
}
|
||||
|
||||
public List<String> getChildrenOptional() {
|
||||
return childrenOptional;
|
||||
}
|
||||
|
||||
public List<String> getDependencies() {
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
package org.studiorailgun.sim.config.space;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.studiorailgun.FileUtils;
|
||||
|
||||
/**
|
||||
* Manages the region definitions
|
||||
*/
|
||||
public class RegionDefinitionManager {
|
||||
|
||||
/**
|
||||
* Path to the root file
|
||||
*/
|
||||
static final String ROOT_FILE_PATH = "./data/sim/region/region_def.json";
|
||||
|
||||
/**
|
||||
* The definitions
|
||||
*/
|
||||
Map<String,RegionDefinitionFile> definitions = new HashMap<String,RegionDefinitionFile>();
|
||||
|
||||
/**
|
||||
* Loads the region def manager
|
||||
* @return The region def manager
|
||||
*/
|
||||
public static RegionDefinitionManager loadManager(){
|
||||
RegionDefinitionManager rVal = new RegionDefinitionManager();
|
||||
|
||||
RegionDefinitionManager.recursivelyParse(rVal, ROOT_FILE_PATH);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively parses for region definition files
|
||||
* @param manager The manager
|
||||
* @param path The current root path
|
||||
*/
|
||||
private static void recursivelyParse(RegionDefinitionManager manager, String path){
|
||||
RegionDefinitionFile def = FileUtils.loadObjectFromFile(new File(path), RegionDefinitionFile.class);
|
||||
manager.addDefinition(def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a region definition to the manager
|
||||
* @param file
|
||||
*/
|
||||
public void addDefinition(RegionDefinitionFile file){
|
||||
definitions.put(file.getName(), file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region file by its name
|
||||
* @param name The name of the region
|
||||
* @return The definition if it exists, null otherwise
|
||||
*/
|
||||
public RegionDefinitionFile getDefinition(String name){
|
||||
return definitions.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package org.studiorailgun.sim.space.gen;
|
||||
|
||||
import org.studiorailgun.Globals;
|
||||
import org.studiorailgun.sim.config.space.RegionDefinitionFile;
|
||||
import org.studiorailgun.sim.space.Region;
|
||||
|
||||
/**
|
||||
* Generates a region
|
||||
*/
|
||||
public class RegionGenerator {
|
||||
|
||||
/**
|
||||
* Generates a region
|
||||
* @param type The type of the region
|
||||
* @return The region
|
||||
*/
|
||||
public static Region generate(String type){
|
||||
Region rVal = new Region();
|
||||
RegionDefinitionFile def = Globals.config.getRegionDefinitionManager().getDefinition(type);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user