The Sims actually uses "subject oriented programming", and it even personalizes objects and objectifies people! ;)
It's actually implemented in C++ of course, but it has a virtual machine that executes a noodly visual programming language called "SimAntics". And by noodly, I mean optimized for spaghetti code, containing intertwined loops, floppy, and droopy...
https://medium.com/@donhopkins/the-sims-pie-menus-49ca02a74d...
Subject Oriented Programming
This is described by some people as object — not Object Oriented Programming, but Subject Oriented Programming.
Objectifying People
People are objects, so when you click on another person, the items that you get in the menu depend on your mood, and your relationship with that person.
(From the transcript of this demo video:)
https://www.youtube.com/watch?v=-exdu4ETscs
The Sims, Pie Menus, Edith Editing, and SimAntics Visual Programming Demo
This is a demonstration of the pie menus, architectural editing tools, and Edith visual programming tools that I developed for The Sims with Will Wright at Maxis and Electronic Arts.
http://radar.oreilly.com/2009/03/interview-will-wright-sims-...
Will Wright: Well, one of the first challenges was
could we develop a really robust model of human behavior test so that
we could put these little characters in the elements in any situation
they would behave reasonably. A Sims user is kind of controlling the
environment. They can put the Sims in a wide variety of potential
environments and then the Sims have to act reasonable. So we kind of
had to develop a very — well, on the surface, it looks like an
object-oriented programming model, but in fact, it’s what’s
technically called a subject-oriented programming model. But I won’t
get into that detail. So developing this robust kind of behavior
system — in fact, it was environmentally distributed intelligence is
the way we solved it.
But on the design
side, there was a lot of thought about how much autonomy do these
characters have versus how much reliance do they have on the player
directing their actions. And there was also a whole dimension of
thought around how much are we going to let the player read in to the
simulation. In other words, how much of the simulation are we going
to offer them to play of imagination versus make very clear and
overt?
https://www.gamedev.net/forums/topic/697362-need-some-advice...
All8Up
Moderator
Posted June 15, 2018
From the way the embedded code is shown, I would say the first thing to do is reverse the logic. What I mean is that what you posted suggests that the code is along the lines of "I'm trying to interact with you" and "I need to figure out what you are and what I can do to you". Conceptually of course is the most sensible solution, unfortunately in practice it is also the solution which fails the most often. Rather than this, I've always used subject oriented programming for interactions. This reverses the logic such that rather than the 'doer' figuring things out the subject of the interaction performs the work. Basically this means that the input system would simply set a flag on the input component saying "this entity wishes to interact". The interaction system can then do pre-cull for subject entities which are in range, which ones can be used from the doer's position, etc. Finally, you end up with a door that runs the rule checks: "You are in range, you have my key, it is Monday after noon, you are wearing a purple shirt... Ok, guess I will open now."
As to how you implement these things in the ECS itself, I suspect everyone does it differently. Personally I use a handle based approach where the interaction component simply contains a handle which refers to usually a script which checks the interaction rules. The script gets the doer and subject ID's so it can check states and make the decision. Then, likely in another script, an action is performed.
Overall this probably sounds ass backwards but it is a well proven solution to removing massive 'if/else' checks. It is also great for expansion packs and such since all the new logic is contained in the subject and you don't have to patch the doer code to understand the new interaction. Just as an example, The Sims used(still uses I assume) this subject oriented approach which allows DLC to be dropped in and mostly just work.
Hope this makes sense.
http://ivizlab.sfu.ca/arya/Papers/SW/SOP.pdf
Subject-Oriented Programming
(A Critique of Pure Objects).
William Harrison and Harold Ossher.
Abstract
Object-Oriented technology is often described in terms of an interwoven troika of themes:
encapsulation, polymorphism, and inheritance. But these themes are firmly tied with the concept of identity. If object-oriented technology is to be successfully scaled from the development of independent applications to development of integrated suites of applications, it must relax its emphasis on the object. The technology must recognize more directly that a multiplicity of subjective views delocalizes the concept of object, and must emphasize more the binding concept of identity to tie them together.
This paper explores this shift to a style of object oriented technology that emphasizes the subjective views: Subject-Oriented Programming.
https://en.wikipedia.org/wiki/Subject-oriented_programming
In computing, subject-oriented programming is an object-oriented software paradigm in which the state (fields) and behavior (methods) of objects are not seen as intrinsic to the objects themselves, but are provided by various subjective perceptions (“subjects”) of the objects. The term and concepts were first published in September 1993 in a conference paper[1] which was later recognized as being one of the three most influential papers to be presented at the conference between 1986 and 1996. As illustrated in that paper, an analogy is made with the contrast between the philosophical views of Plato and Kant with respect to the characteristics of “real” objects, but applied to software ones. For example, while we may all perceive a tree as having a measurable height, weight, leaf-mass, etc., from the point of view of a bird, a tree may also have measures of relative value for food or nesting purposes, or from the point of view of a tax-assessor, it may have a certain taxable value in a given year. Neither the bird’s nor the tax-assessor’s additional state information need be seen as intrinsic to the tree, but are added by the perceptions of the bird and tax-assessor, and from Kant’s analysis, the same may be true even of characteristics we think of as intrinsic.