ID:151874
 
Recently I have been trying to create an npc system that is based around AbyssDragon's Parser but I ran into a snag on using parameters within parameters (its to do with the library which I haven't really looked at).
I was planning on using this system in conjunction with a sort of genetic procedure where 2 NPCs 'breed' and produce a combination of the 2 (hence the title).

Anyway has anyone tried doing this? Can they share some snippets and ideas with us all or explain some things? Especially to do with the fact that I'd need to make a small programming language that can be changed on runtime.
You mean... like mixing NPC text?
Make a variable containing NPC text, you're making it sound so much more complicated then it really is.

mob/var
// BEGIN NPC 1s TEXT
npc1text1 = "Hi! I'm an NPC!"
npc1text2 = "How are you?! :)"
// END NPC 1s TEXT

// BEGIN NPC 2s TEXT
npc2text1 = "Omg omg omg!"
npc2text2 = ":3"
// END NPC 2s TEXT

mob/NPC
Npc1
DblClick()
usr<<"[npc1text1]" // NPC 1s first text
usr<<"[npc1text2]" // NPC 1s second text
Npc2
DblClick()
usr<<"[npc2text1]" // NPC 2s first text
usr<<"[npc2text2]" // NPC 2s second text
Npc1n2Offspring
DblClick()
usr<<"[npc1text1]" // NPC 1s first text
usr<<"[npc2text2]" // NPC 2s second text


Or do you mean...
Making NPCs look like the offspring of some?
That's icons. (:


I'm not sure if this is what you meant, but the idea of using variables for text in NPCs intrigues me... I'm off to go experiment! Thanks for the idea! (:
In response to Euphemism (#1)
Neither of those is what I meant at all. heh.
I was referring to programming NPC behaviour and making them more human like through a sort of evolution.
In response to Lyndonarmitage1 (#2)
Like, learning from a human?
It could be done, I'm sure.
It'd just require ALOT of coding. :|
Like... some variables like: isfun, isboring, isdumb and other things that it could learn. I'm sure the NPC coding would be pretty long, too.

So you mean an NPC asking a series of questions and learning what the player likes and the NPC learns and acts influenced by it?
In response to Euphemism (#3)
It's not learning, it's a mixture of characteristics between two different NPCs to influence the actions of it.
An easy way would be to have a list of characteristics for each npc, then somehow (probably randomly) combine them when breeding.

I don't really see why you would need a programming language for this, though.
When in doubt with this kind of thing, follow nature. Nature randomly takes one of two traits from the parent, and then mixes the two. In complete dominance, one trait masks another. In incomplete dominance, the trait is in the middle between the two. In codomincance, the both traits are expressed.

//we will group them in twos, and give them true/false values

mob/NPC/var/genes = list(1,0,1,1,0,0) //first trait would be heterozygous (both different)
//second would be homozygous dominant (both dom.)
//third would be homozygous recessive (both rec.)

mob/NPC
New()
Load_genes()
genes = list2params(genes)
..()

proc/Load_genes()
ASSERT(genes.len%2) //might want to remove this after testing
for(var/X in 1 to genes.len/2)
Take_Action(X,genes[X*2-1],genes[X*2])

proc/Take_Action(trait_num,n1,n2)
switch(trait_num)
if(1)
icon = file("Person[n1+n2]") //give them a base based on their trait
//simple example really, this would be
//an example of a intermediate trait
//value ranges from 0 to 2
if(2)
hair_color = rgb(n1*255,n2*255,n1*155) //simple enough, select their hair color
if(3)
hair_icon = file("Hair[n1+n2]") //another example like this because
//I'm out of ideas. You get the picture, correct?

proc/generate_offspring(list/set1,list/set2)
if(istext(set1)) set1 = params2list(set1)
if(istext(set2)) set2 = params2list(set2)
. = list()
for(var/X in 1 to set1.len) //shouldn't be different, anyway
.[X] = pick(set1[X],set2[X]) //oversimplified right now, you might want to
//be more realistic and give your NPC one trait from each
//parent
In response to Nickr5 (#5)
A language allows it more freedom to grow and adapt.
In response to Jeff8500 (#6)
This has given me the idea of scrapping trying to make a language to be parsed and instead having fixed genes that can be called depending upon random traits.
.[X] = pick(set1[X],set2[X])
Isn't really oversimplified it is what I would use in such a situation seeing as both parents would then have an equal chance of influencing every gene although I see what you mean by your comment
In response to Kaiochao (#4)
Technically it does 'learn' and adapt to it's environment because of environmental pressures.
In response to Lyndonarmitage1 (#8)
In actual genetics, parents have an equal say in every gene, so yes, it is over simplified. You can do something similar to what I did up top, where you multiply X by two, and then for each number in the list, you can set one of two genes with pick() and the other (X+1) with the left over gene.

EDIT: If your really wanted to get insane, you could go down another level, into actual nucleotide sequences. That would be borderline crazy in BYOND, though.
In response to Lyndonarmitage1 (#9)
Acquired characteristics of organisms don't pass on to offspring, but the organism itself learning is completely different(it's not genetic).
In response to Kaiochao (#11)
The reason learn was in quote marks is because I didn't literally mean it as learn in the sense of "no don't do that!" but rather the idea of instincts and evolved characteristics.
I probably sounded a bit vague though so sorry for the confusion.
In response to Lyndonarmitage1 (#12)
Genetic memory as far as I know only exists in science fiction :)
In response to Jeff8500 (#6)
Jeff8500 wrote:
When in doubt with this kind of thing, follow nature. Nature randomly takes one of two traits from the parent, and then mixes the two.

Nothing in nature is random. There are only enough factors involved to make seemingly random events seem random.
In response to Lyndonarmitage1 (#9)
Lyndonarmitage1 wrote:
Technically it does 'learn' and adapt to it's environment because of environmental pressures.

Technically, it doesn't learn. True AI has not been accomplished yet because of the fact that computers cannot efficiently learn anything yet.
In response to CaptFalcon33035 (#14)
There are only enough factors involved to make seemingly random events seem random.

True, but there are so many factors that the word random is the only one that fits.