class Scene_Riversi < Scene_MenuBase alias takossprocess_reverse_stone process_reverse_stone def process_reverse_stone(x,y,color) takossprocess_reverse_stone(x,y,color) n_empty = number_empty n_stones = 64 - n_empty update_currentnode(n_stones, x, y) end ###オープニング def init_opening(chara) @current_node = Opening_Node.new([-1,-1,0]) set_opening_tree(chara) return end def set_opening_tree(chara) opening_list = chara.opening_list opening_list.each do |op| nodes = $data_opening[op[0]] nodes_branch = nodes[1] oparray = op[1] if (oparray) nodes_branch.weight1 = oparray[0] nodes_branch.weight2 = oparray[1] end add_nodes(nodes) end @current_node = $top_node end def add_node(root_node,node) if (!root_node.arrows.include?(node)) new_root_line = root_node.root_line.dup root_node.arrows.push(node) new_root_line.push(root_node) node.root_line = new_root_line end end def add_nodes(node_list) if (node_list.length <= 1) return end node_list.each_index do |i| add_node(node_list[i],node_list[i + 1]) if i < node_list.length - 1 end end def update_currentnode(n_stones, px, py) if (!@current_node || n_stones == 4) return end if(@opening_orientation < 0 ) (0..7).each do |k| if check_set_opening_orientation(k,n_stones) @opening_orientation = k end end end change_orientation_in_opening coord = trans_coord_global_into_edge(@opening_orientation,[px, py]) if (@current_node) @current_node = get_node_match_value(coord[0], coord[1]) || nil end end def update_currentnode_in_stage2(px, py) if (@current_node) @current_node = get_node_match_value(px, py) || nil @current_person.current_node_name = @current_node.name if @current_node end end def get_node_match_value(epx,epy) nodes = @current_node.arrows if (nodes.length == 0) @current_node = nil end nodes.each do |child| if (child.value[0] == epx && child.value[1] == epy) return child end end return nil end def check_opening_tree return @current_node && @current_node.arrows.length != 0; end def check_opening_start if (number_empty == 60) if (get_stone(3,3,@board) == 2 && get_stone(4,4,@board) == 2) if (get_stone(3,4,@board) == 1 && get_stone(4,3,@board) == 1) return true end end end return false end def check_set_opening_orientation(edge, n_stones) if (!@records[0]) return false end if (n_stones >= 5) record = @records[0] coord = [record[1], record[2]] coorde = trans_coord_global_into_edge(edge,coord) if (coorde[0] == 5 && coorde[1] == 4) return true end end return false end def put_opening_tree(pt) nodes = @current_node.arrows px = pt % BOARDWIDTH py = pt / BOARDWIDTH coord = trans_coord_global_into_edge(@opening_orientation,[px,py]) nodes.each do |child| if (child.value[0] == coord[0] && child.value[1] == coord[1]) weight1 = child.weight1 || 1 weight2 = child.weight2 || 1 return child.value[2] * weight1 / weight2 end end return 1 end def check_opening_symmetry(pcount,op_name,coord) if (@current_node.name == op_name) record = @records[pcount] return 0 unless record tcoord = trans_coord_global_into_edge(@opening_orientation,[record[1], record[2]]) if (tcoord[0] == coord[0] && tcoord[1] == coord[1]) return 1 elsif (tcoord[0] == coord[1] && tcoord[1] == coord[0]) return 2 end end return 0 end def change_orientation_in_opening $orientation_change_in_op.each do |e| pcount = @current_node.n_stones - 4 if check_opening_symmetry(pcount,e[0],e[1]) == 2 if e[2] == 0 @opening_orientation = get_edge_same_root(@opening_orientation) else @opening_orientation = get_edge_same_pointa(@opening_orientation) end end end end end