{"id":2232,"date":"2024-09-09T10:49:29","date_gmt":"2024-09-09T10:49:29","guid":{"rendered":"https:\/\/research.swissdigitization.ch\/?p=2232"},"modified":"2024-09-10T08:01:20","modified_gmt":"2024-09-10T08:01:20","slug":"simple-ais-source-code","status":"publish","type":"post","link":"https:\/\/research.swissdigitization.ch\/?p=2232","title":{"rendered":"Simple AIs? Ein Wunschtraum &#8211; Source Code"},"content":{"rendered":"\n<p>AIs werden immer gering gesch\u00e4tzt gerade einfach Logische. Dabei sind sie teilweise gar nicht so einfach zu implementieren. In Assembler sind sogar die einfachsten Sachen schon recht komplex und ben\u00f6tigen einiges an Konzentration (jmps etc!)<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"720\" style=\"aspect-ratio: 924 \/ 720;\" width=\"924\" controls src=\"https:\/\/research.swissdigitization.ch\/wp-content\/uploads\/2024\/09\/Screen-2024-09-09-122553.mp4\"><\/video><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p>Hier die endg\u00fcltige Version<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"720\" style=\"aspect-ratio: 978 \/ 720;\" width=\"978\" controls src=\"https:\/\/research.swissdigitization.ch\/wp-content\/uploads\/2024\/09\/Screen-2024-09-09-124319.mp4\"><\/video><\/figure>\n\n\n\n<p>Der SourceCode f\u00fcr ein wenig Intelligenz:<\/p>\n\n\n\n<p>Kommentar dazu: <br>&#8211; Sonderbehandlung der Koordinaten (10* gr\u00f6sser als Pixelaufl\u00f6sung)<br>&#8211; Bewegungsrichtung in: gameobject_cat1 + cat2<br>&#8211; Bewegung nur im 16er PlayfieldRaster (getLevelBlock)<br>&#8211; Init und Update-Funktions<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; ----------------------\n;  a_protect\n; ----------------------\n\tcmp.w #type_a_protect,gameobject_type(a6)\n\tbne.w h_protect\n\n\t\t; init\n\t\tcmp.w #handle_init,handleState,\n\t\tbne.w h_init_h_protect\n\n\t\t\tmove.w #objectstate_active,gameobject_state(a6)\t\n\t\t\tmove.w #collision_yes,gameobject_collision(a6)\n\t\t\tmove.w #cat0_friend,gameobject_cat0(a6)\t\n\n\t\t\tmove.w #0,gameobject_cat1(a6)\t\n\t\t\tmove.w #0,gameobject_cat2(a6)\t\n\n\t\t\tmove.w #art_type_bob1616,gameobject_art(a0)\n\t\t\tmove.w #atype_noanim,gameobject_animtype(a0)\n\t\t\tmove.w #atype_loop,gameobject_animtype(a0)\t\n\t\t\tmove.w #48,gameobject_animmin(a0)\t\n\t\t\tmove.w #48,gameobject_animind(a0)\t\n\t\t\tmove.w #49,gameobject_animmax(a0)\t\n\n\t\t\t; *10\n\t\t\tclr.l d0\n\t\t\tmove.w gameobject_x(a6),d0\t\n\t\t\tmulu   #10,d0\n\t\t\tmove.w  d0,gameobject_x_expanded(a6)\n\t\t\tclr.l  d0\n\t\t\tmove.w gameobject_y(a6),d0\t\n\t\t\tmulu   #10,d0\n\t\t\tmove.w d0,gameobject_y_expanded(a6)\n\n\t\t\tjmp  end_handle\t\t\n\t\th_init_h_protect:\n\n\t\t; update\n\t\tcmp.w #handle_update,handleState\n\t\tbne h_protect\n\n\n\t\t\t\t; expanded ... \n\t\t\t\tmove.w gameobject_cat1(a6),d0\n\t\t\t\tadd.w d0,gameobject_x_expanded(a6)\n\t\t\t\tmove.w gameobject_cat2(a6),d1\n\t\t\t\tadd.w d1,gameobject_y_expanded(a6)\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t; expanded to x,y\n\t\t\t\tclr.l d0\n\t\t\t\tmove.w  gameobject_x_expanded(a6),d0\n\t\t\t\tdivu   #10,d0\n\t\t\t\tmove.w d0,gameobject_x(a6)\n\t\t\t\tclr.l d0\n\t\t\t\tmove.w  gameobject_y_expanded(a6),d0\n\t\t\t\tdivu   #10,d0\n\t\t\t\tmove.w d0,gameobject_y(a6)\t\n\n\t\t\t\t; ... \n\t\t\t\tcmp.w #avatar_y,gameobject_y(a6)\n\t\t\t\tblt.w h_notdown_protect\n\t\t\t\t\tmove.w #objectstate_awake,gameobject_state(a6)\n\t\t\t\t\tmove.w #type_explosion,gameobject_type(a6)\n\t\t\t\th_notdown_protect:\n\t\t\t\n\t\t\t\t; stop and think\n\t\t\t\tclr.l d0\n\t\t\t\tmove.w gameobject_x(a6),d0\n\t\t\t\tclr.l d1\n\t\t\t\tmove.w gameobject_y(a6),d1\n\n\t\t\t\t; x%16==0 &amp;&amp; y%16==0\n\t\t\t\tdivu #16,d0\n\t\t\t\tswap d0\n\t\t\t\text.w d0\n\t\t\t\tcmp.w  #0,d0\n\t\t\t\tbne.w  h_nodecision_protect\n\t\t\t\tdivu #16,d1\n\t\t\t\text.w d1\n\t\t\t\tswap d1\n\t\t\t\tcmp.w  #0,d1\n\t\t\t\tbne.w  h_nodecision_protect\n\t\t\t\t\t\n\n\t\t\t\t\t\t\t; check going down as often as possible\n\t\t\t\t\t; overwrite the rest\n\t\t\t\t\tmove.w gameobject_x(a6),levelBlockX\n\t\t\t\t\tmove.w gameobject_y(a6),levelBlockY\n\t\t\t\t\tadd.w  #8,levelBlockX\n\t\t\t\t\tadd.w  #16,levelBlockY\n\t\t\t\t\tjsr getLevelBlock\t\t\n\n\t\t\t\t\t; LEFT\n\t\t\t\t\tcmp.w #0,gameobject_cat1(a6)\n\t\t\t\t\tbgt   h_tripleft_protect\n\t\t\t\t\tbeq   h_tripleft_protect\n\t\t\t\t\t  \tmove.w gameobject_x(a6),levelBlockX\n\t\t\t\t\t\tmove.w gameobject_y(a6),levelBlockY\n\t\t\t\t\t\tsub.w  #8,levelBlockX\n\t\t\t\t\t\tadd.w  #8,levelBlockY\n\t\t\t\t\t\tjsr getLevelBlock\t\n\t\t\t\t\t\tcmp.w #undestroyableBlockStart,levelBlockIndex\n\t\t\t\t\t\tblt.w h_tripleft_protect\n\t\t\t\t\t\tcmp.w #destroyBlockStop,levelBlockIndex\n\t\t\t\t\t\tbgt.w h_tripleft_protect\n\t\t\t\t\t\t\tmove.w #3,gameobject_cat1(a6)\n\t\t\t\t\t\t\tmove.w #0,gameobject_cat2(a6)\n\t\t\t\t\t\t\tjmp h_tripleftright_protect\n\t\t\t\t\th_tripleft_protect:\n\n\t\t\t\t\t; RIGHT\n\t\t\t\t\tcmp.w #0,gameobject_cat1(a6)\n\t\t\t\t\tblt   h_tripright_protect\n\t\t\t\t\tbeq   h_tripright_protect\n\t\t\t\t\t  \tmove.w gameobject_x(a6),levelBlockX\n\t\t\t\t\t\tmove.w gameobject_y(a6),levelBlockY\n\t\t\t\t\t\tadd.w  #16,levelBlockX\n\t\t\t\t\t\tadd.w  #8,levelBlockY\n\t\t\t\t\t\tjsr getLevelBlock\t\n\t\t\t\t\t\tcmp.w #undestroyableBlockStart,levelBlockIndex\n\t\t\t\t\t\tblt.w h_tripright_protect\n\t\t\t\t\t\tcmp.w #destroyBlockStop,levelBlockIndex\n\t\t\t\t\t\tbgt.w h_tripright_protect\n\t\t\t\t\t\t\tmove.w #-3,gameobject_cat1(a6)\n\t\t\t\t\t\t\tmove.w #0,gameobject_cat2(a6)\n\t\t\t\t\t\t\tjmp h_tripleftright_protect\n\t\t\t\t\th_tripright_protect:\n\n\t\t\t\t\th_tripleftright_protect:\n\n\t\t\t\t\t; AN OPEN FIELD DOWN?\n\t\t\t\t\tmove.w gameobject_x(a6),levelBlockX\n\t\t\t\t\tmove.w gameobject_y(a6),levelBlockY\n\t\t\t\t\tadd.w  #8,levelBlockX\n\t\t\t\t\tadd.w  #16,levelBlockY\n\t\t\t\t\tjsr getLevelBlock\n\t\t\t\t\tcmp.w #undestroyableBlockStart,levelBlockIndex\n\t\t\t\t\tblt.w h_nodecision_downfree_protect\n\t\t\t\t\tcmp.w #destroyBlockStop,levelBlockIndex\n\t\t\t\t\tbgt.w h_nodecision_downfree_protect\t\n\t\t\t\t\t\tjmp h_nodecision_down_protect\n\t\t\t\t\th_nodecision_downfree_protect:\t\t\t\n\t\t\t\t\t\t; check left or right\n\t\t\t\t\t\tmove.w #0,gameobject_cat1(a6)\n\t\t\t\t\t\tmove.w #3,gameobject_cat2(a6)\n\t\t\t\t\t\tjmp end_handle\n\t\t\t\t\th_nodecision_down_protect:\n\n\t\t\t\t\t\t; let's think about\n\t\t\t\t\t\t; move.w #0,gameobject_cat1(a6)\n\t\t\t\t\t\t; move.w #0,gameobject_cat2(a6)\n\n\t\t\t\t\tcmp.w #0,gameobject_cat1(a6)\n\t\t\t\t\tbne   h_nodecision_protect\n\n\t\t\t\t\t\t; left?\n\t\t\t\t\t\tmove.w gameobject_x(a6),levelBlockX\n\t\t\t\t\t\tmove.w gameobject_y(a6),levelBlockY\n\t\t\t\t\t\tsub.w  #8,levelBlockX\n\t\t\t\t\t\tadd.w  #8,levelBlockY\n\t\t\t\t\t\tjsr getLevelBlock\t\n\t\t\t\t\t\tcmp.w #undestroyableBlockStart,levelBlockIndex\n\t\t\t\t\t\tblt.w h_nodecision_leftfree_protect\n\t\t\t\t\t\tcmp.w #destroyBlockStop,levelBlockIndex\n\t\t\t\t\t\tbgt.w h_nodecision_leftfree_protect\t\n\t\t\t\t\t\t\tjmp h_nodecision_leftf_protect\n\t\t\t\t\t\th_nodecision_leftfree_protect:\t\t\t\t\t\t\n\t\t\t\t\t\t\t; something else\n\t\t\t\t\t\t\tmove.w #-3,gameobject_cat1(a6)\n\t\t\t\t\t\t\tmove.w #0,gameobject_cat2(a6)\n\t\t\t\t\t\t\tjmp end_handle\n\t\t\t\t\t\th_nodecision_leftf_protect:\n\n\t\t\t\t\t\t; right?\n\t\t\t\t\t\tmove.w gameobject_x(a6),levelBlockX\n\t\t\t\t\t\tmove.w gameobject_y(a6),levelBlockY\n\t\t\t\t\t\tadd.w  #16,levelBlockX\n\t\t\t\t\t\tadd.w  #8,levelBlockY\n\t\t\t\t\t\tjsr getLevelBlock\t\n\t\t\t\t\t\tcmp.w #undestroyableBlockStart,levelBlockIndex\n\t\t\t\t\t\tblt.w h_nodecision_rightfree_protect\n\t\t\t\t\t\tcmp.w #destroyBlockStop,levelBlockIndex\n\t\t\t\t\t\tbgt.w h_nodecision_rightfree_protect\t\n\t\t\t\t\t\t\tjmp h_nodecision_rightf_protect\n\t\t\t\t\t\th_nodecision_rightfree_protect:\t\t\t\t\t\t\n\t\t\t\t\t\t\t; something else\n\t\t\t\t\t\t\tmove.w #3,gameobject_cat1(a6)\n\t\t\t\t\t\t\tmove.w #0,gameobject_cat2(a6)\n\t\t\t\t\t\t\tjmp end_handle\n\t\t\t\t\t\th_nodecision_rightf_protect:\n\t\t\t\t\n\n\n\t\t\t\th_nodecision_protect:\n\n\t\t\t\t; or in the middle? \n\n\t\tjmp end_handle\n\n; ----------------------\nh_protect:\n; ----------------------\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>AIs werden immer gering gesch\u00e4tzt gerade einfach Logische. Dabei sind sie teilweise gar nicht so einfach zu implementieren. In Assembler sind sogar die einfachsten Sachen schon recht komplex und ben\u00f6tigen einiges an Konzentration (jmps etc!)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2232","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=\/wp\/v2\/posts\/2232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2232"}],"version-history":[{"count":3,"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=\/wp\/v2\/posts\/2232\/revisions"}],"predecessor-version":[{"id":2244,"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=\/wp\/v2\/posts\/2232\/revisions\/2244"}],"wp:attachment":[{"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/research.swissdigitization.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}