{"id":368,"date":"2017-06-14T15:44:46","date_gmt":"2017-06-14T06:44:46","guid":{"rendered":"https:\/\/do-gugan.com\/swift\/?p=368"},"modified":"2017-06-14T21:09:05","modified_gmt":"2017-06-14T12:09:05","slug":"%e3%82%b9%e3%83%86%e3%83%bc%e3%82%b8%e3%82%92%e4%bd%9c%e3%82%8b-6-%e3%83%ab%e3%83%bc%e3%83%97%e3%82%92%e4%bd%9c%e3%82%8b","status":"publish","type":"post","link":"https:\/\/do-gugan.com\/swift\/?p=368","title":{"rendered":"\u30b9\u30c6\u30fc\u30b8\u3092\u4f5c\u308b 6. \u30eb\u30fc\u30d7\u3092\u4f5c\u308b"},"content":{"rendered":"<p>\u4e00\u898b\u3059\u308b\u30684\u30ab\u6240\u306e\u9699\u9593\u3092\u3075\u3055\u3044\u3067\u9577\u65b9\u5f62\u306e\u30b9\u30c6\u30fc\u30b8\u306b\u3057\u3066\u3057\u307e\u3048\u3070\u3001\u3042\u3068\u306f\u898f\u5b9a\u5b9d\u77f3\u6570\u96c6\u3081\u308b\u307e\u3067\u30b0\u30eb\u30b0\u30eb\u307e\u308f\u308c\u3070\u3044\u3044\u6c17\u304c\u3057\u307e\u3059\u304c\u3001\u30ef\u30fc\u30d7\u304c\u3042\u308b\u306e\u3067\u305d\u3046\u3082\u3044\u304d\u307e\u305b\u3093\u3002<br \/>\n\u79c1\u306f2\u7b87\u6240\u3060\u3051\u3064\u306a\u3044\u3067\u30014\u30d6\u30ed\u30c3\u30af\u304c\u771f\u3063\u76f4\u3050\u4e26\u3076\u5cf6\u304c4\u3064\u3001\u3068\u3044\u3046\u72b6\u614b\u306b\u3057\u307e\u3057\u305f\u3002\u5b9f\u306f\u3053\u308c\u3067\u30ef\u30fc\u30d7\u3092\u901a\u308b\u3068\u9577\u3044\u4e00\u672c\u9053\u3068\u540c\u3058\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3059\u3002\u3042\u3068\u306f\u3001\u305d\u3053\u3092\u3072\u305f\u3059\u3089\u5f80\u5fa9\u3057\u3066\u5b9d\u77f3\u3092\u96c6\u3081\u3066\u3044\u3051\u3070\u3044\u3064\u304b\u5fc5\u8981\u6570\u96c6\u3081\u3066\u7d42\u308f\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3064\u307e\u308a\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u300c\u884c\u304d\u6b62\u307e\u308a\u306b\u306a\u3063\u305f\u3089\u632f\u308a\u8fd4\u308b\u300d\u300c\u5b9d\u77f3\u304c\u3042\u3063\u305f\u3089\u53d6\u308b\u300d\u300c\u898f\u5b9a\u6570\u5b9d\u77f3\u3092\u96c6\u3081\u308b\u307e\u3067\u7e70\u308a\u8fd4\u3059\u300d\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001\u96c6\u3081\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u5b9d\u77f3\u306e\u6570totalGems\u306f\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u5ea6\u306b\u5909\u5316\u3057\u307e\u3059\u3002\u4e0d\u5b8c\u5168\u306a\u30b3\u30fc\u30c9\u3067\u3082\u3001totalGems\u304c\u305f\u307e\u305f\u307e2\u3068\u304b\u5c11\u306a\u3044\u6570\u3060\u3068\u4e0a\u624b\u304f\u30af\u30ea\u30a2\u3067\u304d\u3066\u3057\u3044\u307e\u3046\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u4f55\u5ea6\u304b\u5b9f\u884c\u3057\u3066\u3069\u3093\u306a\u6570\u306b\u306a\u3063\u3066\u3082\u30af\u30ea\u30a2\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046\uff08\u305d\u306e\u6642\u3005\u306e\u96c6\u3081\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u6570\u306f\u5b9f\u884c\u3057\u305f\u6642\u306b\u7a7a\u306e\u5de6\u4e0a\u306e\u3068\u3053\u308d\u306b\u51fa\u307e\u3059\uff09\u3002<\/p>\n<pre class=\"lang:swift decode:true \" >\r\nlet totalGems = tandomNumberOfGems \/\/\u96c6\u3081\u308b\u5b9d\u77f3\u306e\u6570\r\n\r\n\/\/\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u4f5c\u6210\u3057\u3066\u914d\u7f6e\r\nlet ch = Character()\r\nworld.place(ch, facing: south, atColumn: 0, row: 1)\r\n\r\n\/\/\u53d6\u3063\u305f\u5b9d\u77f3\u3092\u6570\u3048\u308b\u30ab\u30a6\u30f3\u30c8\u7528\u5909\u6570\r\nvar getGem = 0\r\n\r\n\/\/2\u30ab\u6240\u306b\u30d6\u30ed\u30c3\u30af\u3092\u7f6e\u304f\r\nworld.place(Block(), atColumn: 0, row: 2)\r\nworld.place(Block(), atColumn: 3, row: 3)\r\n\r\n\/\/\u3053\u3053\u304b\u3089\u672c\u7de8\r\n\/\/\u96c6\u3081\u305f\u5b9d\u77f3\u306e\u6570getGem\u304c\u3001\u6240\u5b9a\u306e\u6570totalGems\u3088\u308a\u5c11\u306a\u3044\u9650\u308a\u7e70\u308a\u8fd4\u3059\r\nwhile getGem &lt; totalGems {\r\n    \/\/\u5b9d\u77f3\u304c\u3042\u3063\u305f\u3089\u30b2\u30c3\u30c8\uff08\u30ab\u30a6\u30f3\u30c8\u5909\u6570\u3067\u6570\u3048\u308b\uff09\r\n    if ch.isOnGem {\r\n        ch.collectGem()\r\n        getGem += 1\r\n    }\r\n\r\n   \/\/\u884c\u304d\u6b62\u307e\u308a\u306a\u3089\u66f4\u306b3\u3064\u306e\u30b1\u30fc\u30b9\u306b\u5206\u5c90\u3057\u3066\u65b9\u5411\u8ee2\u63db\u51e6\u7406\r\n    if ch.isBlocked {\r\n        \/\/\u5de6\u53f3\u3068\u3082\u884c\u304d\u6b62\u307e\u308a\u306e\u6642\u306f\u632f\u308a\u8fd4\u308b\r\n        if ch.isBlockedRight &amp;&amp; ch.isBlockedLeft {\r\n            ch.turnRight()\r\n            ch.turnRight()\r\n        \/\/\u53f3\u307e\u305f\u306f\u5de6\u306e\u307f\u304c\u884c\u304d\u6b62\u307e\u308a\u306e\u6642\uff08\u30ef\u30fc\u30d7\u3092\u51fa\u305f\u6642\u7528\uff09\u306f\u6a2a\u3092\u5411\u304f\r\n        } else if ch.isBlockedRight {\r\n            ch.turnLeft()\r\n        } else {\r\n            ch.turnRight()\r\n        }\r\n    }\r\n    \/\/\u65b9\u5411\u8ee2\u63db\u51e6\u7406\u304c\u6e08\u3093\u3060\u3089\u3001\u307e\u305f\u306f\u5fc5\u8981\u306a\u3044\u6642\u306f\u524d\u9032\r\n    ch.moveForward()\r\n}<\/pre>\n<p>\u3061\u306a\u307f\u306b\u30ef\u30fc\u30d7\u30dd\u30fc\u30bf\u30eb\u306e\u4e0a\u306b\u30d6\u30ed\u30c3\u30af\u7f6e\u3044\u3066\u585e\u3044\u3067\u3084\u308c\u3070\u5192\u982d\u306b\u66f8\u3044\u305f\u3088\u3046\u306b\u5927\u304d\u306a\u9577\u65b9\u5f62\u30b9\u30c6\u30fc\u30b8\u306b\u3067\u304d\u308b\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u601d\u3063\u305f\u3093\u3067\u3059\u304c\u3001\u3069\u3046\u3082\u30ef\u30fc\u30d7\u30dd\u30fc\u30bf\u30eb\u306f\u7a4d\u307f\u4e0a\u304c\u3063\u305f\u30d6\u30ed\u30c3\u30af\u306e\u4e0a\u306b\u51fa\u73fe\u3057\u3066\u3057\u307e\u3046\u3088\u3046\u3067\u3059\u306d\u3002<br \/>\n\u307e\u305f\u6700\u521d\u304b\u3089\u3042\u308b\u30ef\u30fc\u30d7\u30dd\u30fc\u30bf\u30eb\u306f\u547c\u3073\u540d\u304c\u308f\u304b\u3089\u306a\u3044\u306e\u3067\u3001.isActive = false\u3067\u30aa\u30d5\u306b\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u306a\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u65b9\u5411\u8ee2\u63db\u51e6\u7406\u306e\u3068\u3053\u308d\u306f\u3001<\/p>\n<pre class=\"lang:swift decode:true \" >   \/\/\u5de6\u53f3\u3068\u3082\u884c\u304d\u6b62\u307e\u308a\u306e\u6642\u306f\u632f\u308a\u8fd4\u308b\r\n    if ch.isBlocked &amp;&amp; ch.isBlockedRight &amp;amp;&amp;amp; ch.isBlockedLeft {\r\n        ch.turnRight()\r\n        ch.turnRight()\r\n        \/\/\u53f3\u307e\u305f\u306f\u5de6\u306e\u307f\u304c\u884c\u304d\u6b62\u307e\u308a\u306e\u6642\uff08\u30ef\u30fc\u30d7\u3092\u51fa\u305f\u6642\u7528\uff09\u306f\u6a2a\u3092\u5411\u304f\r\n    } else if ch.isBlocked &amp;&amp; ch.isBlockedRight {\r\n        ch.turnLeft()\r\n    } else if ch.isBlocked &amp;&amp; ch.isBlockedLeft {\r\n        ch.turnRight()\r\n    }\r\n <\/pre>\n<p>\u3068\u3082\u66f8\u3051\u308b\u3067\u3057\u3087\u3046\u3002\u305f\u3060\u30573\u3064\u306eif\u5168\u3066\u306b isBlocked &amp;amp; \u304c\u3064\u3044\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u5916\u5074\u306e\u5927\u304d\u306aif\u6587\u3068\u3057\u3066\u56f2\u3063\u3066\u30cd\u30b9\u30c8\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3068\u3001\u500b\u3005\u306eif\u6587\u306e\u6761\u4ef6\u5f0f\u304c1\u9805\u6e1b\u3063\u3066\u898b\u3084\u3059\u304f\u306a\u308b\u6c17\u304c\u3057\u307e\u305b\u3093\u304b\uff1f\u307e\u305f\u3001\u4eca\u56de\u306f\u6b63\u9762\u3060\u3051\u304c\u884c\u304d\u6b62\u307e\u308a\u3068\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u306f\u306a\u3044\u306e\u3067\u3001\u5916\u5074\u306eif\u6587\u3067\u6b63\u9762\u304c\u884c\u304d\u6b62\u307e\u308a\uff08isBlocked\uff09\u3092\u6761\u4ef6\u3068\u3057\u305f\u5f8c\u3001\u6b8b\u308b\u53ef\u80fd\u6027\u306f\u300c\u4e21\u5074\u884c\u304d\u6b62\u307e\u308a\u300d\u300c\u53f3\u304c\u884c\u304d\u6b62\u307e\u308a\u300d\u300c\u5de6\u304c\u884c\u304d\u6b62\u307e\u308a\u300d\u3060\u3051\u306b\u306a\u308a\u307e\u3059\u3002\u306a\u306e\u3067\u3001\u6700\u5f8c\u306felse if\u306b\u3059\u308b\u5fc5\u8981\u3082\u306a\u304f\u300132\u884c\u76ee\u306f\u305f\u3060\u306eelse\u3067\u6e08\u307e\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<script type=\"text\/javascript\">amzn_assoc_ad_type =\"responsive_search_widget\"; amzn_assoc_tracking_id =\"doguganprojec-22\"; amzn_assoc_marketplace =\"amazon\"; amzn_assoc_region =\"JP\"; amzn_assoc_placement =\"\"; amzn_assoc_search_type = \"search_widget\";amzn_assoc_width =\"500\"; amzn_assoc_height =\"400\"; amzn_assoc_default_search_category =\"\"; amzn_assoc_default_search_key =\"iPad\";amzn_assoc_theme =\"light\"; amzn_assoc_bg_color =\"FFFFFF\"; <\/script><script src=\"\/\/z-fe.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1&Marketplace=JP\"><\/script>","protected":false},"excerpt":{"rendered":"<p>\u4e00\u898b\u3059\u308b\u30684\u30ab\u6240\u306e\u9699\u9593\u3092\u3075\u3055\u3044\u3067\u9577\u65b9\u5f62\u306e\u30b9\u30c6\u30fc\u30b8\u306b\u3057\u3066\u3057\u307e\u3048\u3070\u3001\u3042\u3068\u306f\u898f\u5b9a\u5b9d\u77f3\u6570\u96c6\u3081\u308b\u307e\u3067\u30b0\u30eb\u30b0\u30eb\u307e\u308f\u308c\u3070\u3044\u3044\u6c17\u304c\u3057\u307e\u3059\u304c\u3001\u30ef\u30fc\u30d7\u304c\u3042\u308b\u306e\u3067\u305d\u3046\u3082\u3044\u304d\u307e\u305b\u3093\u3002 \u79c1\u306f2\u7b87\u6240\u3060\u3051\u3064\u306a\u3044\u3067\u30014\u30d6\u30ed\u30c3\u30af\u304c\u771f\u3063\u76f4\u3050\u4e26\u3076\u5cf6\u304c4\u3064\u3001\u3068 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/do-gugan.com\/swift\/?p=368\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u30b9\u30c6\u30fc\u30b8\u3092\u4f5c\u308b 6. \u30eb\u30fc\u30d7\u3092\u4f5c\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,16],"tags":[],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry","category-learncode2","category-makingstage"],"_links":{"self":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368"}],"version-history":[{"count":4,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions"}],"predecessor-version":[{"id":386,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions\/386"}],"wp:attachment":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}