{"id":162,"date":"2018-11-20T23:36:33","date_gmt":"2018-11-20T14:36:33","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=162"},"modified":"2018-11-20T23:40:16","modified_gmt":"2018-11-20T14:40:16","slug":"%e3%83%aa%e3%83%90%e3%83%bc%e3%82%b7%e3%81%a78%e6%96%b9%e5%90%91%e3%81%ae%e5%87%a6%e7%90%86%e3%82%92%e3%81%be%e3%81%a8%e3%82%81%e3%82%8b%e7%bd%ae%e3%81%91%e3%82%8b%e5%a0%b4%e6%89%80%e3%81%ae%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2018\/11\/20\/162\/","title":{"rendered":"\u30ea\u30d0\u30fc\u30b7\u30678\u65b9\u5411\u306e\u51e6\u7406\u3092\u307e\u3068\u3081\u308b&#038;\u7f6e\u3051\u308b\u5834\u6240\u306e\u8868\u793a"},"content":{"rendered":"<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/qePjQc8gVgY\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2018\/11\/Screenshot_20181119-224550.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-163\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2018\/11\/Screenshot_20181119-224550-289x300.png\" alt=\"\" width=\"289\" height=\"300\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2018\/11\/Screenshot_20181119-224550-289x300.png 289w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2018\/11\/Screenshot_20181119-224550-768x796.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2018\/11\/Screenshot_20181119-224550-987x1024.png 987w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><\/a><br \/>\n\u3044\u308d\u3093\u306a\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u3057\u3064\u3064\u3001\u306a\u3093\u3068\u306a\u304f\u982d\u306e\u4e2d\u306b\u306f\u3067\u304d\u3066\u304d\u305f\u306e\u3067\u3001\u30b5\u30af\u30b5\u30af\u3044\u304f\u304b\u306a\u3041\u3068\u601d\u3063\u305f\u3089\u305d\u3093\u306a\u3053\u3068\u306f\u306a\u304f\u3001\u3084\u305f\u3089\u624b\u9593\u53d6\u3063\u3066\u3084\u3063\u3068\u3067\u304d\u305f\u3002\u306a\u3093\u304b\u8272\u3005\u3042\u3063\u305f\u3051\u3069\u5168\u90e8\u306f\u899a\u3048\u3066\u306a\u3044\u306e\u3067\u3055\u3089\u3063\u3068\u66f8\u3044\u3068\u304f\u3002<\/p>\n<h2>8\u65b9\u5411\u306e\u51e6\u7406\u3092\u307e\u3068\u3081\u308b<\/h2>\n<h3>CheckFlip**()\u3092\u5206\u5272\u3059\u308b<\/h3>\n<p>\u77f3\u3092\u7f6e\u3051\u308b\u304b\u3069\u3046\u304b\u306e\u51e6\u7406\u3068\u305d\u308c\u3092\u5143\u306b\u5f15\u3063\u7e70\u308a\u8fd4\u3059\u51e6\u7406\u304c\u4e00\u7dd2\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u305d\u308c\u3092\u5206\u3051\u305f\u3002<\/p>\n<h4>checkCanFlip()<\/h4>\n<pre>public void checkCanFlip(TextView tv){\r\n    int di;\r\n    int taptag = Integer.parseInt(tv.getTag().toString());\r\n    TextView ttv;\r\n    int StoneColor;\r\n\r\n    for(int d = 0 ; d &lt;= 7 ; d++){\r\n        di = MoveQuantity[d];\r\n\r\n        for(int c = 1 ; c &lt;= 8 ; c ++) {\r\n            ttv = parentView.findViewWithTag(String.format(\"%02d\",taptag + (c * di)));\r\n\r\n            if(ttv == null) {\r\n                canFlip[d] = false;\r\n                break;\r\n            }\r\n\r\n            if (!existStone(ttv)) {\r\n                canFlip[d] = false;\r\n                break;\r\n            }\r\n\r\n            StoneColor = getStoneColor(ttv);\r\n\r\n            if (PlayerTurn == StoneColor &amp;&amp; StoneCount[d] &lt; 1) {\r\n                canFlip[d] = false;\r\n                break;\r\n            }\r\n\r\n            if (PlayerTurn != StoneColor) {\r\n                StoneCount[d]++;\r\n                continue ;\r\n            }\r\n\r\n            if (PlayerTurn == StoneColor) {\r\n                canFlip[d] = true;\r\n                break;\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p><a href=\"http:\/\/uguisu.skr.jp\/othello\/7gyou.html\">http:\/\/uguisu.skr.jp\/othello\/7gyou.html<\/a><\/p>\n<p>\u3053\u3061\u3089\u306e\u30b5\u30a4\u30c8\u304c\u3059\u3054\u304f\u53c2\u8003\u306b\u306a\u3063\u305f\u3002\u3053\u3053\u307e\u3067\u304d\u308c\u3044\u306b\u306f\u66f8\u3051\u306a\u3044\u3051\u3069\u30018\u65b9\u5411\u306e\u79fb\u52d5\u91cf\u3092\u914d\u5217\u3067\u6301\u3063\u3066\u304a\u304f\u3063\u3066\u3044\u3046\u306e\u304c\u3059\u3054\u3044\u3002\u304b\u3063\u3053\u3044\u3044\u3002<\/p>\n<ul>\n<li>MoveQuantity[]\u2192\u65b9\u5411\u3054\u3068\u306e\u79fb\u52d5\u91cf<\/li>\n<li>StoneCount[]\u2192\u65b9\u5411\u3054\u3068\u306e\u3072\u3063\u304f\u308a\u8fd4\u305b\u308b\u77f3\u306e\u6570<\/li>\n<li>canFlip[]\u2192\u65b9\u5411\u3054\u3068\u306b\u3072\u3063\u304f\u308a\u8fd4\u305b\u308b\u306a\u3089true<\/li>\n<\/ul>\n<p>\u3068\u3057\u3066\u3070\u30fc\u3063\u30688\u65b9\u5411\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3002\u4e0a\u8a183\u3064\u306f\u30e1\u30f3\u30d0\u5909\u6570\u306a\u306e\u3067\u6b21\u306e\u5f15\u3063\u7e70\u308a\u8fd4\u3059\u51e6\u7406\u3067\u3082\u4f7f\u3048\u308b\u3002<\/p>\n<p>\u4e0a\u7aef\u306b\u6765\u305f\u6642\u3001getTag()\u3059\u308b\u3068&#8221;01&#8243;\u306e\u306f\u305a\u304c&#8221;1&#8243;\u306b\u306a\u3063\u305f\u308a\u3068int\u578b\u306b\u3057\u305f\u5f0a\u5bb3\u304c\u51fa\u305f\u306e\u3067String.format\u30670\u57cb\u3081\u3057\u305f\u3002\u4f7f\u3044\u65b9\u304c\u3088\u304f\u5206\u304b\u3093\u306a\u304b\u3063\u305f\u3001\u7279\u306b\u5f15\u6570\u304c\u3002\u306e\u3067\u30b3\u30d4\u30da\u3002\u3067\u3082\u6012\u3089\u308c\u308b\u3002\u6012\u3089\u308c\u308b\u5185\u5bb9\u304c\u3088\u304f\u308f\u304b\u3063\u3066\u306a\u304b\u3063\u305f\u308a\u3002<\/p>\n<p>for\u6587\u30821\u65b9\u5411\u305a\u3064\u306e\u30b3\u30fc\u30c9\u304b\u3089\u307b\u307c\u6d41\u7528\u3067\u304d\u305f\u3051\u3069\u3001return, break, continue\u306e\u4f7f\u3044\u65b9\u304c\u3053\u3093\u304c\u3089\u304c\u308a\u30011\u56de1\u56de\u30b9\u30c6\u30c3\u30d7\u30a4\u30f3\u3057\u306a\u304c\u3089\u7f6e\u304d\u63db\u3048\u3066\u78ba\u304b\u3081\u3066\u3044\u3063\u305f\u3002\u5927\u5909\u3060\u3063\u305f\u3002\u3002\u3002<\/p>\n<h3>\u5f15\u3063\u7e70\u308a\u8fd4\u3059\u51e6\u7406\u3092\u4f5c\u308b<\/h3>\n<pre>public void FlipStone(TextView tv){\r\n    int di;\r\n    int taptag = Integer.parseInt(tv.getTag().toString());\r\n    TextView ttv;\r\n\r\n    for(int d = 0 ; d &lt;= 7 ; d++) {\r\n        di = MoveQuantity[d];\r\n\r\n        if(canFlip[d]){\r\n            setStoneToCell(tv);\r\n\r\n            for(int c = 1 ; c &lt;= StoneCount[d] ; c++){\r\n                ttv = parentView.findViewWithTag(String.format(\"%02d\",taptag + (c * di)));\r\n                setStoneToCell(ttv);\r\n            }\r\n        }\r\n    }\r\n\r\n    canFlip = new boolean[]{false, false, false, false, false, false, false, false};\r\n    StoneCount = new int[]{0,0,0,0,0,0,0,0};\r\n}<\/pre>\n<p>\u4e0a\u3067\u4f7f\u3063\u305f3\u3064\u306e\u5909\u6570\u3092\u5143\u306b\u3001\u77f3\u3092\u3072\u3063\u304f\u308a\u8fd4\u3057\u3066\u3044\u304f\u3002\u5b9f\u969bfor\u6587\u3067\u56de\u3057\u305f\u308a\u3001\u4f7f\u3063\u3066\u308b\u5909\u6570\u306f\u540c\u3058\u306a\u3093\u3060\u3051\u3069\u3001\u3053\u3053\u3092\u5206\u3051\u3068\u304b\u306a\u3044\u3068\u6b21\u306e\u7f6e\u304d\u77f3\u306e\u8868\u793a\u3067checkcanflip\u3092\u4f7f\u3044\u56de\u305b\u306a\u3044\u3068\u601d\u3063\u305f\u306e\u3067\u3002\u6700\u521d\u3001\u51e6\u7406\u306e\u6700\u5f8c\u3067\u914d\u5217\u3092\u521d\u671f\u5316\u3057\u3066\u306a\u304f\u3066\u3001\u7f6e\u304f\u3054\u3068\u306b\u3048\u3089\u3044\u5834\u6240\u306b\u7f6e\u304d\u77f3\u53ef\u80fd\u306e\u8868\u793a\u304c\u51fa\u3066\u305f\u3002<\/p>\n<h2>\u7f6e\u3051\u308b\u5834\u6240\u306e\u8868\u793a<\/h2>\n<p>\u3053\u306e\u524d\u4f5c\u3063\u305fCellArray\u3092\u4f7f\u3063\u3066\u30de\u30b9\u3092\u5168\u90e8\u691c\u67fb\u3057\u3066\u3044\u304f\u3002\u601d\u3063\u305f\u3093\u3060\u3051\u3069\u3001\u5225\u306bCellArray\u4f5c\u3093\u306a\u304f\u3066\u3082\u3001findViewWithTag\u3067\u56de\u3057\u3066\u3082\u5225\u306b\u826f\u304b\u3063\u305f\u3093\u3058\u3083\u2026\u3002\u3069\u3063\u3061\u306e\u304c\u697d\u306a\u3093\u3060\u308d\u3002\u3066\u3044\u3046\u304b\u6700\u521d\u306b\u3061\u3083\u3093\u3068\u65b9\u91dd\u3092\u6c7a\u3081\u3066\u81ea\u5206\u306b\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u4f5c\u3063\u3066\u3044\u3063\u3066\u306a\u3044\u306e\u304c\u60aa\u3044\u3093\u3060\u308d\u3046\u306a\u3002\u3084\u3063\u3071\u308a\u3042\u308c\u304c\u5fc5\u8981\u3001\u3068\u304b\u3001\u3053\u308c\u3044\u3089\u306a\u304b\u3063\u305f\u3001\u3068\u304b\u304c\u591a\u3044\u306e\u3067\u3001\u81ea\u5206\u3067\u3082\u628a\u63e1\u304c\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<h3>scanBoard()<\/h3>\n<p>\u3053\u306e\u540d\u524d\u306e\u95a2\u6570\u306fTextView\u9054\u3092\u914d\u5217\u306b\u3076\u3063\u3053\u3080\u95a2\u6570\u3060\u3063\u305f\u3051\u3069\u3001\u305d\u3063\u3061\u306fmakeCellArray\u306b\u540d\u524d\u5909\u3048\u3066\u3001\u3053\u3063\u3061\u3067\u3053\u306e\u540d\u524d\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<pre>public void scanBoard(){\r\n\r\n    for(TextView[] cc : CellArray){\r\n        for(TextView c : cc) {\r\n            if(existStone(c)){\r\n\r\n            }else{\r\n                checkCanFlip(c);\r\n\r\n                for (boolean b : canFlip) {\r\n                    if (b) {\r\n                        c.setText(\"*\");\r\n                        break;\r\n                    } else {\r\n                        c.setText(\"\");\r\n                    }\r\n                }\r\n                canFlip = new boolean[]{false, false, false, false, false, false, false, false};\r\n                StoneCount = new int[]{0, 0, 0, 0, 0, 0, 0, 0};\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\u3053\u3053\u306b\u6765\u308b\u307e\u3067\u304c\u9577\u304b\u3063\u305f\u3002\u3053\u308c\u4f5c\u3063\u3066\u308b\u9593\u306b\u3001checkcanflip\u306e\u4e0d\u5177\u5408\u304c\u898b\u3064\u304b\u3063\u305f\u308a\u3057\u3066\u3001\u3069\u3063\u3061\u304c\u30c0\u30e1\u306a\u306e\u304b\u5206\u304b\u3093\u306a\u304f\u306a\u3063\u305f\u3002\u7f6e\u3051\u308b\u5834\u6240\u306b\u306f\u300c*\u300d\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<p>\u305d\u306e\u524d\u306f<\/p>\n<pre class=\"java\">c.setBackgroundColor(Color.rgb(150, 255, 170));<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u8272\u3092\u4ed8\u3051\u3088\u3046\u3068\u3057\u3066\u3044\u305f\u3093\u3060\u3051\u3069\u3001\u8272\u3092\u4ed8\u3051\u308b\u3068\u67a0\u7dda\u304c\u6d88\u3048\u305f\u3002<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/gu93GspJC2c\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>\u3053\u3093\u306a\u3002<\/p>\n<p>\u67a0\u7dda\u306f\u3082\u3046\u5b8c\u5168\u306b\u7406\u89e3\u3057\u306a\u3044\u3067\u30b3\u30d4\u30da\u3057\u3066\u304d\u3066\u308b\u306e\u3067\u3001\u76f4\u3057\u65b9\u3082\u5206\u304b\u3089\u305a\u3002\u8abf\u3079\u308b\u6c17\u3082\u8d77\u304d\u305a\u3002\u306a\u306e\u3067\u300c*\u300d\u306b\u3057\u305f\u3002\u305d\u308c\u306b\u3088\u3063\u3066(&#8220;&#8221;)\u3067\u5224\u5b9a\u3057\u3066\u3044\u305f\u90e8\u5206\u3001existStone()\u3068\u304b\u3001\u306b\u652f\u969c\u304c\u51fa\u305f\u306e\u3067\u3001\u300c*\u300d\u306e\u5834\u5408\u3082\u7a7a\u767d\u6271\u3044\u306b\u3059\u308b\u3088\u3046\u306b\u30b3\u30fc\u30c9\u5909\u3048\u305f\u3002\u3053\u308c\u306f3\u30f6\u6240\u3050\u3089\u3044\u3060\u3063\u305f\u306e\u3067\u52a9\u304b\u3063\u305f\u3002<\/p>\n<h3>\u3053\u3053\u307e\u3067<\/h3>\n<p>\u66f8\u3044\u305f\u4ee5\u5916\u306b\u3082\u7d30\u304b\u3044\u6240\u3067\u3044\u3063\u3071\u3044\u5f15\u3063\u304b\u304b\u3063\u3066\u308b\u3093\u3060\u3051\u3069\u3001\u66f8\u304f\u306e\u304c\u3081\u3093\u3069\u3044\u3002<\/p>\n<p>\u3042\u3001\u3042\u3068for\u3068\u304bif\u304c\u306a\u3093\u3060\u304b\u6df1\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306a\u3002\u89e3\u6d88\u3057\u305f\u3044\u3051\u3069\u3001\u305d\u3053\u307e\u3067\u982d\u304c\u56de\u3089\u306a\u3044\u2026\u3002<\/p>\n<p>\u7f6e\u304d\u77f3\u53ef\u80fd\u304b\u306e\u8868\u793a\u304c\u3067\u304d\u305f\u306e\u3067\u3001\u3053\u3063\u304b\u3089\u300c\u305d\u3053\u306b\u306f\u7f6e\u3051\u307e\u305b\u3093\u300d\u306e\u30c8\u30fc\u30b9\u30c8\u3068\u3001\u30d1\u30b9\u6a5f\u80fd\u306b\u5e83\u3052\u3089\u308c\u308b\u3093\u3058\u3083\u306a\u3044\u304b\u306a\u3068\u601d\u3063\u3066\u308b\u3002\u3084\u3063\u3071\u308a\u982d\u306e\u4e2d\u3067\u8003\u3048\u308b\u306e\u3068\u3001\u5b9f\u969b\u66f8\u304f\u3093\u3058\u3083\u5927\u9055\u3044\u3060\u306a\u3041\u3002\u9811\u5f35\u3063\u3066\u3044\u3063\u3071\u3044\u8003\u3048\u305f\u3051\u3069\u3001\u601d\u3044\u901a\u308a\u306b\u52d5\u304b\u306a\u3044\u3053\u3068\u5c71\u306e\u5982\u3057\u3001\u5148\u304c\u601d\u3044\u3084\u3089\u308c\u308b\u305e\u3002\u3067\u3082\u3084\u3063\u3071\u5b8c\u6210\u3055\u305b\u305f\u3044\u6c17\u6301\u3061\u306e\u307b\u3046\u304c\u3042\u308b\u304b\u306a\u3002\u3046\u307e\u304f\u3044\u304f\u3068\u3044\u3044\u306a\u3041\u3002<\/p>\n<h3>\u53c2\u8003<\/h3>\n<p><a href=\"http:\/\/write-remember.com\/program\/java\/format\/\">http:\/\/write-remember.com\/program\/java\/format\/<\/a><\/p>\n<p><a href=\"https:\/\/www.javadrive.jp\/start\/array\/\">https:\/\/www.javadrive.jp\/start\/array\/<\/a><\/p>\n<p><a href=\"https:\/\/www.javadrive.jp\/android\/textview\/index4.html\">https:\/\/www.javadrive.jp\/android\/textview\/index4.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3044\u308d\u3093\u306a\u30b5\u30a4\u30c8\u3092\u53c2\u8003\u306b\u3057\u3064\u3064\u3001\u306a\u3093\u3068\u306a\u304f\u982d\u306e\u4e2d\u306b\u306f\u3067\u304d\u3066\u304d\u305f\u306e\u3067\u3001\u30b5\u30af\u30b5\u30af\u3044\u304f\u304b\u306a\u3041\u3068\u601d\u3063\u305f\u3089\u305d\u3093\u306a\u3053\u3068\u306f\u306a\u304f\u3001\u3084\u305f\u3089\u624b\u9593\u53d6\u3063\u3066\u3084\u3063\u3068\u3067\u304d\u305f\u3002\u306a\u3093\u304b\u8272\u3005\u3042\u3063\u305f\u3051\u3069\u5168\u90e8\u306f\u899a\u3048\u3066\u306a\u3044\u306e\u3067\u3055\u3089\u3063\u3068\u66f8\u3044\u3068\u304f\u3002 8\u65b9\u5411\u306e\u51e6\u7406\u3092\u307e\u3068 &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2018\/11\/20\/162\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":163,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[3,6,4,13],"class_list":["post-162","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-8","tag-android","tag-androidstudio","tag-4","tag-13"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":3,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions\/166"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media\/163"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}