This commit is contained in:
austin 2025-01-05 12:32:07 -05:00
parent 33701b9be3
commit 38433108d3
26 changed files with 883 additions and 13 deletions

View File

@ -0,0 +1,2 @@
"utility","transfer","query","imperative","sentence"
1,0,0,0,"Hello"
1 utility transfer query imperative sentence
2 1 0 0 0 Hello

View File

@ -0,0 +1,2 @@
"look","transfer","query","imperative","sentence"
1,0,0,0,"Hello"
1 look transfer query imperative sentence
2 1 0 0 0 Hello

50
data/sim/emotions.json Normal file
View File

@ -0,0 +1,50 @@
[
{
"valence" : 0.0,
"arousal" : 0.0,
"dominance" : 0.0,
"name" : "Neutral"
},
{
"valence" : 1.0,
"arousal" : 0.0,
"dominance" : 0.0,
"name" : "Happy"
},
{
"valence" : 1.0,
"arousal" : 1.0,
"dominance" : 0.0,
"name" : "Joy"
},
{
"valence" : -0.5,
"arousal" : 0.5,
"dominance" : 0.3,
"name" : "Anger"
},
{
"valence" : 0.5,
"arousal" : 0.75,
"dominance" : -0.1,
"name" : "Surprise"
},
{
"valence" : -0.75,
"arousal" : 0.5,
"dominance" : 0.1,
"name" : "Digust"
},
{
"valence" : -0.75,
"arousal" : 0.75,
"dominance" : -0.75,
"name" : "Fear"
},
{
"valence" : -0.75,
"arousal" : 0.25,
"dominance" : -0.5,
"name" : "Sadness"
}
]

View File

@ -7,6 +7,8 @@ import org.studiorailgun.ai.conversation.parser.bank.LemmaBank;
import org.studiorailgun.ai.conversation.tracking.Conversation; import org.studiorailgun.ai.conversation.tracking.Conversation;
import org.studiorailgun.ai.knowledge.CSVExport; import org.studiorailgun.ai.knowledge.CSVExport;
import org.studiorailgun.ai.knowledge.KnowledgeWeb; import org.studiorailgun.ai.knowledge.KnowledgeWeb;
import org.studiorailgun.sim.space.World;
import org.studiorailgun.sim.character.Character;
/** /**
* Global variables * Global variables
@ -23,6 +25,16 @@ public class Globals {
*/ */
public static Conversation conversation; public static Conversation conversation;
/**
* The simulation world
*/
public static World world;
/**
* The player's character
*/
public static Character playerCharacter;
/** /**
* Initializes the knowledge web * Initializes the knowledge web
*/ */

View File

@ -1,5 +1,7 @@
package org.studiorailgun; package org.studiorailgun;
import org.studiorailgun.interact.GameLoop;
/** /**
* The main class * The main class
*/ */
@ -9,7 +11,7 @@ public class Main {
* The main method * The main method
*/ */
public static void main(String[] args){ public static void main(String[] args){
AgentLoop.main(); GameLoop.main();
} }
} }

View File

