Author Topic: [D&D CharOp Software] Making a character generator (that supports constraints)  (Read 37754 times)

Offline Dictum Mortuum

  • Sr. Member
  • ***
  • Posts: 467
    • View Profile
Main idea: Make an application that can generate every possible combination of classes that fulfill certain requirements.

So, this is a big one. Anyone that possesses programming skills and would like to participate, please read the rest of the topic and post!

Recently I've been pondering on different builds using the interesting Court Herald class from Power of Faerun. The class has been pretty much under the radar, even though it's very interesting. It has steep skill requirements, so I went on a quest to get the best possible combination of base and prestige classes to be used as an entry.

At that point I thought that I've done the same thing so many times - checking if a particular class or classes have a certain skill or skills as class skills. So I thought: this process can be automated, at least at a certain level: if we had a database containing information on each class (and prestige class) and provided a set of requirements, it'd not be difficult to create a set of possible class combinations that could cover those requirements.

Programming Stuff Follows

Issues:

  • Front End: Most useful programs, eventually require a user-friendly environment. Obviously this is going to be the last to be developed.
  • Business Logic: Although it seemed pretty straightforward when I first thought of developping this application, actual, there are several issues to address. First of all assuming a large enough set of classes could result in a large number of results, so we'll have to be able to cut down on results somehow (probably enforcing level restrictions would work pretty well - e.g. I want my entry to use five to six levels). To add more, an algorithmic way of what to look first so that results can be cut down earlier must be developed, based on the requirements (e.g. lookup class skills or feats or spell requirements?). Finally I have no idea how the special abilities section of a class can be implemented.
  • Back End: This is an important issue. Should there be a database (which should be designed carefuly - then we could at least have a way of comparing special abilities between them - e.g. if we have abilities A and B that have different names that both make you eligible for prestige class X, it's easier to assosiate them in a database - in a plain text setup it's not that easy) or should we just have plain text collections and a parser? Easier for users to use and edit (if they need homebrew stuff), or just want to speed up/filter results (for people who dislike certain classes or they are banned in their games) and easier for developpers to maintain.

I've tried to do some preliminary work by creating a parser using the laja generator, so I'm currently working in Java. Before that I've pondered using multiple programming languages (even Prolog! :P) and I'm obiously open if there are better suggestions. I've gotten around creating a parser that is able to parse the following elements of a d&d class: name, hit die, BAB, saves, alignment(s), skill/level, skills. Special abilities could be easily added, but at a string-only level. I don't even want to contemplate how much of a headache incorporating spellcasting would be.

I'm going to stop here as it's late and I'm pretty tired. If you've got any suggestions or would like to participate, please post.
Dictum Mortuum's Handbooks: My personal character optimization blog.

Offline Rebel7284

  • Hero Member
  • ***
  • Posts: 706
    • View Profile
A small, well indexed, SQL database with lots of bridge tables for relationships could make a fairly easy to traverse backend.

Alternatively, an object oriented database may be more flexible, but those tend to be a bitch to query.

CREATE TABLE class_level (
id int primary key auto_increment,
name varchar(128),
level smallint,
comment varchar(1024),
);

CREATE TABLE skill_prerequisite (
id int primary key auto_increment,
class_id int foreign key references class_level.id,
skill_id foreign key references skills.id,
skill_ranks smallint
);

CREATE TABLE class_skills (
class_id int foreign key references class_level.id,
skill_id foreign key references skills.id
);

etc. etc. etc.

Offline ClayQ

  • Full Member
  • **
  • Posts: 127
  • Shhh, I'm hiding.
    • View Profile
Note to self; Check this thread when you've had more than 3 hours of sleep in the last 3 days.

Once I've had a chance to read the OP in more detail and think. I should be able to help at least some.
Something Funny?

Offline sirpercival

  • Epic Member
  • ****
  • Posts: 10855
  • you can't escape the miles
    • View Profile
My programming experience is in IDL, and some Visual Basic -- I'm happy to help, but it would likely be in data pre-processing.
I am the assassin of productivity

(member in good standing of the troll-feeders guild)

It's begun — my things have overgrown the previous sig.

Offline Rebel7284

  • Hero Member
  • ***
  • Posts: 706
    • View Profile
I think the first step is to make an entity-relationship type of diagram.

http://en.wikipedia.org/wiki/Entity-relationship_model

Making sure to specify correct cardinality is important.
« Last Edit: April 17, 2012, 11:50:21 AM by Rebel7284 »

Offline Dictum Mortuum

  • Sr. Member
  • ***
  • Posts: 467
    • View Profile
