var pref = new Array();
var line_a = new Array();
var line_b = new Array();
var link_parent = new Array();
var link_child = new Array();
var link_active = new Array();
var gr = new Array();
var number_link;
var number_line;
var fight, def;
function sample(){
var timer;
var delay = 100;
number_link=0;
faststep();
var loop = function () {
select_fight();
select_def();
if (def.length > 1) game();
check();
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function check(){
for (s = 1; s < 48; s++) {
gr[s] = pref[s];
for (sx = 1; sx < number_link + 1; sx++) {
h = 0;
if (link_child[sx] == pref[s]) h = h + 1;
if (link_active[sx] > 50) h = h + 1;
if (h == 2) gr[s] = link_parent[sx];
}
}
}
function game(){
for(s=1;s<number_link+1;s++){
h = 0;
if(link_child[s]==def)h=h+1;
if(link_active[s]>50)h=h+1;
if (h == 2) link_active[s] = 0;
}
number_link = number_link + 1;
link_parent[number_link] = fight;
link_child[number_link] = def;
link_active[number_link] = 100;
}
function select_def() {
var delta = new Array();
sx = 0;
for(s=1;s<number_line+1;s++){
if (line_a[s] == fight) sx = sx + 1;
if (line_a[s] == fight) delta[sx] =line_b[s];
}
for(s=1;s<number_line+1;s++){
if (line_b[s] == fight) sx = sx + 1;
if (line_b[s] == fight) delta[sx] =line_a[s];
}
n1 = sx*Math.random();
n2 = Math.floor(n1) + 1;
def = "A";
if(sx>0)def = delta[n2];
for(s=1;s<number_link+1;s++){
h = 0;
if(link_parent[s]==fight)h=h+1;
if(link_child[s]==def)h=h+1;
if(link_active[s]>50)h=h+1;
if (h == 3)def="A";
}
for(s=1;s<number_link+1;s++){
h = 0;
if(link_child[s]==fight)h=h+1;
if(link_parent[s]==def)h=h+1;
if(link_active[s]>50)h=h+1;
if (h == 3)def="A";
}
}
function select_fight(){
n1 = 47*Math.random();
n2 = Math.floor(n1) + 1;
fight = pref[n2];
}
function paint(){
var str;
str="<table>";
for(s=1;s<number_link+1;s++){
str=str+"<tr><td>"+link_parent[s]+"</td>";
str=str+"<td>"+link_child[s]+"</td>";
}
str=str+"</table>"
$("#memo").html(str);
}
function faststep(){
var link = new Array();
var data;
data = new XMLHttpRequest();
data.open("GET", "data.txt", false);
data.send(null);
var str=data.responseText;
var x=str.split("\n");
for (s = 1; s < 48; s++) {
link[s] = new Array();
for (sx = 1; sx < 48; sx++) {
link[s][sx] = "A";
}
}
number=x.length;
for(s=0;s<number;s++){
var x1=x[s].split(",");
n = x1[0];
pref[n] = x1[1];
for(sx=2;sx<x1.length;sx++){
link[n][sx]=x1[sx];
}
}
tx = 0;
for (s = 1; s <48;s++ ){
for(sx=2;sx<10;sx++){
h = 0;
if(link[s][sx]=="A")h=100;
if (h < 50) tx = tx + 1;
if (h < 50) line_a[tx] = pref[s];
if (h < 50) line_b[tx] = link[s][sx];
}
}
number_line = tx;
}
1,北海道,青森県
2,青森県,岩手県,秋田県
3,岩手県,宮城県
4,宮城県,福島県
5,秋田県,山形県
6,山形県,新潟県
7,福島県,栃木県,茨城県
8,茨城県,東京都
9,栃木県,埼玉県
10,群馬県,埼玉県,新潟県
11,埼玉県,東京都
12,千葉県,東京都
13,東京都,神奈川県,山梨県
14,神奈川県,静岡県
15,新潟県,富山県
16,富山県,石川県
17,石川県,福井県
18,福井県,滋賀県
19,山梨県,長野県
20,長野県,愛知県
21,岐阜県,滋賀県,愛知県
22,静岡県,愛知県
23,愛知県,三重県
24,三重県
25,滋賀県,京都府
26,京都府,大阪府
27,大阪府,兵庫県,奈良県,和歌山県
28,兵庫県,岡山県,鳥取県
29,奈良県
30,和歌山県
31,鳥取県,島根県
32,島根県,山口県
33,岡山県,広島県,香川県
34,広島県,山口県
35,山口県,福岡県
36,徳島県,香川県,高知県
37,香川県,愛媛県
38,愛媛県,高知県
39,高知県
40,福岡県,佐賀県,大分県
41,佐賀県,長崎県,熊本県
42,長崎県
43,熊本県,鹿児島県
44,大分県,宮崎県
45,宮崎県,鹿児島県
46,鹿児島県,沖縄県
47,沖縄県
最終更新:2015年06月02日 19:27