Creating a sex-system like in CoC, Lilith's Throne, or Degree's of Lewdity

xj47

Member
Nov 4, 2017
241
409
Hey,

I'm interested in creating a game with a text-based generic sex system like in CoC, Lilith's Throne, or DoL.
Something where an event gets triggered with generic characters and the sex-scene gets played out over multiple "turns" with clothing removal and 'object' insertion.

Now, I consider myself a pretty experienced programmer and am confident in my ability to build a system like that from scratch, but it does sound like a lot of work and I don't want to reinvent the wheel if I don't have to.

Does anyone know if there's any existing framework someone has created that I can freely incorporate into personal projects?
That or if one of the projects with such a system allows people to copy code.
 
  • Like
Reactions: Daba

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
Does anyone know if there's any existing framework someone has created that I can freely incorporate into personal projects?
That or if one of the projects with such a system allows people to copy code.
Hmm, since you don't give the game engine(s) for which such framework(s) should be, and so don't offer the possibility for someone to give you an effective answer, why you just don't contact CoC, Lilith's Throne or DoL teams, to know if they allow you to copy their code ?
 
  • Like
Reactions: Lranja

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,607
2,256
CoC (Corruption of Champions) from what I remember is HTML. It's appeal is less the engine and more about the story structure and gameplay.
It may even be Twine for all I know (which I believe generators HTML).

Lilith's Throne is apparently Java. And is frequently recommended in the Corruption of Champions II game thread.

DoL seems to be Degrees of Lewdity. Another HTML game.
Edit: D'oh... the name being in the thread title should have been a bit of a clue for me.


Honestly, I haven't played any of them - so can't speak to how clever or intricate their game mechanics are. I tried CoC once, because it's so highly regarded... but I guess I've gotten too comfortable with playing RenPy games and couldn't get past the feeling that I was playing a game on a 1998 version of Geocities.

I will do my usual thing at this point and point out that RenPy has something called . Which can create a largely text based game rather than "images with subtitles". Scrolling text, back tracking, etc.

As far as a common set of libraries or functions, or some prototype framework... Sorry, nothing I can speak to. Especially since I have no experience of those three games to think of anything similar.

I thought HTML, by its very nature, included the code that runs the game? Is it possible to reverse engineer something directly out of there?

Personally, I'd reinvent the wheel... and do it in RenPy as a full AVN rather than being purely text based. But in part, that's more about my lack of imagination than anything else.

Anyway... this post was more about explaining what "CoC" and "DoL" were and which engines they use.
 
Last edited:

Jofur

Member
May 22, 2018
251
272
I doubt there is one out there. It's a pretty niche and specialized thing. And probably something that would be better made on a per-game bases over a framework.
Then again I've always disliked using large frameworks so maybe I'm just biased.

CoC (Corruption of Champions) from what I remember is HTML.
I think it uses good old Adobe Flash.
 
  • Like
Reactions: kisa1234

xj47

Member
Nov 4, 2017
241
409
Hmm, since you don't give the game engine(s) for which such framework(s) should be, and so don't offer the possibility for someone to give you an effective answer, why you just don't contact CoC, Lilith's Throne or DoL teams, to know if they allow you to copy their code ?
I'm more interested in how other games organize this system in terms of classes and variables and whatnot, don't need to literally copy-paste stuff hence the exact engine isn't that important to me.

I agree that just contacting some devs is probably the way to go though.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
I'm more interested in how other games organize this system in terms of classes and variables and whatnot, [...]
What still totally depend of the game engine, language and, to some extent, the save capabilities.
The prototyping abilities of JavaScript will lead to a code totally different to the one you would have with Python. C/C++/C# offer a total freedom that will lead to yet another approach, while a game engine like LÖVE that rely on LUA will have an approach radically different to the three others. It will be in yet a different way if the code have to handle all the INPUT/OUTPUT, than if the game engine take care of them. And the whole algorithm will be different if you can save by serializing all your class or if you need to save value by value.

Blindly looking at how others do will not really help you. At best it will be mostly useless, and at worse it confuse you, letting you go on a way that isn't at all adapted to the game engine/language you'll use.
 

