saw an anon ask on @/zilodaks blog that asked for advice on how to write ai characters. as someone who is drawn to and likes analyzing these types of characters, i offer some advice below (read more; note there are discussions of portal characters that aren't spoiler-free so be wary):
for the sake of making myself clear, i'm going to use GLADoS and wheatley from the Portal series since they're a) very familiar to people and b) they're relatively easy to understand character-wise. i'm only going to discuss them as it pertains to the points i'm making. i encourage you to research some popular ai characters and take the time to deconstruct their character to figure out why and how they work (you can also figure out why they're popular too!). with that out of the way, let's get into it.
when i interact with ai characters, i've noticed that most (if not all) share three things in common that makes them compelling to people:
their original purpose (why they were created)
the "rules" they must follow (which, to me, is their motivation)
a development of sentience
all ai are created with a purpose in mind. if you look into some popular ai, most of them were originally developed to fulfill some need/want that their creator wanted to see fulfilled. they can be simple, such as running simple equations, or complex such as overseeing an entire community of people. GLADoS and wheatley are similar in that they're both personality cores, little spheres of ai that are noted for their ability to express emotions. but they serve different purposes.
in GLADoS' case, she was created to oversee and maintain the enrichment center on behalf of aperture science. wheatley, on the other hand, was made with the sole purpose of inhibiting GLADoS' intelligence so that she is easier for the scientists to manage.
when creating an ai character, it helps to figure out what they are originally created for (as well as *who* created them) to get a good start on fleshing them out. which brings me to my next point:
ai are machines first and foremost, programmed by their creators to fulfill a purpose. as a result, theyre bound to a set of "rules" within their programming that helps to fulfill their purpose in an efficient and successful way. as the central core of the center, GLADoS (and later wheatley) have a strong desire to conduct tests and maintain the center to the best of their ability. since GLADoS was intentionally created for this purpose, the center has a clean look and smooth operation under her guidance.
wheatley, however, does a terrible job which is (primarily) because of his original purpose as an "intelligence dampening sphere". as a result, the center becomes messy and rocky in terms of operation. though GLADoS and wheatley are both personality cores, their differences in their purpose and "rules" overall dictate the condition of the center beneath them.
after deciding on the ai character's purpose, you can then move onto figuring out the "rules" included in their programming since that can influence their behavior. to me, the main rule that GLADoS must follow is the rule of "maintain the testing facility and continue testing on behalf of aperture science". she does follow this rule faithfully to a t, even if she has the habit of harming the test subjects involved. which brings me to my last point:
3. the issue of sentience and morality
a lot of popular ai characters have some level of sentience to them. sentience, in layman's terms, is the base level of consciousness that allows organisms to feel things and recognize that feeling. in my opinion, a lot of sci-fi writers and creators play with sentience in ai characters because it makes them more compelling/interesting to their audience (giving human traits to nonhuman beings). this also allows them to explore the potential consequences of allowing ai to gain sentience.
with GLADoS, wheatley, and others within the enrichment center, they all have some level of sentience that allows them to experience pain and emotions. to me, this makes them more approachable to the audience since they aren't unfamiliar (the use of human traits makes them more palatable).
but at the end of the day, ai will fall back on logic/reason in order to solve all potential problems. inevitably this often leads into morally grey territory where they may cause harm in the pursuit of fulfilling their goals. even a "good" ai may be so tightly bound by the "rules" that it pushes them towards harming humans in order to adhere to them (a famous example of this is HAL 9000).
both GLADoS and wheatley have done actions that have harmed chell, even though wheatley was the friendlier one towards her throughout the portal 2 campaign (though it is mentioned in portal 2 that him dropping chell into the pit was an accident).
keep in mind that an ai gaining sentience does not mean that they will develop a good moral character. again, ai are machines and will act according to what is programmed in them. while that doesn't mean it's impossible for them to change, they are incredibly resistant towards it.
a good way to tackle ai characters in this regard is to decide on two things:
whether they gain sentience (and if it evolves into a more "human-like" consciousness)
what they do as a result of sentience
these questions are broad because there isn't an exact answer i can give. there are many ai characters across the spectrum of "good" and "evil", with a good amount of them falling in the morally grey area. to me, the matter of sentience is fully dependent on their purpose for creation and the circumstances surrounding it. similar to how humans raise children, ai are molded by their creators into what makes them unique.
ai, as a concept, is a fun one to explore. but it can be difficult to figure out where to even start since they come in so many shapes and forms (literally). to summarize, consider the following factors when writing an ai character:
research some popular ai, take some time to deconstruct their character and figure out why they work within the narrative. as much as research sucks, you can't make an ai from scratch without some background knowledge.
once you do the research, you can then:
figure out their purpose: who created them, and what they were created for
figure out the "rules" they follow. this can relate to their purpose or, if they are sentient enough, can be a honor code that they adhere to.
determine the level of sentience that the character has, and what they do with that.