{"id":400,"date":"2017-06-16T00:10:40","date_gmt":"2017-06-15T15:10:40","guid":{"rendered":"https:\/\/do-gugan.com\/swift\/?p=400"},"modified":"2017-06-17T20:55:14","modified_gmt":"2017-06-17T11:55:14","slug":"%e9%85%8d%e5%88%97-5-%e9%85%8d%e5%88%97%e3%81%ab%e8%bf%bd%e5%8a%a0%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/do-gugan.com\/swift\/?p=400","title":{"rendered":"\u914d\u5217 5. \u914d\u5217\u306b\u8ffd\u52a0\u3059\u308b"},"content":{"rendered":"<p>8&#215;8\u306e64\u30de\u30b9\u306e\u5ea7\u6a19\u3092allCoordinates\u914d\u5217\u306b\u5165\u308c\u3066\u3001for\u301cin\u6587\u30671\u30641\u3064\u306b\u3064\u3044\u3066\u30c1\u30a7\u30c3\u30af\u3092\u3057\u3066\u3001\u6761\u4ef6\u306b\u5f53\u3066\u306f\u307e\u308b\u3082\u306e\u3092\u5225\u306eblockSet\u3068\u3044\u3046\u914d\u5217\u306b\u8ffd\u52a0\u3057\u3001\u6700\u5f8c\u306bblockSet\u306e\u4e2d\u8eab1\u30641\u3064\u306b\u3064\u3044\u3066\u307e\u305ffor\u301cin\u6587\u3067\u30eb\u30fc\u30d7\u3057\u3066\u30d6\u30ed\u30c3\u30af\u3092\u7a4d\u307f\u4e0a\u3052\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u30b9\u30c6\u30fc\u30b8\u3067\u306e\u76ee\u65b0\u3057\u3044\u30c6\u30af\u30cb\u30c3\u30af\u306f\u30012\u3064\u3002<br \/>\n1\u3064\u306f\u3001coodinate.column\u3068\u304bcoodinate.row\u3067Coodinate\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u3082\u3063\u3066\u3044\u308bcolumn\u3084row\u3068\u3044\u3063\u305f\u5024\uff08\u30e1\u30f3\u30d0\u30fc\u5909\u6570\u3068\u547c\u3093\u3060\u308a\u3057\u307e\u3059\uff09\u3092\u53d6\u308a\u51fa\u305b\u308b\u70b9\u3067\u3059\u3002\u30c9\u30c3\u30c8\u8a18\u6cd5\u306f\u8272\u3005\u306a\u610f\u5473\u304c\u3042\u3063\u3066\u3084\u3084\u3053\u3057\u3044\u3067\u3059\u306d\u3002\u4e00\u822c\u306b\u3001<\/p>\n<pre class=\"lang:swift decode:true \">expert.moveForward()<\/pre>\n<p>\u306e\u3088\u3046\u306b\u6700\u5f8c\u306b()\u304c\u3064\u3044\u3066\u3044\u308b\u5834\u5408\u306f\u3001\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306a\u3093\u3089\u304b\u306e\u51e6\u7406\uff08\u30e1\u30bd\u30c3\u30c9\uff09\u3092\u5b9f\u884c\u3055\u305b\u308b\u610f\u5473\u3067\u3001<\/p>\n<pre class=\"lang:swift decode:true \">coodinate.column<\/pre>\n<p>\u306e\u3088\u3046\u306b()\u304c\u3064\u3044\u3066\u3044\u306a\u3044\u3082\u306e\u306f\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u4e2d\u306b\u3082\u3063\u3066\u3044\u308b\u5909\u6570\uff08\u30e1\u30f3\u30d0\u30fc\u5909\u6570\uff09\u3092\u6307\u3057\u3066\u3044\u308b\u3068\u601d\u3048\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u3002\u82f1\u8a9e\u306a\u306e\u304c\u96e3\u70b9\u3067\u3059\u304c\u305d\u306e\u610f\u5473\u304b\u3089\u306a\u3093\u3068\u306a\u304f\u30a4\u30e1\u30fc\u30b8\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n<p>2\u3064\u3081\u306f\u3001\u914d\u5217\u306b\u5bfe\u3057\u3066\u8981\u7d20\u3092\u8ffd\u52a0\u3059\u308b.append()\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u4ee5\u524d\u3001.insert()\u3068\u3044\u3046\u306e\u3082\u51fa\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u305d\u308c\u3068\u9055\u3044\u3001\u5358\u7d14\u306b\u6700\u5f8c\u306b\u4ed8\u3051\u8db3\u3059\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<pre class=\"lang:swift decode:true \">(\u914d\u5217\u540d).append((\u8ffd\u52a0\u3057\u305f\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8))\r\n<\/pre>\n<p>\u4eca\u914d\u5217\u5185\u306b\u8981\u7d20\u304c\u3044\u304f\u3064\u3042\u308b\u304b\u6c17\u306b\u3057\u306a\u304f\u3066\u826f\u3044\u306e\u3067\u3001\u3046\u3063\u304b\u308a\u7bc4\u56f2\u5916\u30a8\u30e9\u30fc\u3092\u51fa\u3057\u3066\u3057\u307e\u3046\u5fc3\u914d\u3082\u306a\u304f\u304a\u624b\u8efd\u3067\u3059\u306d\u3002\u914d\u5217\u306e\u4e2d\u3067\u306e\u9806\u756a\u304c\u91cd\u8981\u3067\u306f\u306a\u3044\u5834\u5408\u306f\u3001.insert()\u3088\u308a.append()\u304c\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e2\u70b9\u3092\u8e0f\u307e\u3048\u3066\u6b63\u89e3\u4f8b\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre class=\"lang:swift decode:true \">let allCoordinates = world.allPossibleCoordinates \/\/\u5168\u30de\u30b9\u306e\u5ea7\u6a19\u3092allCoordinates\u306b\u30bb\u30c3\u30c8\r\nvar blockSet: [Coordinate] = [] \/\/blockSet\u3068\u3044\u3046\u540d\u524d\u3067Coordinate\u578b\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u7528\u306e\u7a7a\u306e\u914d\u5217\u3092\u7528\u610f\r\n\r\n\/\/allCoordinates\u914d\u5217\u306e\u4e2d\u8eab\u304c\u9806\u756a\u306bcoodinate\u3068\u3044\u3046\u540d\u524d\u3067\u30bb\u30c3\u30c8\u3055\u308c\u30eb\u30fc\u30d7\u3092\u51e6\u7406\r\nfor coordinate in allCoordinates {\r\n    \/\/ Check for coordinates with a column &gt; 5 OR a row &lt; 4.\r\n    \/\/ (\u5404\u5ea7\u6a19\u306e\u5217\u304c5\u3088\u308a\u5927\u304d\u304f\u3001\u884c\u304c4\u3088\u308a\u5c0f\u3055\u3044\u304b\u30c1\u30a7\u30c3\u30af)\r\n    if coordinate.column &gt; 5 || coordinate.row &lt; 4 { \/\/\u30c9\u30c3\u30c8\u8a18\u6cd5.column\u3001.row\u3067coordinate\u306e\u5217\u756a\u53f7\u3001\u884c\u756a\u53f7\u3092\u8aad\u307f\u51fa\u305b\u308b\r\n        \/\/ Append coordinate to blockSet.\r\n        \/\/ \u5bfe\u8c61\u306e\u5ea7\u6a19\u3092\u914d\u5217blockSet\u306b\u8ffd\u52a0\r\n        blockSet.append(coordinate)\r\n    }\r\n}\r\n\r\n\/\/ For each coordinate in blockSet, place 6 blocks.\r\n\/\/ (blockSet\u306e\u4e2d\u306e\u305d\u308c\u305e\u308c\u306e\u5ea7\u6a19\u306b\u30016\u3064\u305a\u3064\u30d6\u30ed\u30c3\u30af\u3092\u914d\u7f6e)\r\nfor coordinate in blockSet {\r\n    \/\/\u30d6\u30ed\u30c3\u30af\u3092\u540c\u3058\u5ea7\u6a19\u306b6\u6bb5\u7f6e\u3044\u3066\u3044\u304f\u306b\u306f\u5358\u7d14\u306b6\u56de\u305a\u3064\u5b9f\u884c\r\n    for i in 1 ... 6 {\r\n        world.place(Block(), at: coordinate)\r\n    }\r\n}\r\n<\/pre>\n<p>\u3044\u307e\u3044\u3061\u4f55\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u308f\u304b\u308a\u3065\u3089\u3044\u306e\u3067\u3001\u6b63\u89e3\u4f8b\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3057\u305f\u6642\u306e\u7d50\u679c\u3082\u753b\u50cf\u3067\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-457 size-large\" src=\"https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0023-1024x879.jpg\" alt=\"\" width=\"525\" height=\"451\" srcset=\"https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0023-1024x879.jpg 1024w, https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0023-300x258.jpg 300w, https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0023-768x659.jpg 768w, https:\/\/do-gugan.com\/swift\/wp-content\/uploads\/2017\/06\/IMG_0023.jpg 1301w\" 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>8&#215;8\u306e64\u30de\u30b9\u306e\u5ea7\u6a19\u3092allCoordinates\u914d\u5217\u306b\u5165\u308c\u3066\u3001for\u301cin\u6587\u30671\u30641\u3064\u306b\u3064\u3044\u3066\u30c1\u30a7\u30c3\u30af\u3092\u3057\u3066\u3001\u6761\u4ef6\u306b\u5f53\u3066\u306f\u307e\u308b\u3082\u306e\u3092\u5225\u306eblockSet\u3068\u3044\u3046\u914d\u5217\u306b\u8ffd\u52a0\u3057\u3001\u6700\u5f8c\u306bblockSet\u306e\u4e2d\u8eab1\u30641 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/do-gugan.com\/swift\/?p=400\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u914d\u5217 5. \u914d\u5217\u306b\u8ffd\u52a0\u3059\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-400","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\/400","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=400"}],"version-history":[{"count":5,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":458,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/400\/revisions\/458"}],"wp:attachment":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}