xj47

Member
Nov 4, 2017
241
409
What still totally depend of the game engine, language and, to some extent, the save capabilities.
<snip>

Blindly looking at how others do will not really help you. At best it will be mostly useless, and at worse it confuse you, letting you go on a way that isn't at all adapted to the game engine/language you'll use.
I respectfully disagree.
Most programming languages aren't that different. You can fairly accurately describe languages as being statically or dynamically typed and either object-oriented, functional, or procedural. And almost everything these days is object-oriented so that narrows things down even more.
It is possible for an engine to be so different that an algorithm/system can't be translated at all, but it is pretty rare.

And on a more general note, there are plenty of algorithms or systems that if you look them up online just get explained in a high-level non-language specific way. "Pseudo code" is often used precisely because a programs logic can be described independently of any languages precise syntax and rules.
 

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,011
An open source framework for lewd interactions? Sounds like a neat idea.

While there are some projects I am vaguely aware of (like skyrim's osex), if you are mostly interested in studying these frameworks: ie
I'm more interested in how other games organize this system in terms of classes and variables and whatnot, don't need to literally copy-paste stuff hence the exact engine isn't that important to me.
then the more dedicated projects aren't really an answer, as its more like a software suit rather than just some classes (that you can't even view the code for anyways).

I imagine for a lot of other games, devs don't like to share too much on code, besides the usual 'copyright' reason I think most of the time its that you forget how it even worked, and you don't want to be responsible with maintaining a page for some code that you don't even think is that special. I know that as much as I like to make and talk about code, For any serious projects, I hesitate to share things, mainly out of fear of such systems being abused for lower quality projects.

For my own project, I'm hoping to get around the issue of sharing cool ideas in raw code form, to instead have a game that acts more like a tool, to not just allow for modding of the game (the project), but allow people to customize and make their own games (the project originally started out as a Roleplaying software for my roleplaying group to make more interactive and automated campaigns with). The sex system isn't in code yet, but the plan is in place. Right now, due to how complex it is, I'm having to create my own database software, so that it's not only easy for me to manage and create all the class instances, but make it easier for others to make custom systems without needing touch code (but you can still inherant the raw class, look into the class, and just deserialize the database to instantiate the classes, using the database tool as a project viewer without needing it to be in the form of text files, seeing how all the instances relate an interact in real time).

If your thinking about cantacting devs, are you more interested in learning how a 'particular' game did its system, or just more, learning the concept of how such systems could be implemented in different ways, or talking with fellow devs on developing ways to execute a sex system?
 
  • Like
Reactions: Daba

xj47

Member
Nov 4, 2017
241
409
If your thinking about cantacting devs, are you more interested in learning how a 'particular' game did its system, or just more, learning the concept of how such systems could be implemented in different ways, or talking with fellow devs on developing ways to execute a sex system?
I mean, my hope is that an existing game has a generic sex mini-engine that I can port and adapt to my own uses. Baring that, just seeing how they implemented it might give me ideas on how I should implement it.

I took a look at the Lilith Throne code (since it's public on github) but I think it's too specialized for their game. Or rather, a lot of mechanics are hardcoded which would make it awkward to adapt even if I got permission.

idk, I'll probably just write my own thing. Might not be as much work as I think.

Maybe I'm wrong but QSP framework? (ain't played those game tho)
From what I can tell QSP is more of a general engine. Doesn't look like what I'm looking for.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
I respectfully disagree.
Most programming languages aren't that different.
You can fairly accurately describe languages as being statically or dynamically typed and either object-oriented, functional, or procedural.
What change nothing to the fact that each one have its particularities and, due to them, their own way to implements a given algorithm.
Of course, the more languages you'll know, the easier you'll be able to understand what a code do. But the problem do not rely on what it do, but on why it do it ; and this "why" is the most important information, because it's what make the code be efficient and bug free.
If you really think that looking at a C++ code could tell you how to implement something in Python or Perl, by example, you're wrong. All you'll know is how the algorithm is implemented accordingly to C++ specificities, but porting it as it would be an error, because you'll not benefit from the strength of the language and perhaps rely on its weaknesses.