I think the first step is to make an entity-relationship type of diagram.

http://en.wikipedia.org/wiki/Entity-relationship_model

Making sure to specify correct cardinality is important.

So, are we going to use a database? My problem is that (it may sound kinda stupid :P) I don't know of a way to distribute a program with an integrated database (assuming mysql here, right?).

I'm assuming you'd like to help Rebel7284? If we get 2-3 more guys, we could start.
Dictum Mortuum's Handbooks: My personal character optimization blog.

Offline Prime32

  • Over-Underling
  • Retired Admin
  • *****
  • Posts: 2914
    • View Profile
So, are we going to use a database? My problem is that (it may sound kinda stupid :P) I don't know of a way to distribute a program with an integrated database (assuming mysql here, right?).
What's the trouble? Can't you just include the database with it? :???

Offline SorO_Lost

  • Epic Member
  • ****
  • Posts: 7197
  • Banned
    • View Profile
Main idea: Make an application that can generate every possible combination of classes that fulfill certain requirements.
that's about 130 steps father away than a more useful and realistic goal of a character generator that contains every printed PrC in it. So why not double up on that too? :D

I've tried to do some preliminary work by creating a parser using the laja generator, so I'm currently working in Java.
Correct me if I'm wrong since I don't really use Java, but it's syntax is based on C/C++ correct? So that mess of code for Iaja on the linked page doesn't look like Java at all. So why mess with it? Learn the real programming language it's self rather than self limiting knock off.

Now since Java is object oriented you could simply make the appropriate classes to handle and run the information and load/save the data however you please. SQL or a readable text file, doesn't matter except one is more user friendly as any user can edit text files.

Offline Rebel7284

  • Hero Member
  • ***
  • Posts: 706
    • View Profile
I think the first step is to make an entity-relationship type of diagram.

http://en.wikipedia.org/wiki/Entity-relationship_model

Making sure to specify correct cardinality is important.

So, are we going to use a database? My problem is that (it may sound kinda stupid :P) I don't know of a way to distribute a program with an integrated database (assuming mysql here, right?).

I'm assuming you'd like to help Rebel7284? If we get 2-3 more guys, we could start.

Yes I am in.  A bit busy with work and other stuff, but this project seems fun so it gets time anyway.

Really simple way to distribute an application with a database:
1. Make the front end in HTML/Javascript
2. Post it on the internet.

Everyone can access it instantly. :)

Just to clarify from the start. I assume you want to make a free application here, right?  The market for something like this is tiny anyway and the licensing involved with using WotC content is a nightmare otherwise unless you do Core-Only.

Edit:

As far as back end languages go, I vote PHP due to personal preference and ease of use with web apps.
« Last Edit: April 17, 2012, 04:16:32 PM by Rebel7284 »

Offline Dictum Mortuum

  • Sr. Member
  • ***
  • Posts: 467
    • View Profile
So, are we going to use a database? My problem is that (it may sound kinda stupid :P) I don't know of a way to distribute a program with an integrated database (assuming mysql here, right?).
What's the trouble? Can't you just include the database with it? :???

There probably is a way (as blade7284 mentions), however I've never done it before.

Main idea: Make an application that can generate every possible combination of classes that fulfill certain requirements.
that's about 130 steps father away than a more useful and realistic goal of a character generator that contains every printed PrC in it. So why not double up on that too? :D

I've tried to do some preliminary work by creating a parser using the laja generator, so I'm currently working in Java.
Correct me if I'm wrong since I don't really use Java, but it's syntax is based on C/C++ correct? So that mess of code for Iaja on the linked page doesn't look like Java at all. So why mess with it? Learn the real programming language it's self rather than self limiting knock off.

Now since Java is object oriented you could simply make the appropriate classes to handle and run the information and load/save the data however you please. SQL or a readable text file, doesn't matter except one is more user friendly as any user can edit text files.

When I say classes, I obviously mean prestige classes, too. The problem is working with the generator, which should work if your database has 10 classes or 100.

Java and C++ are more or less the same. They have their differences (some are major), but for the average user they're not really that important. Laja may look like it's not java, but it does generate java code in the end. So you just write this:

Code: [Select]
grammar classIndex {
    number = "0".."9"+;
    name = ("A".."Z" | "a".."z" | "_")+;
    lawChaos = "L" | "N" | "C";
    goodEvil = "G" | "N" | "E";
    bab = "1" | "0.75" | "0.5";
    alignment = lawChaos goodEvil;
    attr = "Str" | "Dex" | "Con" | "Int" | "Wis" | "Cha";
    skill = name "(" attr ")";
    skillsPerLevel = number;
    hitDie = "d" number;
    save = "Fort" | "Ref" | "Will";

    class = name "[" hitDie "][" bab "][" save [", " save]+ "][" alignment [", " alignment]+ "][" skillsPerLevel "][" skill [", " skill]+ "]";

    classIndex = class [ "\r\n" | "\n" class];

    Skill skill;
    skill.setName(String name);
    skill.setAttribute(String attr);

    Class class;
    class.setName(String name);
    class.setHitDie(String hitDie.number);
    class.setBAB(String bab);
    class.addSaves(String save);
    class.addAlignment(Alignment alignment);
    class.addSkill(Skill skill);
    class.setSkillsPerLevel(String skillsPerLevel);

    Alignment alignment;
    alignment.setLawChaosAxis(String alignment.lawChaos);
    alignment.setGoodEvilAxis(String alignment.goodEvil);

    ClassIndex classIndex;
    classIndex.addClass(Class class);
}

and you get an almost complete set of java classes: alignment, class, classIndex, skill. Which is what you mentioned, really :P It just saves a lot of time to write 20 lines and then compile, than 200 lines and then run :P

I think the first step is to make an entity-relationship type of diagram.

http://en.wikipedia.org/wiki/Entity-relationship_model

Making sure to specify correct cardinality is important.

So, are we going to use a database? My problem is that (it may sound kinda stupid :P) I don't know of a way to distribute a program with an integrated database (assuming mysql here, right?).

I'm assuming you'd like to help Rebel7284? If we get 2-3 more guys, we could start.

Yes I am in.  A bit busy with work and other stuff, but this project seems fun so it gets time anyway.

Really simple way to distribute an application with a database:
1. Make the front end in HTML/Javascript
2. Post it on the internet.

Everyone can access it instantly. :)

Just to clarify from the start. I assume you want to make a free application here, right?  The market for something like this is tiny anyway and the licensing involved with using WotC content is a nightmare otherwise unless you do Core-Only.

Edit:

As far as back end languages go, I vote PHP due to personal preference and ease of use with web apps.

I thought of that, but that means that we'll have to host it somewhere. And (I might be wrong) the computer that it's hosted on should be quite good, from a processing speed POV.

Just to clarify this, this project will be open source (we should use a licence), which means completely free and anyone that whishes to see/edit the code should be free to do so. Thus, to anyone that whishes to be involved, don't expect any income :P

PHP is fine for me, too.
Dictum Mortuum's Handbooks: My personal character optimization blog.

Offline SorO_Lost

  • Epic Member
  • ****
  • Posts: 7197
  • Banned
    • View Profile
Laja may look like it's not java, but it does generate java code in the end. So you just write this:
Code: [Select]
grammar classIndex {
    skillsPerLevel = number;
    class.setSkillsPerLevel(String skillsPerLevel);
}

and you get an almost complete set of java classes: alignment, class, classIndex, skill. Which is what you mentioned, really :P It just saves a lot of time to write 20 lines and then compile, than 200 lines and then run :P
Was that you or the generator getting confused on what an integer or string is?

And I guess Java just isn't as quick as C# because you can compile in a split second if you wanted to do compile checks and if you must have some sort of code handling program (opposed to the manly way of being able to use notepad) Express pretty much fixes everything syntax wise as you write it.

On the PHP note, yeah it would require a host and such. You can code everything using Javascript, including loading additional resources to some extent I think but I'd have to read up on it. But Javascript is a pain in the ass and I wouldn't suggest it. Java and such can be ran locally using the users resources and updated when they feel like it, it's probably the best route.

Offline nijineko

  • DnD Handbook Writer
  • ****
  • Posts: 2413
  • two strange quarks short of a graviton....
    • View Profile
    • TwinSeraphim
i'm interested in this project. my contributions are likely to be limited to conceptual, for the most part.

i was already planning on doing something similar using the crystalball lite software. though i think i was more aiming at a character sheet that would nicely add everything applicable with options for the optional stuff. also a generator for items and similar. error checking is also possible.

about some of the logic for generating possible entries, if you allow cross class skills to be counted in, as long as the final total is equal to 'x', then your possible combos climb massively. especially if you allow able learner feat to be set as a possibility. same for other early entry tricks involving races and odd feats and so forth. the number crunching alone is going to be interesting. detecting and excluding non-viable possibilities early on will be critical.

Offline SorO_Lost

  • Epic Member
  • ****
  • Posts: 7197
  • Banned
    • View Profile
