{"id":474,"date":"2017-06-17T21:54:19","date_gmt":"2017-06-17T12:54:19","guid":{"rendered":"https:\/\/do-gugan.com\/swift\/?p=474"},"modified":"2017-06-21T02:36:06","modified_gmt":"2017-06-20T17:36:06","slug":"%e9%85%8d%e5%88%97-11-%e9%81%95%e3%81%84%e6%96%b9%e6%b3%95%e3%81%a7%e9%85%8d%e5%88%97%e3%82%92%e4%bd%9c%e3%82%8b","status":"publish","type":"post","link":"https:\/\/do-gugan.com\/swift\/?p=474","title":{"rendered":"\u914d\u5217 11. \u9055\u3046\u65b9\u6cd5\u3067\u914d\u5217\u3092\u4f5c\u308b"},"content":{"rendered":"<p>\u65b0\u898f\u8981\u7d20\u306f2\u3064\u3002<\/p>\n<p>\u307e\u305a\u3001\u4eca\u30b9\u30c6\u30fc\u30b8\u4e0a\u306b\u3044\u308b\u5168\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u914d\u5217\u306b\u5165\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002world.allPossibleCoordinates\u306e\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u7248\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u3067\u3059\u300217\u884c\u76ee\u307e\u3067\u3067\u30d6\u30ed\u30c3\u30af\u3084\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u6761\u4ef6\u306b\u5f93\u3063\u3066\u914d\u7f6e\u3057\u305f\u5f8c\u300120\u884c\u76ee\u3067\u3001\u305d\u306e\u6642\u70b9\u306e\u5168\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092characters\u3068\u3044\u3046\u540d\u524d\u306e\u914d\u5217\u3092\u4f5c\u3063\u3066\u683c\u7d0d\u3057\u307e\u3059\u3002.existingCharacters()\u30e1\u30bd\u30c3\u30c9\uff08existing\u306f\u5b58\u5728\u3059\u308b\u3001\u3068\u3044\u3046\u610f\u5473\uff09\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3068\u3057\u3066\u3001allCordinates\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u5168\u30de\u30b9\u304c\u5bfe\u8c61\u306b\u306a\u308b\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u3057\u3066\u300122\u884c\u76ee\u3067\u305d\u306echaracters\u306b\u5165\u3063\u305f\u500b\u3005\u306e\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u306b\u3064\u3044\u3066\u3001for\u301cin\u6587\u3092\u4f7f\u3063\u3066\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u3055\u305b\u307e\u3059\u3002\u3053\u306e\u30b9\u30c6\u30fc\u30b8\u3067\u65b0\u767b\u5834\u306e\u30e1\u30bd\u30c3\u30c9\u3001<\/p>\n<ul>\n<li>danceLikeNoOneIsWatching()<\/li>\n<li>turnUp()<\/li>\n<li>breakItDown()<\/li>\n<li>grumbleGrumble()<\/li>\n<li>argh()<\/li>\n<\/ul>\n<p>\u306a\u3069\u304c\u4f7f\u3048\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u3069\u3093\u306a\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u3057\u3066\u304f\u308c\u308b\u304b\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u30016\u884c\u76ee\u306f\u6700\u521d\u3001\u5217\u306e\u5024\u3057\u304bheight\u306b\u5165\u3063\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u30b3\u30e1\u30f3\u30c8\u652f\u6301\u306b\u3042\u308b\u3088\u3046\u306b\u884c\u306e\u5024\u3082\u8db3\u3059\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:swift decode:true\">let allCoordinates = world.allPossibleCoordinates\r\n\r\nfor coordinate in allCoordinates {\r\n    \/\/ Change height to be the sum of the column and row for each coordinate.\r\n    \/\/ (\u5404\u5ea7\u6a19\u306e\u884c\u3068\u5217\u306e\u5408\u8a08\u3092\u9ad8\u3055\u3068\u3057\u306a\u3055\u3044)\r\n    let height = coordinate.column + coordinate.row\r\n    \r\n    for i in 0...height {\r\n        world.place(Block(), at: coordinate)\r\n    }\r\n    \r\n    if height &gt;= 2 &amp;&amp; height &lt; 4 {\r\n        world.place(Character(name: .blu), at: coordinate)\r\n    } else if height &gt; 5 {\r\n        world.place(Character(name: .hopper), at: coordinate)\r\n    }\r\n}\r\n\r\n\/\/ Initialize an array of existing characters in the puzzle world.\r\n\/\/ (\u30d1\u30ba\u30eb\u30ef\u30fc\u30eb\u30c9\u306b\u5b58\u5728\u3059\u308b\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u306e\u914d\u5217\u3092\u4f5c\u308a\u306a\u3055\u3044)\r\nlet characters = world.existingCharacters(at: allCoordinates)\r\n\r\n\/\/ For each of the characters, perform a set of actions.\r\n\/\/ (\u305d\u308c\u305e\u308c\u306e\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u306b\u3044\u304f\u3064\u304b\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3057\u306a\u3055\u3044)\r\nfor ch in characters {\r\n    ch.danceLikeNoOneIsWatching()\r\n}\r\n<\/pre>\n<p>\u5b9f\u884c\u5f8c\u306f\u3053\u3093\u306a\u72b6\u614b\u306b\u306a\u3063\u3066\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-486\" src=\"https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0030-861x1024.jpg\" alt=\"\" width=\"525\" height=\"624\" srcset=\"https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0030-861x1024.jpg 861w, https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0030-252x300.jpg 252w, https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0030-768x913.jpg 768w, https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0030.jpg 990w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/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>\u65b0\u898f\u8981\u7d20\u306f2\u3064\u3002 \u307e\u305a\u3001\u4eca\u30b9\u30c6\u30fc\u30b8\u4e0a\u306b\u3044\u308b\u5168\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u914d\u5217\u306b\u5165\u308c\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002world.allPossibleCoordinates\u306e\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u7248\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u3067\u3059\u300217\u884c\u76ee\u307e\u3067\u3067\u30d6\u30ed\u30c3\u30af\u3084\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u6761\u4ef6\u306b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/do-gugan.com\/swift\/?p=474\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u914d\u5217 11. \u9055\u3046\u65b9\u6cd5\u3067\u914d\u5217\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,17],"tags":[],"class_list":["post-474","post","type-post","status-publish","format-standard","hentry","category-learncode2","category-array"],"_links":{"self":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/474","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=474"}],"version-history":[{"count":5,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":487,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions\/487"}],"wp:attachment":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}