creatures caves welcome, guest
downloads   gallery   dev   community   creatchi   forum   mycaves
bookmarks | search | post new topic
Development Forum
old
Misc. CAOS questions   
Luzze

Luzze
Germany  


  7/31/2014

While coding a plant some questions came to my mind..

1) Do Variables carry over in gsubs? If I used Va00 in a script that contains a gsub, can I use the stored information inside it?

2) Can someone explain how named Variables work? I've read about them in the documentation but it's confusing me..

3) About stimuli.
- If I make a pushable object but dont give out the stimuli when done creatures don't get the 'reward' (= - boredom) if they do it, right? So they don't learn that pushing the 'genus' my agent is in is fun?

-I made a seed vendor that doesn't activate when pulled or deactivated. Shall I give out the stim for punishment or pulling/deactivating?

- Stimuli are coded in the genetics, right? So if I made a new one, would I adress to it as 'stim 98'? What would happen if I'd adress a stimulus that the "from" creature doesn't have? I don't plan to add any stimuli, the question is just out of curiosity :)


4) In the "Creatures Development Standards" I've read about a pollination custom script. What agents do use it?
It says there is a similar system in C3.. to what does this refer?

 
Ghosthande
Prodigal Sock

Ghosthande


 visit Ghosthande's website: Breeders Beware
  7/31/2014

1. A GSUB just grabs a subroutine within the same script; VAxx type variables exist from start to finish within a script, so they don't even need to "carry over"; you're just running a different block inside the same script so assuming the variable was defined before you use the GSUB, they'll still be there.

2. Named variables are a bit complex and clunky to work with, and (at least from what Moe has told me) they eat a bit more memory than regular variables; all of the above makes them a bit of a pain in the butt. I'll see if I can find an example to show you... but the fact is that I use OVxx instead of named variables whenever I can.

3a. Basically, yes. Most Creatures will just keep trying until either they get stimmed finally, or some more urgent need (like starvation) takes their attention away from it.

3b. Don't use the stim for punishment to make Creatures not want to do things. Just give them the stim for disappointment. They'll still feel disinclined to use it, but without actually being "punished".

3c. Yes again. If you made a new stimulus, Creatures with no corresponding stimulus gene just wouldn't get any useful information, because it's the gene that determines what the number "means". So I guess it would be basically the same as if they hadn't been stimmed.

4. I'm pretty sure most if not all C3 flowers use the pollination script. IIRC my sunflowers do, too.



 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  7/31/2014

From the cacbana:

******flower fertilised event
scrp 2 7 3 303
setv ov70 1
endm


From the balloon bug's timer script:

*hunting
doif ov00 eq 3
setv ov14 3
setv ov15 3
gsub home
gsub velo
* see if touching flower
inst
doif ov16 ne null
doif touc ov16 ownr gt 0
mesg writ ov16 303
setv ov00 0
addv ov02 100
endi
else
setv ov00 0
endi
slow
endi


From the cacbana flower's timer script:

* fertilised
doif ov70 eq 1
doif pose lt 8
setv va00 pose
addv va00 1
pose va00
else
setv va00 posl
setv va01 post
* produce seed
new: simp 2 3 9 "cacbana" 12 0 50
attr 199
elas 40
fric 50
aero 5
accg 1
rnge 500
doif tmvt va00 va01 eq 1
mvto va00 va01
else
mvsf va00 va01
endi
velo rand -10 10 rand -5 -20
setv ov81 rand 8 15
targ ownr
* sort out the parents plant states
targ ov16
doif targ ne null
doif ov16 eq ownr
seta ov16 null
elif ov17 eq ownr
seta ov17 null
endi
doif ov16 eq null and ov17 eq null
setv ov80 0
setv ov69 0
setv ov66 100
endi
endi
kill ownr
endi
endi
endm


So, when a bug lands on a flower, it tells the flower to activate its pollination script. The pollination script sets an object variable to 1. The next time the flower's timer script runs through, it sees 'oh, I've been pollinated, I'd better make a seed instead of waiting around or dying', and so it does. :)


My TCR Norns
 
Papriko
Peppery One

Papriko



  7/31/2014  1

Named variables are, aside of the size and perhaps speed disadvantages they might cause, not that awful. There is 3 levels of named variables:

NAME: These variables are just valid inside the agent that created them. They are basically like additional OV variables. You can use them when you actually should be running out of OVs (which I doubt will ever happen, there is 100 afterall) or when you want to store something in foreign agents without disturbing them in any way.
Creatures self would be an example. Let's say you have an agent which runs a complex check or something over creatures and then should mark them somehow. You could use an OV variable and hope no other script uses that particular one. Chances are good nothing will happen, but better safe than sorry.
Another thing is when you dynamically add or remove variables. I believe Moe's pathfinding for bees uses them. Remember room you are in and it's flower smell strength. Fly to another room. Is smell stronger than before? If no, turn back and try another direction, if yes add another NAME variable to remember this smell/roomID pair.
Once we reached our flowers and harvested nectar, go through your collected variables from the last to the first in order to find your hive again.
VAs or OVs are absolutely unqualified for this kind of code, so you go for NAME ones.

GAME: These are variables which are "known" within the entire world. You can use it e.g. for global rules that multiple agents can read and/or change. The breeding limits would be examples of such variables.
One unique thing about GAME variables is that you have to run an update command after changing them, so that scripts notice that it was changed. That command is RGAM. You can delay updating variables by not running RGAM, but it isn't the most reliable thing in the world. It is likely that some other agent RGAMs in the meantime because it has to update some other GAME variables.

EAME: The EAME variables are not very commonly used. The "E" stands for "Engine", i.e. they can be used across the entire game. Your current world, the world switcher, other worlds you load, all of them will know that EAME variable once you set it.
The ones already in the game influence options which are even "more global" than the breeding limit, such as if the hand actually shall be attached to the mouse or if the screensaver is allowed to activate while the game is running.



As Ghosthande mentioned, they take up quite a bit of space, so when you can be sure that you never ever need them again, you can destroy them (and that way completely free the memory they occupy) by using the commands DELN, DELG and DELE respectively.

For the syntax: you can use them pretty much like normal variables, but you always need to put the type it is (NAME, GAME, EAME) in front of it. Here an example:
* add a local variable
setv name "myvar1" 12

* get it's value, 12
outv name "mayvar1"

*do maths with it. Now it's 36
mulv name "myvar1" 3



* make a world-wide variable
setv game "spaces are supported too for names" 5

* does not exist yet, errors out
outv game "spaces are supported too for names"

* but now it does! we get a 5
rgam
outv game "spaces are supported too for names"



* make a variable that works across worlds
sets eame "SomeFunkyVariable" "named variables also support string values and agents"

* now we can even read our message in other worlds too
outs eame "SomeFunkyVariable"

* now let's remove all this stuff again
deln "mayvar1"
delg "spaces are supported too for names"
dele "SomeFunkyVariable"


Lets play plants! Photosynthesis... Photosynthesis... Photosynthesis...
 
RisenAngel
Sanely Insane

RisenAngel

Manager


 visit RisenAngel's website: The Realm
  7/31/2014

One more thing about named variables: "name" and "eame" are DS-only CAOs commands. C3 standalone will not recognize them and will throw an error if you try using them there. "Game" variables, on the other hand, work in both C3 standalone and DS worlds.

~ The Realm ~
Risen Angel's Creatures Blog


 
Luzze

Luzze



  7/31/2014

Thanks for the replys :)

I think I understand the named variables now.

So script '303' activates when a bug touches the flower but it has to be coded into the insect..
Since you said that almost every C3 Flower uses it it wouldn't be wrong to code it into the one I'm making, right?

 
Malkin

Malkin

Manager


 visit Malkin's website: Malkin's page at CWiki
  7/31/2014

It just means that you'll have to tell people to plant them with pollinating insects. (And that people without C3 will most likely not be able to use your plant properly.)

My TCR Norns
 


downloads
cobs
adoptions
creaturelink
metarooms
breeds
 
gallery
art
wallpaper
screenshots
graphics
promos
sprites
dev
hack shack
script reservations
dev resources
active projects
dev forum
 
community
links
advice
chat
polls
resources
creatchi
 
forum
bookmarks
general
news
help
development
strangeo
survivor
mycaves
log in
register
lost pw
0 online
creatures caves is your #1 resource for the creatures artificial life game series: creatures, creatures 2, creatures 3, docking station, and the upcoming creatures family.

contact    help    privacy policy    terms & conditions    rules    donate    wiki