about some of the logic for generating possible entries, if you allow cross class skills to be counted in, as long as the final total is equal to 'x', then your possible combos climb massively. especially if you allow able learner feat to be set as a possibility. same for other early entry tricks involving races and odd feats and so forth. the number crunching alone is going to be interesting.
Not really, should be a cakewalk. You're forgetting how easy it is for a computer to compare stuff in a list :p

Offline Dictum Mortuum

  • Sr. Member
  • ***
  • Posts: 467
    • View Profile
Laja may look like it's not java, but it does generate java code in the end. So you just write this:
Code: [Select]
grammar classIndex {
    skillsPerLevel = number;
    class.setSkillsPerLevel(String skillsPerLevel);
}

and you get an almost complete set of java classes: alignment, class, classIndex, skill. Which is what you mentioned, really :P It just saves a lot of time to write 20 lines and then compile, than 200 lines and then run :P
Was that you or the generator getting confused on what an integer or string is?

And I guess Java just isn't as quick as C# because you can compile in a split second if you wanted to do compile checks and if you must have some sort of code handling program (opposed to the manly way of being able to use notepad) Express pretty much fixes everything syntax wise as you write it.

On the PHP note, yeah it would require a host and such. You can code everything using Javascript, including loading additional resources to some extent I think but I'd have to read up on it. But Javascript is a pain in the ass and I wouldn't suggest it. Java and such can be ran locally using the users resources and updated when they feel like it, it's probably the best route.

Neither me, nor the generator. It's a way for the generator to know that this function has "text input", because you know... for obvious reasons, the parser parses... text :p Inside the parser the strings can be translated to other data types (like integer) and quite easily, too:

Code: [Select]
Integer.parseInt(String)
Err, notepad :p? I'm using a heavily customized IDE that fits my liking (Netbeans). But even then, just because you can type a c# program faster than a notepad user, isn't actually a metric to compare java and c# :p

I've never touched javascript, although I'm not against learning something new. I've used jsp and javaBeans before, that might be a valid idea.

i'm interested in this project. my contributions are likely to be limited to conceptual, for the most part.

i was already planning on doing something similar using the crystalball lite software. though i think i was more aiming at a character sheet that would nicely add everything applicable with options for the optional stuff. also a generator for items and similar. error checking is also possible.

about some of the logic for generating possible entries, if you allow cross class skills to be counted in, as long as the final total is equal to 'x', then your possible combos climb massively. especially if you allow able learner feat to be set as a possibility. same for other early entry tricks involving races and odd feats and so forth. the number crunching alone is going to be interesting. detecting and excluding non-viable possibilities early on will be critical.

Yes, there are a lot of complications like that - that's why I stress optimization so much - the problem grows exponentialy when you have 1 class level and then a huge branch factor of class levels to choose from.

I think that we should first consider what branches can be cut off first. This is a backtracking approach - first build a tree that is dynamicaly populated with children nodes that represent class levels. First we add all class levels and then we start cutting down results that are not compatible (because of skill, alignment restrictions and so on).

Example: say we've got a database that consists of class A, B and C. All those classes are 3 levels long.

Let's say that we're starting a search based on restriction 'R' that is only fulfilled if you have at least a level of A, B, C and 3 total levels.

Starting Point --- Nodes

1)
Code: [Select]
NewCharacter --- A1
              |--- B1
              |--- C1

2)
Code: [Select]
NewCharacter --- A1 --- A2
        |        |--- B1
        |        |--- C1
        |--- B1 --- B2
        |        |--- A1
        |        |--- C1
        |--- C1 --- C2
                 |--- A1
                 |--- B1

At this point we can cut down the branches that have more than one level in a certain class:

3)
Code: [Select]
NewCharacter --- A1
        |        |--- B1 --- C1
        |        |--- C1 --- B2
        |--- B1
        |        |--- A1 --- C1
        |        |--- C1 --- A1
        |--- C1
                 |--- A1 --- B1
                 |--- B1 --- A1
Dictum Mortuum's Handbooks: My personal character optimization blog.

Offline Maat Mons

  • DnD Handbook Writer
  • ****
  • Posts: 1203
  • What is a smile but a grimace of happiness?
    • View Profile
Is there an easy way to handle things that change a class skill list?  There are several class variants that alter skill lists.  The Cityscape web enhancement provides options for changing skill lists.  Several cleric domains change the cleric skill list.  There are feats (and the human paragon class) that make certain skills class skills for all classes, and also some that do it for only one class. 

