{"id":132,"date":"2021-05-09T21:41:05","date_gmt":"2021-05-09T21:41:05","guid":{"rendered":"https:\/\/msc-ai.knipmeyer.co.uk\/?p=132"},"modified":"2021-05-09T21:41:05","modified_gmt":"2021-05-09T21:41:05","slug":"keys-doors","status":"publish","type":"post","link":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/2021\/05\/09\/keys-doors\/","title":{"rendered":"Keys &#038; Doors"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"ICE-4732 - AI &amp; Game Design - Dragon game - doors &amp; keys\" width=\"584\" height=\"329\" src=\"https:\/\/www.youtube.com\/embed\/-zogRBfyWWM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption>Keys and Doors walkthru<\/figcaption><\/figure>\n\n\n\n<p>In the video our hero can now pick up keys and walk thru doors.<\/p>\n\n\n\n<p>This is accomplished by checking the tile ahead and wether our hero has the key. We also report in the GUI the &#8216;has-key&#8217; value to show that the key is being consumed.<\/p>\n\n\n\n<p>Firstly, in the &#8216;globals&#8217; we create variables for storing the has-key value<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  has-red-key;\n  has-yellow-key;\n  has-green-key;<\/code><\/pre>\n\n\n\n<p>And in the GUI create a reporter that returns that value<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"494\" src=\"https:\/\/msc-ai.knipmeyer.co.uk\/wp-content\/uploads\/2021\/05\/image-40.png\" alt=\"\" class=\"wp-image-133\" srcset=\"http:\/\/msc-ai.knipmeyer.co.uk\/wp-content\/uploads\/2021\/05\/image-40.png 808w, http:\/\/msc-ai.knipmeyer.co.uk\/wp-content\/uploads\/2021\/05\/image-40-300x183.png 300w, http:\/\/msc-ai.knipmeyer.co.uk\/wp-content\/uploads\/2021\/05\/image-40-768x470.png 768w, http:\/\/msc-ai.knipmeyer.co.uk\/wp-content\/uploads\/2021\/05\/image-40-491x300.png 491w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><figcaption>reporter for the has-red-key<\/figcaption><\/figure>\n\n\n\n<p>We then need to know when our hero has encountered a key, consume it, then remove it from the dungeon.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>to consume  ;;\n..  \n  ;; red key\n  if any? red-keys-here\n  &#91; set has-red-key 1\n  ask red-keys-here &#91; die ]\n  ]\n<\/code><\/pre>\n\n\n\n<p>Then to be able to move around, and only go thru doors when the relevant keys are held<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if &#91;pcolor] of patch-ahead 1 = black\n&#91; fd 1 ]\nif &#91;pcolor] of patch-ahead 1 = yellow and has-yellow-key = 1\n&#91; fd 1 ]\nif &#91;pcolor] of patch-ahead 1 = green and has-yellow-key = 1\n&#91; fd 1 ]\nif &#91;pcolor] of patch-ahead 1 = red and has-red-key = 1\n&#91; fd 1\nset level-over? true ]<\/code><\/pre>\n\n\n\n<p>Notice that when our hero can reach the red-door it is considered the end of the game, this logic will be further improved to only allow the red-door to be used once the dragon is also slayed.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the video our hero can now pick up keys and walk thru doors. This is accomplished by checking the tile ahead and wether our hero has the key. We also report in the GUI the &#8216;has-key&#8217; value to show &hellip; <a href=\"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/2021\/05\/09\/keys-doors\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/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-132","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":1,"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":134,"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/132\/revisions\/134"}],"wp:attachment":[{"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/msc-ai.knipmeyer.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}