By example, Perl have one of, if not the, most efficient regEx implementation. This imply that if you design your class correctly, with Perl something like:
Code:
switch( girlName ):
{
    case "anna":
        girl = annaObject
    case "sarah":
        girl = sarahObject
    [...]
}

switch( action )
{
    case "handjob":
        girl.hanjob()
    case "blowjob":
        girl.blowjob()
    case "analsex":
        girl.analsex()
    case "analsex":
        girl.sex()
}
would become this single line $reftab{girlName}->{$1}() if action =~ /^((?:hand|blow)job|(?:anal)sex)$/;. It would do the exact same, and do it way faster that the original implementation.


And almost everything these days is object-oriented so that narrows things down even more.
Oh... So in C++ you can have this (and have it this easily):
Code:
class Girls( object ):
    [...]
    def registerGirl( self, name, data={} ):
        self.data[name] = data

    def addGirl( self, name ):
        def inner( self, command ):
            getattr( self, command )( name )
        setattr( self, name, inner )
to dynamically extend your object, adding a method that will act as proxy to all its methods, exactly like if you created a new object for a new girl.
And obviously, like all the girls are now available through a method added to the same object, sharing the game context between them isn't anymore a problem. All the information are part of the object that host all of them. This while you can add as many girls as you want without having to create a new object or change your class.

So, no, most languages being object oriented don't at all narrow things. You cannot even expect this to help you understand the code you'll see. Due to its duck typing compliance, Python magic methods permit to radically change the behavior of any object ; including the most basic ones, since in Python even numbers are objects.
You can have integers that will in fact only return prime numbers, and then 5 + 1 = 7 or 23 + 2 = 31 will be a natural behavior. If the algorithm rely massively on prime numbers, you'll look at the code, see myVar += 1 and expect that "myVar" value is now one unit bigger, while it will in fact now have as value the next prime number. And obviously porting the algorithm as it will never works for you, because you missed the magic behind the scene ; a magic that happen and is defined in a totally different part of the code, one where you haven't looked.
You can also have integers that are bounded (there's even the code for that somewhere here). What mean that there will be no boundary test in the code you'll see. You'll implement it as it, and have a bugged system every time the value will goes further than handled by the algorithm.
You can have myString = "anna" while print( myString ) will return "Hello, my name is Anna, glad to met you", the first time, while the second print( myString ) will return "Oh, hello again, how are you today ?".
While it's not necessarily used this often, all this is the natural behavior that one should expect to be possible when looking at Python code. Then, it's not just the implementation of the system that you have to look at, it's the whole code, to be sure that values are what they looks like.

And each language have this kind of particularities that make the code you'll see not do what you think it do.


I imagine for a lot of other games, devs don't like to share too much on code, besides the usual 'copyright' reason I think most of the time its that you forget how it even worked, and you don't want to be responsible with maintaining a page for some code that you don't even think is that special.
Most of the time, especially on an amateur scene like this one, the reason is probably way more simple.

In the early 2000, Luu Tran made XNews, what was the best Usenet newsreader ever made for Windows. It was 100% free, but he always refused to release the source. I don't remember his exact words, but it goes more or less like this: "I'm not good enough, I don't want you to see the mess I made for this to works".
It's like ducks, so calm and gracious when you look at them swinging on the pound... and in the same time so furiously moving their legs because they are against the current. Devs prefer to hear, "wow, I really love your game", than, "OMFG your code is so horrible".
 

xj47

Member
Nov 4, 2017
241
409
Your example is overly specific.
Take this python code:
Python:
class EchoProps(object):
    def getattr(self,key):
        return key + "Key"

obj = EchoProps()
print(obj.something) # prints "somethingKey"
Could I port this directly to C++? No. They aren't literally the same language.
But wtf is the point of this weird ass code?
If the purpose is to append "Key" to the end of a string then that's trivial to do in C++

Similar thing with your python example.
It can't be implemented the exact same way, but if you want a place to store girl info then that's easy.
Just create a dictionary-type object of GirlData objects where GirlData is whatever you want stored.
 
  • Like
Reactions: LS47 and HiEv

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,011
It's like ducks, so calm and gracious when you look at them swinging on the pound... and in the same time so furiously moving their legs because they are against the current. Devs prefer to hear, "wow, I really love your game", than, "OMFG your code is so horrible".
Lol, yep, I totally get that.

It also reminds me of something that always bugs me. When people complement a game or project, now that I have the perspective on how much work it is to make this kinds of projects and the stress with trying to go public, I find that most complements are actually kind of insulting.

Say someone says your game is good, or they say that it was a great idea, or that it was well made; each of these are a gross simplification of all the work done. Not just the time end effort, but it wasn't one good idea, it was a serious of choices and design consideration that leads to success, not just one thing.

I mean, my hope is that an existing game has a generic sex mini-engine that I can port and adapt to my own uses.
The few I have seen, in their raw code form, tends to be when I'm helping other projects. There isn't a good 'generic sex mini-engine' because
  1. I haven't seen anyone make a good one yet, and
  2. even if its just a mini-engine, such as its just a mini game mechanic for a sex scene, the issue I have seen with them that could make them look 'specialized' is that in order to operate they need a character datatype to use.
it seems what you and anne O'nymous are talking about is the age old talk of, identifying and isolating the 4 levels of a system's abstraction, from raw code, to how its designed (assuming OOP paradigm), the core goal and the philosophy of its design.

I'm a huge C# fan, so I'll just go with OOP paradigm, since thats most of what I've seen for projects related to your posting questing

with anne O'nymous example that uses switch statements, that form is something I mostly see with Ren'py projects. I don't work on Ren'py project so I'm only loosely associating the idea, but what I've seen, is that to control the ren'py engine and load up scenes and what not, the code isn't too complex, getting a few state variables and trying to figure out what image to show next. What I don't see with ren'py games (and feel to correct me on this anne O'nymous), is serious implementation of custom and complex data types.

When I say, custom and complex, I mean something as simple as having a object class made to represent an idea, such as being a container for data, and then simply making different instantiations with different data that you can swap in and out to make new game content.

For example, I would usually start by breaking down a sex-engine system into 5 parts:
  1. A) Interface class
  2. B) Engine Core class
  3. C) Context Class,
  4. D) Specific Data (character) class,
  5. E) user class.