@ -1,13 +1,14 @@
package org.studiorailgun.ai.conversation.command; package org.studiorailgun.ai.conversation.command;
import org.studiorailgun.AgentLoop;
import org.studiorailgun.ai.conversation.llm.LLMLoop; import org.studiorailgun.ai.conversation.llm.LLMLoop;
import org.studiorailgun.ai.knowledge.CSVExport; import org.studiorailgun.ai.knowledge.CSVExport;
import org.studiorailgun.interact.AgentLoop;
import org.studiorailgun.interact.GameLoop;
/** /**
* Parses player commands to execute * Parses player commands to execute
*/ */
public class CommandParser { public class ConvCommandParser {
/** /**
* Parses the input for commands. If a valid command is recognized, returns true. Otherwise returns false. * Parses the input for commands. If a valid command is recognized, returns true. Otherwise returns false.
@ -18,6 +19,7 @@ public class CommandParser {
if(input.equals("exit")){ if(input.equals("exit")){
LLMLoop.running = false; LLMLoop.running = false;
AgentLoop.running = false; AgentLoop.running = false;
GameLoop.running = false;
} else if(input.equals("s hypo")){ //save a response failing to consider a hypothetical } else if(input.equals("s hypo")){ //save a response failing to consider a hypothetical
} else if(input.equals("s q")){ //save a question } else if(input.equals("s q")){ //save a question

View File

@ -2,7 +2,7 @@ package org.studiorailgun.ai.conversation.llm;
import java.util.Scanner; import java.util.Scanner;
import org.studiorailgun.ai.conversation.command.CommandParser; import org.studiorailgun.ai.conversation.command.ConvCommandParser;
import org.studiorailgun.kobold.KoboldPrinter; import org.studiorailgun.kobold.KoboldPrinter;
import org.studiorailgun.kobold.KoboldRequest; import org.studiorailgun.kobold.KoboldRequest;
@ -39,7 +39,7 @@ public class LLMLoop {
//handle player statement //handle player statement
prompt = scan.nextLine(); prompt = scan.nextLine();
if(CommandParser.parseCommands(prompt)){ if(ConvCommandParser.parseCommands(prompt)){
continue; continue;
} }
convo.addStatement(new Statement(player, prompt)); convo.addStatement(new Statement(player, prompt));

View File

@ -1,18 +1,14 @@
package org.studiorailgun; package org.studiorailgun.interact;
import java.util.Scanner; import java.util.Scanner;
import org.studiorailgun.Globals;
import org.studiorailgun.ai.conversation.ConvAI; import org.studiorailgun.ai.conversation.ConvAI;
import org.studiorailgun.ai.conversation.command.CommandParser; import org.studiorailgun.ai.conversation.command.ConvCommandParser;
import org.studiorailgun.ai.conversation.tracking.Quote; import org.studiorailgun.ai.conversation.tracking.Quote;
public class AgentLoop { public class AgentLoop {
/**
* The size of the context available
*/
static final int CONTEXT_SIZE = 32 * 1024;
/** /**
* Controls whether the main parser loop is running * Controls whether the main parser loop is running
*/ */
@ -34,7 +30,7 @@ public class AgentLoop {
//handle player statement //handle player statement
prompt = scan.nextLine(); prompt = scan.nextLine();
if(CommandParser.parseCommands(prompt)){ if(ConvCommandParser.parseCommands(prompt)){
continue; continue;
} }
Quote response = ConvAI.simFrame(prompt); Quote response = ConvAI.simFrame(prompt);

View File

@ -0,0 +1,48 @@
package org.studiorailgun.interact;
import java.util.Scanner;
import org.studiorailgun.Globals;
import org.studiorailgun.ai.conversation.ConvAI;
import org.studiorailgun.ai.conversation.command.ConvCommandParser;
import org.studiorailgun.ai.conversation.tracking.Quote;
import org.studiorailgun.sim.character.gen.PlayerCharSourcer;
import org.studiorailgun.sim.space.gen.WorldGenerator;
/**
* The game loop
*/
public class GameLoop {
/**
* Controls whether the main parser loop is running
*/
public static boolean running = true;
/**
* The main method
*/
public static void main(){
Globals.init("web.json");
Globals.world = WorldGenerator.generateWorld();
Globals.playerCharacter = PlayerCharSourcer.getPlayerCharacter();
try (Scanner scan = new Scanner(System.in)) {
String prompt = "";
System.out.println("Game is ready..");
//actual main loop
while(running){
//handle player statement
prompt = scan.nextLine();
if(ConvCommandParser.parseCommands(prompt)){
continue;
}
Quote response = ConvAI.simFrame(prompt);
System.out.println(response.getRaw());
}
}
}
}

View File

@ -1,8 +1,58 @@
package org.studiorailgun.sim.character; package org.studiorailgun.sim.character;
import org.studiorailgun.sim.character.emotion.EmotionData;
import org.studiorailgun.sim.character.vis.CharacterAppearance;
/** /**
* A reasoning entity being simulated in the game world * A reasoning entity being simulated in the game world
*/ */
public class Character { public class Character {
/**
* The id of the character
*/
int id;
/**
* The physical appearance of the character
*/
CharacterAppearance appearance;
/**
* The emotional data for the character
*/
EmotionData emotions;
/**
* Gets the appearance of the character
* @return The appearance of the character
*/
public CharacterAppearance getAppearance() {
return appearance;
}
/**
* Sets the appearance of the character
* @param appearance The appearance of the character
*/
public void setAppearance(CharacterAppearance appearance) {
this.appearance = appearance;
}
/**
* Gets the emotions of the character
* @return The emotions of the character
*/
public EmotionData getEmotions() {
return emotions;
}
/**
* Sets the emotions of the character
* @param emotions The emotions of the character
*/
public void setEmotions(EmotionData emotions) {
this.emotions = emotions;
}
} }

View File

@ -0,0 +1,71 @@
package org.studiorailgun.sim.character.emotion;
/**
* Contains emotion data about the character
*/
public class EmotionData {
/**
* How positive/negative the character is
*/
float valence;
/**
* How aroused the character is
*/
float arousal;
/**
* How dominant the character is
*/
float dominance;
/**
* Gets the valence of the character
* @return The valence of the character
*/
public float getValence() {
return valence;
}
/**
* Sets the valence of the character
* @param valence The valence of the character
*/
public void setValence(float valence) {
this.valence = valence;
}
/**
* Gets the arousal of the character
* @return The arousal of the character
*/
public float getArousal() {
return arousal;
}
/**
* Sets the arousal of the character
* @param arousal The arousal of the character
*/
public void setArousal(float arousal) {
this.arousal = arousal;
}
/**
* Gets the dominance of the character
* @return The dominance of the character
*/
public float getDominance() {
return dominance;
}
/**
* Sets the dominance of the character
* @param dominance The dominance of the character
*/
public void setDominance(float dominance) {
this.dominance = dominance;
}
}

View File

@ -0,0 +1,84 @@
package org.studiorailgun.sim.character.emotion;
/**
* A definition of an emotion
*/
public class EmotionDef {
/**
* The valence of the emotion
*/
float valence;
/**
* The arousal of the emotion
*/
float arousal;
/**
* The dominance of the emotion
*/
float dominance;
/**
* The name of this emotion
*/
String name;
/**
* Gets the valence of the emotion
* @return The valence of the emotion
*/
public float getValence() {
return valence;
}
/**
* Sets the valence of the emotion
* @param valence The valence of the emotion
*/
public void setValence(float valence) {
this.valence = valence;
}
/**
* Gets the arousal of the emotion
* @return The arousal of the emotion
*/
public float getArousal() {
return arousal;
}
/**
* Sets the arousal of the emotion
* @param arousal The arousal of the emotion
*/
public void setArousal(float arousal) {
this.arousal = arousal;
}
/**
* Gets the dominance of the emotion
* @return The dominance of the emotion
*/
public float getDominance() {
return dominance;
}
/**
* Sets the dominance of the emotion
* @param dominance The dominance of the emotion
*/
public void setDominance(float dominance) {
this.dominance = dominance;
}
/**
* Gets the name of this emotion definition
* @return The name of the emotion
*/
public String getName(){
return name;
}
}

View File

@ -0,0 +1,19 @@
package org.studiorailgun.sim.character.gen;
import org.studiorailgun.sim.character.Character;
/**
* Generates a character
*/
public class CharacterGenerator {
/**
* Generates a character
* @return The character
*/
public static Character generateCharacter(){
Character rVal = new Character();
return rVal;
}
}

View File

@ -0,0 +1,19 @@
package org.studiorailgun.sim.character.gen;
import org.studiorailgun.sim.character.Character;
/**
* Sources the player character (ie either by prompting the player, loading from file, generating, etc)
*/
public class PlayerCharSourcer {
/**
* Gets the player's character
* @return The player's character
*/
public static Character getPlayerCharacter(){
Character rVal = new Character();
return rVal;
}
}

View File

@ -0,0 +1,50 @@
package org.studiorailgun.sim.character.gen.params;
/**
* Parameters for the character generator
*/
public class CharacterGeneratorParams {
/**
* The race of the character
*/
String race;
/**
* The sex of the character
*/
String sex;
/**
* Gets the race param
* @return The race
*/
public String getRace() {
return race;
}
/**
* Sets the race param
* @param race The race param
*/
public void setRace(String race) {
this.race = race;
}
/**
* Gets the sex param
* @return The sex param
*/
public String getSex() {
return sex;
}
/**
* Sets the sex param
* @param sex The sex param
*/
public void setSex(String sex) {
this.sex = sex;
}
}

View File

@ -0,0 +1,31 @@
package org.studiorailgun.sim.character.vis;
/**
* A description of the physical characteristics of the eye of a character
*/
public class CharaEyes {
/**
* The color of the eyes
*/
String color;
/**
* Gets the color of the eyes
* @return The color of the eyes
*/
public String getColor() {
return color;
}
/**
* Sets the color of the eyes
* @param color The color of the eyes
*/
public void setColor(String color) {
this.color = color;
}
}

View File

@ -0,0 +1,52 @@
package org.studiorailgun.sim.character.vis;
/**
* A description of the physical characteristics of the hair of a character
*/
public class CharaHair {
/**
* The color of the hair
*/
String color;
/**
* The style of the hair
*/
String style;
/**
* Gets the color of the hair
* @return The color of the hair
*/
public String getColor() {
return color;
}
/**
* Sets the color of the hair
* @param color The color of the hair
*/
public void setColor(String color) {
this.color = color;
}
/**
* Gets the style of the hair
* @return The style of the hair
*/
public String getStyle() {
return style;
}
/**
* Sets the style of the hair
* @param style The style of the hair
*/
public void setStyle(String style) {
this.style = style;
}
}

View File

@ -0,0 +1,52 @@
package org.studiorailgun.sim.character.vis;
/**
* A description of the physical characteristics of the head of a character
*/
public class CharaHead {
/**
* The description of the eyes
*/
CharaEyes eyes;
/**
* The description of the hair
*/
CharaHair hair;
/**
* Gets the eye data
* @return The eye data
*/
public CharaEyes getEyes() {
return eyes;
}
/**
* Sets the eye data
* @param eyes The eye data
*/
public void setEyes(CharaEyes eyes) {
this.eyes = eyes;
}
/**
* Gets the hair data
* @return The hair data
*/
public CharaHair getHair() {
return hair;
}
/**
* Sets the hair data
* @param hair The hair data
*/
public void setHair(CharaHair hair) {
this.hair = hair;
}
}

View File

@ -0,0 +1,75 @@
package org.studiorailgun.sim.character.vis;
/**
* Container for the appearance of a character
*/
public class CharacterAppearance {
/**
* The height of the character
*/
float height;
/**
* The weight of the character
*/
float weight;
/**
* Describes the head of the character
*/
CharaHead head;
/**
* Gets the height of the character
* @return The height of the character
*/
public float getHeight() {
return height;
}
/**
* Sets the height of the character
* @param height The height of the character
*/
public void setHeight(float height) {
this.height = height;
}
/**
* Gets the weight of the character
* @return The weight of the character
*/
public float getWeight() {
return weight;
}
/**
* Sets the weight of the character
* @param weight The weight of the character
*/
public void setWeight(float weight) {
this.weight = weight;
}
/**
* Gets the appearance data of the head of the character
* @return The appearance data of the head of the character
*/
public CharaHead getHead() {
return head;
}
/**
* Sets the appearance data of the head of the character
* @param head The appearance data of the head of the character
*/
public void setHead(CharaHead head) {
this.head = head;
}
}

View File

@ -0,0 +1,34 @@
package org.studiorailgun.sim.item;
/**
* An item
*/
public class Item {
/**
* The id of the item
*/
int id;
/**
* The type of item
*/
String type;
/**
* Gets the type of the item
* @return The type of the item
*/
public String getType() {
return type;
}
/**
* Sets the type of the item
* @param type The type of the item
*/
public void setType(String type) {
this.type = type;
}
}

View File

@ -0,0 +1,64 @@
package org.studiorailgun.sim.space;
import java.util.LinkedList;
import java.util.List;
import org.studiorailgun.sim.character.Character;
import org.studiorailgun.sim.item.Item;
/**
* An area contains characters, items, etc.
* It can also contain other areas recursively.
*/
public class Location {
/**
* The id of the location
*/
int id;
/**
* The characters currently in this region
*/
transient List<Character> chars = new LinkedList<Character>();
/**
* The items in the location
*/
transient List<Item> items = new LinkedList<Item>();
/**
* Gets the characters in this location
* @return The characters in this location
*/
public List<Character> getChars() {
return chars;
}
/**
* Sets the list of characters in this location
* @param chars The list of characters in this location
*/
public void setChars(List<Character> chars) {
this.chars = chars;
}
/**
* Gets the list of items in this location
* @return The list of items in this location
*/
public List<Item> getItems() {
return items;
}
/**
* Sets the list of items in this location
* @param items The list of items in this location
*/
public void setItems(List<Item> items) {
this.items = items;
}
}

View File

@ -0,0 +1,63 @@
package org.studiorailgun.sim.space;
import java.util.LinkedList;
import java.util.List;
/**
* A recursive tree of regions that contain locations at their leaves
*/
public class Region {
/**
* The child reglions of this region
*/
transient List<Region> children = new LinkedList<Region>();
/**
* The location data for this leaf node
*/
Location leaf;
/**
* Gets the child regions of this region
* @return The list of child regions
*/
public List<Region> getChildren() {
return children;
}
/**
* Sets the list of child regions of this region
* @param children The new list of child regions
*/
public void setChildren(List<Region> children) {
this.children = children;
}
/**
* Gets the leaf location of this region
* @return The leaf location of this region
*/
public Location getLeaf() {
return leaf;
}
/**
* Sets the leaf location of this region
* @param leaf The leaf location of this region
*/
public void setLeaf(Location leaf) {
this.leaf = leaf;
}
/**
* Adds a child region
* @param child The child region
*/
public void addChild(Region child){
children.add(child);
}
}

View File

@ -0,0 +1,29 @@
package org.studiorailgun.sim.space;
/**
* Top level spatial container
*/
public class World {
/**
* The top level region
*/
Region region;
/**
* Gets the top level region of this world
* @return The top level region of this world
*/
public Region getRegion() {
return region;
}
/**
* Sets the top level region of this world
* @param region The top level region of this world
*/
public void setRegion(Region region) {
this.region = region;
}
}

View File

@ -0,0 +1,20 @@
package org.studiorailgun.sim.space.gen;
import org.studiorailgun.sim.space.Region;
/**
* Generates buildings
*/
public class BuildingGenerator {
/**
* Generates a building
* @return The building region
*/
public static Region generateBuilding(){
Region rVal = new Region();
return rVal;
}
}

View File

@ -0,0 +1,23 @@
package org.studiorailgun.sim.space.gen;
import org.studiorailgun.sim.space.Region;
/**
* Generates a town
*/
public class TownGenerator {
/**
* Generates a town
* @return A town
*/
public static Region generateTown(){
Region rVal = new Region();
Region building = new Region();
rVal.addChild(building);
return rVal;
}
}

View File

@ -0,0 +1,20 @@
package org.studiorailgun.sim.space.gen;
import org.studiorailgun.sim.space.World;
/**
* Generates a world
*/
public class WorldGenerator {
/**
* Generates a world
* @return The world
*/
public static World generateWorld(){
World rVal = new World();
return rVal;
}
}