Offline Dictum Mortuum

  • Sr. Member
  • ***
  • Posts: 467
    • View Profile
Is there an easy way to handle things that change a class skill list?  There are several class variants that alter skill lists.  The Cityscape web enhancement provides options for changing skill lists.  Several cleric domains change the cleric skill list.  There are feats (and the human paragon class) that make certain skills class skills for all classes, and also some that do it for only one class.

My proposal is that we can have a boolean list for each class level with all the available skills. That way we can easily make skills class/nonclass. The skill cap is different though - if a skill is class skill for one of your classes you can use the HD+3 cap (this is a clause from the player's handbook that works with Able Learner to make all skill virtually "class" skills).

Or we could, instead of using an all-skills-listed approach to just keep the class skills in a list and edit that list accordingly.
Dictum Mortuum's Handbooks: My personal character optimization blog.

Offline Rebel7284

  • Hero Member
  • ***
  • Posts: 706
    • View Profile
What is the domain of the data anyway?  Are we including feats (they are often used as prereqs after all?) Items? Races? etc.

What is some sample input and output?

Offline ClayQ

  • Full Member
  • **
  • Posts: 127
  • Shhh, I'm hiding.
    • View Profile
Interacting with the data is relatively easy once you've decided whats there, and made it.

We've got several options out there on what languages to code in and what not, but why don't we start with a data sample 3-5 classes then move up from there.

What is the domain of the data anyway?  Are we including feats (they are often used as prereqs after all?) Items? Races? etc.

What is some sample input and output?

Probably the most important question I've seen thus far in the thread, what input are we actually going to be giving the CharGen, and what are we expecting in return.

As for the language and program itself, a web based one is nice and all, but I can see why some might want it elsewhere. I've never used java to interact with a sql database however I'm sure its possible, a csv should be too.

I personally have familiarity with PHP, Java and SQL and am willing to help. I'd start this project by answering the question posed by rebel in the form of either a CSV or SQL database, once you've got that done you can then decide on which language to make your first CharGen out of. By taking this approach of I/O and Data first you could easily offer it up as open source as we're likely going to have to anyway and someone who doesn't like your C# or Java app could take the freely accessible data and make a php based web interface too.

A small sample of the data makes the actual programing and testing of a application easier anyway, and of course if we design the database we can always make a steamlined php based page for someone to enter the data for us while we worked on the actual CharGen, then included the completed database at a later date. So some without actual programing knowledge would be able to help us.



1) Desired Output - Be specific on possible outputs, and what we expect to get from the CharGen
2) Input - Be specific on what information we're giving it
3) Select a Database type and lay the groundwork for it - a CSV or a SQL database are my suggestions
4) Build a data entry GUI - so that a limited number of people (of the development team) can begin entery
5) The hard part....

Something Funny?

Offline sirpercival

  • Epic Member
  • ****
  • Posts: 10855
  • you can't escape the miles
    • View Profile
It'll also be a nice resource for homebrewers -- give them an idea of who can qualify for homebrewed PrCs.
I am the assassin of productivity

(member in good standing of the troll-feeders guild)

It's begun — my things have overgrown the previous sig.

Offline Dictum Mortuum

  • Sr. Member
  • ***
  • Posts: 467
    • View Profile
Since I started the thread, I'll elaborate on my thoughts/clear things out: let's say you're building a character and your mind is set on a specific prestige class; so you keep searching possible entry builds, until you go "wow, that's an original thought! I might try that out!". This is how I'd react if I found out that my druid could take levels in a full-casting prestige class that features full BAB and spellcasting, which was meant for paladins, just because it only requires ranks in diplomacy, handle animal and some BAB points.

Because certain prestige classes can have a large number of possible entries, it would be interesting if we could have a tool that could just list them all. If we could go one step further and add a feature that filters results based on source -  that way someone who has access to only certain books can find builds that he can use.

I'd say:
Input: A set of requirements. e.g.

Code: [Select]
skill(concentration, 8), skill(spellcraft, 8), skill(knowledge[Arcana], 8), spells(arcane, 1st), maxEntryLevel(5)
Output:A set of classes that fulfill the requirements. e.g.

Code: [Select]
Wizard 5, Wizard 4/Rogue 1, Wizard 4/Fighter 1, ...... , Sorcerer 5, Sorcerer 4/Barbarian 1, .....
Quite possibly, these results will be listed with a "rank" of some sorts. This will be a very-very loose concept and will not be absolute, probably based on the commandments of practical optimization (don't lose caster levels, etc :P).
Dictum Mortuum's Handbooks: My personal character optimization blog.