The interface class would be the class that other devs would rip apart, as it acts as the intermediary class between their code, and my code, a type of 'wrapper' object or API system. It connects to the Engine core. The engine core is at the center, and it connects to the other 3 classes. I won't bother elaborating too much, but for me the core idea is modularity.

For me, modularity is, being able to tell the engine what scene to load up, all it needs to do is bring the scene to life.

So with a class that represents a character, not only do we tell the engine what character to load into the scene, but if that is a character class with room more more complex data and actions (sexual preferences, or a system for having a character react and give feed back to player actions, feeding said reaction into the engine), then we can have a more powerful system where each character can be described in detail, be unique, etc. and it all gets packaged nicely into these single class text files, rather than some table bloated up somewhere.

As for the code for the actual engine itself, For me at least, its not possible to just have the engine contained in a single class file. It would be nice and readable, but for most ideas I see people want to implement (ie a context class that acts as a story director that tries to guide the situation to fit a narrative ie instructing the NPC that this is an anal scene or limiting what the player can do or is unlocked ) the list of things they want to achieve would bloat the file into a huge wall of text, so the engine becomes a collection of ideas and mechanics. Its the reason I'm making a custom database system for my own project, because the engine is becoming too big to mentally visualize it without a visual map of it, and I'd like to see how data is propagating through the engine. (it also doesn't help that I love making my code look minimal, buy using a 4 level ghost inheritance system)

So is there such an engine? I've seen some stuff on loverslab but I don't really hang out there, too niche, if there were one however, I would worry about a few things, One being that it probably wouldn't be documented, Two even if you go through the code and figure out what its trying to do, and you do implement it, without documentation it can be a hassle not only to use it, but to actually take full advantage of the engine.

another issue is, for projects I've help with, the sex engine isn't isolated, it starts to become interconnected to other systems. Say its a dating sim, and bit by bit you unlock a character's kinks or willingness. Well you need to keep track of the player's data some how, either with a data class for the progress (of the player), or a messy class that keeps track of all the data, or my preferred, a class for each character to keep track of data individually. But even if I can convince a team the benefits of classes made for characters, they then want one master class for each character, bloating up the original character class, when what should be done for better modularity is, have a character class made for each mini engine, and intermediary-engines that convert one class into another class. ie, a class that keeps track of a characters relationship gets fed into an transformation engine that spits out a generated character class that represents what that character data means in terms of sex mechanics, and then feed that to the sex engine. This way you can see all the systems and data as isolated chunks (my database viewer is literally trying to show these as sticky notes), and you can see how you can cut away parts of a game or where you can add in new systems, without fear of having to mess with code related to other parts of the game (avoiding spaghettis code that cripples the UI system or something).

So I don't know if there's an engine, and I fear most code you'll find isn't partitioned well to make it easy to analyze the engine and extract the engine.

but in case you can't tell, I am more than interested in discussing such systems :D
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
Your example is overly specific.
As is any efficient code designed to works as "system". Even a framework would be overly specific... to the way its author see the system being implemented and the engine for which it's made.


It can't be implemented the exact same way, but if you want a place to store girl info then that's easy.
Once again you missed the point. The goal isn't to store the girls data, but to design the whole data system in a way that is both robust, easy to handle and easy to use. And this radically change the algorithm used, as seen from the code point of view.



Say someone says your game is good, or they say that it was a great idea, or that it was well made; each of these are a gross simplification of all the work done. Not just the time end effort, but it wasn't one good idea, it was a serious of choices and design consideration that leads to success, not just one thing.
Yeah, saying that "it's good" make it feel like it was easy to do.
It's like old school movies animators. For Shreck, by example, some of them jumped in mud pound just to have a better understanding regarding how it react, in order to do it right on screen. There's also the Disney golden age, with the studios full of living animals to help the animator to create believable animorphs.
So, yeah, "it's good... If you knew what I had to do for this to be 'good'..."


even if its just a mini-engine, such as its just a mini game mechanic for a sex scene, the issue I have seen with them that could make them look 'specialized' is that in order to operate they need a character datatype to use.
Whatever you design the data first and the system once it's done, or the opposite, the algorithm you'll get will always be 100% specialized for those data.
With its stores, Ren'Py offer an access to multiple data spaces from a single code space. Almost no games use this approach, but it create a level of data isolation that radically change the way you'll deal with them, and therefore the algorithm you'll use.


it seems what you and anne O'nymous are talking about is the age old talk of, identifying and isolating the 4 levels of a system's abstraction, from raw code, to how its designed (assuming OOP paradigm), the core goal and the philosophy of its design.
One of, if not the, the base of algorithm design: do you want something easy to implement, or something easy to use ?
Choice wisely, you can't have both. The first one will not be easy to use, and the second not be easy to implement. And of course, "easy" will totally depend of the language.


What I don't see with ren'py games (and feel to correct me on this anne O'nymous), is serious implementation of custom and complex data types.
I agree. Not that it's impossible, but it goes above the knowledge of most coders on the scene. They are mostly amateurs, most professionals ones goes for engines that feel more professionals. Therefore they tend to stay at a level of data types they fully understand.

And in fact I think that even professionals stay to a "low level" of data type, because they can afford to. I'm rewriting my variable viewer, and I'm still unsure if I want to use objects that would handle everything, or stay on the list of strings approach I initially used.
For the first version such simplicity was a need, because at this time I was still discovering Ren'Py and it's way to deal with data. So, keeping it simple was the best way to not being stuck at some point. But now that I have 3 years of use proving me that it works fine that way, I wonder if I want to make my life harder by using a complex data type that I'll only use once, or harder by dealing with a basic data type that will need more attention.
One of the approach will be a bit less hard than the other, and I highly suspect that it's the basic data type.

This apply even more when it come to games released by updates. There's not much possibilities:
  • You dedicate one year to the design of your data type, releasing nothing, not even effectively working on your game ;
  • You pass half your time between updates only working on the design of the data type you now need, meaning less frequent updates ;
  • You stay on basic data type, and lost few hours updating the game because of this.
Well, seem to me that the last one is the less worse choice. Not that the two others are bad ; the first one should be the chosen one. It's more that you want return on your game, and no one feel like loosing one year designing the perfect data type, to abandon the game after one month because everyone find it ridiculously stupid.

What fall back to what you said at first, "it's good"... Would I have known that the guy who blindly put everything in an array, and try to remember what index have what value, will make a game that you find "marvelous", I would have lost less time.
My mod for superPowered is "good"... Do people want to know how many aspirin tubes I emptied searching the best way to make it being "good" ? I past near to one week searching a working way to transform a dialog line into a notification without having to touch the original code, and it's "good"... Man, it's both fucking genius, fucking ridiculous and fucking dirty.
And the same apply to any coder on the scene, even the worse ones. Yeah, their code is ugly, dirty, and perhaps even broke. But they past one week searching for it, so no, it's not "good". For their level of knowledge it's way more than that.


When I say, custom and complex, I mean something as simple as having a object class made to represent an idea, such as being a container for data, and then simply making different instantiations with different data that you can swap in and out to make new game content.
What, paradoxically, would be so easy with Ren'Py due to Python duck typing.

Take something basic: MC positive actions increase the girl love, MC negative actions decrease it.
Add it a bit of complexity: The more she's in love, the less she can be "more in love", while the more she's in love, the more she can be deceived.
Python duck typing make the code of your game be fuckingly easy to deal with. Redefine addition:
Code:
if value > self.weightLimit
    value = value + ( add / self.weight )
else
    value = value + add
if value > self.maxValue:
    value = self.maxValue
and subtraction:
Code:
if value > self.weightLimit
    value = value - ( sub * self.weight )
else
    value = value - sub
if value < self.minValue:
    value = self.minValue
Be inventive, the value is internally a float, for a better granularity, but an integer when looked at.
Design your Girl class in order to use this refactored integer as love value, with the correct limit and weight depending of the girl:
Code:
love = WeightedInt( startValue, weightLimit, weight, min, max )
And it's done. Starting now you don't need to care about the girl preference and the actual value.
Add something, subtract something, test the value, not just "as if all the girls had the same weight limit and boundaries", but as if there were no weight and boundaries:
Code:
label whatever( girlObject ):
    [...]
    menu:
        "do something stupid":
            girlObject.love -= 2
        "do something romantic":
            girlObject.love += 2
For one girl it will lead to a -5, for another a -1, whatever, you don't need to care about this anymore ; you don't even need to be aware of this when writing that part of the code.
Perhaps that a girl that isn't enough in love will not care at all. Perhaps that there's even a girl who love MC's stupidity and that her love increase each time there's a love -= x, while she hate romantic shit and so her love decrease each time there's a love += x with x > 5 by example.
All this isn't the concern of the code you're working on right no. Your algorithm say that this action decrease the love a little more than usual, it's what will happen. This even if this "little more" happen to be a big change because the girl to who it happened have been so deceived by the MC, or if it lead to an increase of the love because the girl is crazy. This isn't your problem at this moment, so you don't care about it here.

Of course, this is already possible with regular integers, but to the price of a function call that will pass through the same case-like algorithm you hide in the refactored integer. A function that would have to firstly discriminate between each girl, because they don't have the same limits, and that would be less easy to use:
Code:
label whatever( girlObject ):
    [...]
    menu:
        "do something stupid":
            $ decreaseLove( girlObject, 2 )
        "do something romantic":
            $ increaseLove( girlObject, 2 )
And in top of that, this will constantly remind you that the values are subject to changes, what, as I said, isn't your concern here. It will make you overthink the value you need to use, in order for it to reflect the right reaction, while what you need to know is in fact the intensity of the expected reaction, not the reaction itself.


For me, modularity is, being able to tell the engine what scene to load up, all it needs to do is bring the scene to life.
Personally, and thanks to Python duck typing, I would goes further regarding the modularity. And after what I wrote above, I obviously talk about including the value changes:
Code:
label whatever( girlObject ):
    $ girlObject.action = "anal"
    menu:
        "faster":
            girlObject.climaxStep += 1
        "harder":
            girlObject.climaxStep += 2
        "slower":
            girlObject.climaxStep -= 1
        "gentler":
            girlObject.climaxStep -= 2
    $ girlObject.climax += girlObject.climaxStep
A girl who don't care about anal would keep the value as defined. A girl who hate anal would see the value inverted. And a girl who like anal would have the value increased.
And then on top of that, girlObject.action and girlObject.climax would be use to describe the scene. While girlObject.climaxStep would be used to describe the girl reaction.
But looking at that wouldn't give you the effective algorithm used by the sex system. It will falsely make you believe that all girls have the same reaction to the same action.


As for the code for the actual engine itself, For me at least, its not possible to just have the engine contained in a single class file. It would be nice and readable, [...] the list of things they want to achieve would bloat the file into a huge wall of text, so the engine becomes a collection of ideas and mechanics.
It's where Ren'Py is superior, on its ease of use, to most other game engines.
  • Define the different refactored integers you need ;
  • Define a generic girl class that use them ;
  • Define a system that don't care about the particularities ;
  • Use Ren'Py dynamism.
I already gave an overview of the three first steps. The last one is as simple as:
Code:
image sexScene1 = "images/scene/sex/[girlObject.name]/[girlObject.action]/[girlObject.climax]_1.jpg"
image sexScene2 = "images/scene/sex/[girlObject.name]/[girlObject.action]/[girlObject.climax]_2.jpg"
image sexScene3 = "images/scene/sex/[girlObject.name]/[girlObject.action]/[girlObject.climax]_3.jpg"
[...]
label whatever( girlObject ):
    while not MCcummed:
        scene sexScene1
        girlObject.sayer "[girlObject.sexMoaning1]"
        mc "[mcObject.grunt1( girlObject.action )]"
        scene sexScene2
        girlObject.sayer "[girlObject.sexMoaning2]"
        mc "[mcObject.grunt2( girlObject.action )]"
        scene sexScene3
        girlObject.sayer "[girlObject.sexMoaning3]"
        mc "[mcObject.grunt3( girlObject.action )]"
        menu:
            "apology" if girlObject.climaxStep < 0:
                 [...]
            "faster":
                 $ girlObject.climaxStep += 2
            [...]
            "change position":
                menu:
                    "missionary" if girlObject.action != "missionary":
                        $ girlObject.action = "missionary"
                    "anal"  if girlObject.action != "anal":
                    [...]
            "change girl" if multiplePartners:
                menu:
                    "choose [girl1.name]" if girl1.involvedInSex:
                        $ girlObject = girl1
                    [...]

        $ girlObject.climax += girlObject.climaxStep
And it's done, really. With this (and the three first steps) you have a working sex system in Ren'Py.
It will care by itself to select the images corresponding to the actual action for the actual girl with the actual pleasure intensity she have. And it will care by itself to present the choices corresponding to the actual context. This will the object will care to select the right dialog lines accordingly to the context, and to update the girl climax accordingly to the girl preferences.
Of course, it's a limited sex system. All actions would feel more or less the same, but it's already the case in many games that have a different code for all the different actions of all the different girls and for all the different pleasure intensity they can have. But globally speaking, with Ren'Py the system wouldn't need to be more complex than that. And it's what I said above, either something easy to implement but that will be hard to use, or something easy to use but that will be hard to implement.


another issue is, for projects I've help with, the sex engine isn't isolated, it starts to become interconnected to other systems. Say its a dating sim, and bit by bit you unlock a character's kinks or willingness. Well you need to keep track of the player's data some how, either with a data class for the progress (of the player), or a messy class that keeps track of all the data, or my preferred, a class for each character to keep track of data individually.
Or a dynamic object as hub, as I implied in my previous answer. If you design it correctly, the data are stored the way you want, but from your point of view all available from the same place.
Code:
class Girls( object ):
    [...]
    def __getattr__( self, name ):
        if name in self.__handledGirls:
            self.__current = name
            return self
        raise AttributeError( "Oops" )
    [...]
    @property
    def love( self ):
        return self.__girlsObjects[self.__current].love
# or
        return store.love[self.__current]
# or
        return self.__love[self.__current]
# or
        return getattr( store, self.__current+"_love" )
# or whatever else
And then girl.anna.love += 1 whatever how you'll store the data, whatever how many girls you have, and whatever their names. This even if you suddenly decide to add few girls or remove one.
 

Saki_Sliz

Well-Known Member
May 3, 2018
1,403
1,011
anne O'nymous I guess, what I'm thinking is a bit more complex, which is why when I say the engine doesn't fit in a single file or why the data can't be located in one area, but that's because the 'engine' in my case is a 'medium' for different 'AI agents' to be able to interact with each other.

On important thing is, for me, AI agents are not static. Say a character doesn't like anal. The way I design my systems, setting their prefaces isn't an arbitrary data type you set in code. Rather, A character can change and adapt to the player's preferences, this is because my journey into adult games and AI started with me exploring trainer type games, so I like it when NPC's can change. As a result, I don't like monolithic data types, because I decied to break my code into the concept of "AI Agents"

It sounds like you were hinting at something similar, but it wasn't too clear. There being 3 levels of code I think in your talk about refactored integers, the top level (this action happened), the bottom level (does it bring them closer to climax? or make them like the character more, aka what is the result), and I wasn't too sure if you were hinting at this, but for me there is an middle level that interprates the data to then figure out what happen (does the character like you or not, did the ai agree to this? send data to anger, frustration, body stimulation or send data to intimacy, relationship, kink, etc. systems).

Since the OP used
a game with a text-based generic sex system like in CoC, Lilith's Throne, or DoL
as examples, I'm not thinking of simple scenes, such as showing images (or pre written scenes), I'm thinking of an engine that understands context, understands action, understands intension, and understands what different AI agents 'desire,' and based on these it dynamically figures out how AI agents reacts, figures out a chain reaction, and based on the generated data, then generates text to match the narrative, using a natural language processor to generate text from scratch.

So when I say that the engine is too big to fit in one file, I'm not talking about how C# or OOP may encourage breaking apart the logic across multiple files, I'm saying the engines I'm familiar with are far more complicated than just interfacing with data girl.anna.love += 1; rather, the sex-engine is dealing with making smaller mini engines (systems that do interact with data), each deals with a different aspect of the engine, and the sex-engine brings it all together to provide an easy to implement system.

When I say that there are mini-engines in the sex engine, thats because for what I've worked on, when I work with others they will often say 'I would like ...' where the idea they want is simple to them, but for me who is familar with code, while the mechanic may seem similar, the architecture for such as system is vastly different from other systems. This is systems from, characters having preferences (one engine inside the AI agents to say if they like or don't like something and one data type to represent these prefaces), to characters reacting to contextual clues (one engine for allowing AI agents to react to context clues, another engine for modifying context clues, an engine trigger when reactions should happen, and a data type used to describe context).

If anything I think all I'm doing is pointing out that my approach to breakdown an engine into AI agents, mini-engines, and to wrap it all up as a sex-engine, so that being a sex-engine it is easy to implement, and by breaking down the data types into separate things (rather than a monolithic file), the idea is that the model is easy to use (in addition to being easy to implement) because you can tweak various nuances (ie write a different context datatype to represent the different situations that could start a sex scene, and this can affect things like an NPC's mood, ie are they willing to try out anal, such that it doesn't matter if they like it or not, the agreed to try it).

But because with each project the needs (of the team/project) become more complex that with what I'm working on, its not specific to any game anymore, I'm working on an actual 'engine' i guess, and have to start making a database tool to manage the data types, because I am trying to get my code to couple with a natural language processor so that it can dynamically generate text rather than use pre made text.