{"id":300,"date":"2016-07-20T10:23:34","date_gmt":"2016-07-20T15:23:34","guid":{"rendered":"http:\/\/kezune.com\/designergenes\/?p=300"},"modified":"2016-07-20T10:23:34","modified_gmt":"2016-07-20T15:23:34","slug":"breaking-down-the-c1-computer","status":"publish","type":"post","link":"http:\/\/kezune.com\/designergenes\/2016\/07\/20\/breaking-down-the-c1-computer\/","title":{"rendered":"Breaking Down the C1 Computer"},"content":{"rendered":"<p>I&#8217;ve been poking and prodding at this post for a while and I wanted to make sure that this analysis of the code is as complete as possible. However, I&#8217;m still unsure about parts of the code. Here&#8217;s what I know so far!<\/p>\n<p>Also, a small announcement. I&#8217;m going to be away towards the end of the week and all weekend. Don&#8217;t expect many updates while I&#8217;m away! I&#8217;ll be happy to respond to any comments I receive while I&#8217;m gone. Have a great week, everyone!<\/p>\n<p>&#8212;<\/p>\n<p>Something that always bothered me about the first of the Creatures games was that there was no built-in way to teach Creatures how to express emotions. I know there are tools like the <a href=\"https:\/\/creatures.wiki\/Encyclopaedia_Nornica\">Encyclopaedia Nornica<\/a> and the <a href=\"https:\/\/creatures.wiki\/Super_Speech_Toy\">Super Speech Toy<\/a> to help alleviate this and I use them both, but I always thought it would be better to have another computer placed elsewhere that taught creatures feelings like there is in Creatures 2.<\/p>\n<p>I had no idea how to start tackling this sort of problem though since I had no way to pull the scripts from the game to 1) learn how the computer works or 2) start making a new computer based off of that one. That is, until I found this amazing tool at <a href=\"http:\/\/sheeslostknowledge.blogspot.com\/\">Shee&#8217;s Lost Knowledge<\/a>. It&#8217;s a <a href=\"http:\/\/sheeslostknowledge.blogspot.com\/2015\/05\/a-smart-ish-c1-scriptorium-browser.html\">Creatures 1 Scriptorium Extractor<\/a>. It pulls out all of the existing cobs&#8217; scripts and organizes them by class numbers. I was able to pick out which file was the computers thanks to this handy, dandy <a href=\"https:\/\/creatures.wiki\/C1_class_numbers\">C1 class numbers<\/a> list.<\/p>\n<p>I&#8217;m not yet ready to start working on additional computers just yet so for now, let&#8217;s just see how this works. I&#8217;ll be using <a href=\"http:\/\/creatures.wiki\/\">Creatures.wiki<\/a> and <a href=\"http:\/\/www.gamewareeurope.com\/GWDev\/downloads\/cdn\/creatures_caos_guide.pdf\">Gameware&#8217;s Creatures CAOS Guide<\/a> as references. My comments will be preceeded with a double slash ( \/\/comment ).<\/p>\n<pre><code>bbd: edit 0 \r\n    \/\/Prevents word editing\r\nstim shou 60 8 128 0 0 0 0 0 0 0 0 0\r\n    \/\/Sig, inp, int, feat, chem0, chem0, chem1, chem1 amnt... chem4 amnt\r\n    \/\/Significance \u2013 How important this is to the related neuron\r\n    \/\/Input \u2013 Which neuron to trigger (255 if none)\r\n    \/\/Intensity \u2013 Amount to nudge neuron\r\n    \/\/Features \u2013 Determines of features (I'm not sure what this means)\r\nstim from 40 255 0 0 34 50 43 50 0 0 0 0\r\n    \/\/as above<\/code><\/pre>\n<p>This top section prepares the agent by making it so that words can&#8217;t be edited and injecting creatures with the appropriate chemicals.<\/p>\n<pre><code>doif from ne pntr \r\n    \/\/perform the following if not activated by pointer\r\n\taddv obv0 1\r\n        \/\/ add 1 to obv0\r\n\tdoif obv0 gt 13\r\n        \/\/ if obv0 is greater than 13 then...\r\n\tsetv obv0 0\r\n            \/\/ set obv0 to 1\r\n\tendi         \r\n        \/\/ when a creature activates this it moves on to the next word\r\nelse\r\n    \/\/ if it's activated by the pointer\r\n    \/\/ this section determines where the pointer pressed (3 buttons)\r\n\ttarg pntr\r\n        \/\/ targets the pointer\r\n\tsetv var0 posl\r\n        \/\/ setv var0 to the pointer's posl coordinate\r\n\ttarg ownr\r\n        \/\/ target self (?)\r\n\tsubv var0 posl\r\n        \/\/ subtract posl coordinate from var0\r\n        \/\/ this helps find the relative position of the pointer from PC<\/code><\/pre>\n<p>This section above begins a handful of checks. Here, at the top, it checks to see whether the pointer activated the agent or whether it was a creature.<\/p>\n<p>If it was activated by a creature then the script will add 1 to obv0. obv0 is the variable that the game uses to determine which word the computer will play. If that value becomes higher than 13, the script sets the value to 0 which goes back to the beginning of the word list.<\/p>\n<p>If the pointer activated the agent, the script needs to determine which button the pointer pressed.<\/p>\n<pre><code>\/\/ The following section selects which word to choose from the list (0-13)\r\n\tdoif var0 ge 25\r\n        \/\/ if it's 25 greater or equal to var0 then...\r\n        \/\/ This is the \"repeat\" button. No value changes here.\r\n        doif var0 gt 45\r\n            \/\/ if it's 45 greater than var0 then...\r\n            \/\/ This is the far right &gt;&gt; button.\r\n\t\taddv obv0 1 \r\n                    \/\/add 1 to obv0\r\n                    \/\/go to next word in the list\r\n\t\t\tdoif obv0 gt 13 \r\n                    \/\/if obv0 is greater than 13 then...\r\n\t\t\t\tsetv obv0 0 \r\n                        \/\/ set obv0 to 0\r\n                        \/\/ start the word list over\r\n\t\t\tendi\r\n\t\t    else\r\n\t\t    doif obv0 eq 0\r\n                    \/\/ if obv0 is 0\r\n\t\t    setv obv0 13\r\n                        \/\/ set obv0 to 13\r\n\t\t\telse\r\n\t\t\tsubv obv0 1\r\n                    \/\/ subtract 1 from obv0\r\n                    \/\/ go back one word\r\n\t\t\tendi\r\n\t\tendi\r\n\tendi\r\nendi<\/code><\/pre>\n<p>Once the script has the coordinates for the pointer, it then needs to determine which button was pressed and then change the value of obv0.<\/p>\n<p>The first button is the &#8220;repeat&#8221; button. Since the word doesn&#8217;t need to change, no values are changed.<\/p>\n<p>The third button is the &#8220;next&#8221; button. If this button is pressed, the script adds 1 to the obv0 variable. As above, if this value goes over 13, it goes back to the beginning of the list.<\/p>\n<p>The second button is the &#8220;previous&#8221; button. If this is pressed, it subtracts 1 from the obv0 variable. If this value goes below 0, it goes back to the last word in the list by setting the value to 13.<\/p>\n<pre><code>part 2\r\nanim [ 0 1 2 R ]\r\n\r\npart 1\r\nbase 57\r\n    \/\/ frame 57 is the base for this animation\r\nanim [ 0 1 2 3 ]\r\nover\r\n    \/\/ waits til the animation is over\r\nsetv var0 obv0\r\n    \/\/ sets var0 to obv0 (the word number from above)\r\n    \/\/ this helps determine what animation to use next\r\nmulv var0 4\r\n    \/\/ multiply var0 by 4\r\naddv var0 1\r\n    \/\/ add 1 to var0\r\n\r\npart 1\r\nbase var0\r\n    \/\/ as above, with var0 instead of 57\r\nanim [ 0 1 2 3 R ]\r\nbbd: show 1  \r\n    \/\/ shows the current word; taken from obv0 by default\r\nsnde word\r\n    \/\/ plays a sound\r\nwait 10      \r\n    \/\/ wait 10 ticks\r\nbbd: emit 0  \r\n    \/\/ speaks the word so creatures can hear, 0 means it will be \"read\"\r\nsetv actv 0\r\nwait 30\r\n\r\npart 1\r\npose 0\r\nwait 50\r\nbbd: show 0\r\n    \/\/ shows no word\r\n\r\npart 1\r\nbase 61\r\nanim [ 0 1 2 3 R ]\r\n\r\npart 2\r\npose 0\r\nendm<\/code><\/pre>\n<p>Finally, once the word to play is determined, the game can finally play the appropriate animations and teach the creature the appropriate word. My knowledge is still pretty shaky when it comes to how &#8220;part&#8221; is used, so any help I can get would be wonderful.<\/p>\n<p>I&#8217;m also still not sure how to edit the existing computer so if any of you knows how to do this, please let me know! I&#8217;ll be happy to walk you through the process so you can see how it&#8217;s done.<\/p>\n<p>I hope to have something more complete done next time. If there are any other scripts you&#8217;d like me to try to break down I&#8217;ll be happy to do that, too. I could also break them down into small or larger parts if you prefer.<\/p>\n<p>That&#8217;s all for now! Happy developing!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been poking and prodding at this post for a while and I wanted to make sure that this analysis of the code is as complete as possible. However, I&#8217;m still unsure about parts of the code. Here&#8217;s what I know so far! Also, a small announcement. I&#8217;m going to be away towards the end&hellip; <span class=\"kuorinka-read-more\"><a href=\"http:\/\/kezune.com\/designergenes\/2016\/07\/20\/breaking-down-the-c1-computer\/\" class=\"more-link\">Read more <span class=\"screen-reader-text\">Breaking Down the C1 Computer<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":348,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[6,16,29],"tags":[17,21],"class_list":{"0":"post-300","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-creatures","8":"category-creatures-1","9":"category-developer-tutorials-creatures","10":"tag-creatures","11":"tag-tutorials","12":"entry"},"_links":{"self":[{"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/posts\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":9,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":349,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/posts\/300\/revisions\/349"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/media\/348"}],"wp:attachment":[{"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kezune.com\/designergenes\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}