@staticmethod<EOL><INDENT>def cross_state_value(state):<DEDENT>
centres, edges = state<EOL>value = <NUM_LIT:0><EOL>for edge in edges:<EOL><INDENT>if "<STR_LIT>" in edge:<EOL><INDENT>if edge["<STR_LIT>"] == centres["<STR_LIT:D>"]["<STR_LIT:D>"]:<EOL><INDENT>value += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>value += <NUM_LIT:2><EOL><DEDENT><DEDENT>elif "<STR_LIT:D>" in edge:<EOL><INDENT>if edge["<STR_LIT:D>"] != centres["<STR_LIT:D>"]["<STR_LIT:D>"]:<EOL><INDENT>value += <NUM_LIT:3><EOL><DEDENT><DEDENT>else:<EOL><INDENT>value += <NUM_LIT:1><EOL><DEDENT><DEDENT>edgeposes = {}<EOL>counts = {f: <NUM_LIT:0> for f in "<STR_LIT>"}<EOL>ngedges = []<EOL>for edge in edges:<EOL><INDENT>if "<STR_LIT>" in edge and edge["<STR_LIT>"] == centres["<STR_LIT:D>"]["<STR_LIT:D>"]:<EOL><INDENT>k = "<STR_LIT>".join(edge.facings.keys()).replace("<STR_LIT>", "<STR_LIT>")<EOL>edgeposes[k] = edge[k]<EOL>counts[k] += <NUM_LIT:1><EOL><DEDENT>elif "<STR_LIT:D>" in edge and edge["<STR_LIT:D>"] == centres["<STR_LIT:D>"]["<STR_LIT:D>"]:<EOL><INDENT>k = "<STR_LIT>".join(edge.facings.keys()).replace("<STR_LIT:D>", "<STR_LIT>")<EOL>edgeposes[k] = edge[k]<EOL>counts[k] += <NUM_LIT:1><EOL><DEDENT>elif "<STR_LIT>" in edge or "<STR_LIT:D>" in edge:<EOL><INDENT>ngedges.append(edge)<EOL><DEDENT>else:<EOL><INDENT>for k, s in edge:<EOL><INDENT>if s != centres["<STR_LIT:D>"]["<STR_LIT:D>"]:<EOL><INDENT>edgeposes[k] = s<EOL>counts[k] += <NUM_LIT:1><EOL>break<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for edge in ngedges:<EOL><INDENT>idx = "<STR_LIT>".index(edge[centres["<STR_LIT:D>"].colour])<EOL>for i in [-<NUM_LIT:1>, <NUM_LIT:1>]:<EOL><INDENT>if "<STR_LIT>"[(idx+<NUM_LIT:1>)%<NUM_LIT:4>] not in edgeposes:<EOL><INDENT>k = "<STR_LIT>".join(edge.facings.keys()).replace("<STR_LIT>"[idx], "<STR_LIT>")<EOL>edgeposes["<STR_LIT>"[(idx+<NUM_LIT:1>)%<NUM_LIT:4>]] = edge[k]<EOL>counts["<STR_LIT>"[(idx+<NUM_LIT:1>)%<NUM_LIT:4>]] += <NUM_LIT:1><EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>k = "<STR_LIT>".join(edge.facings.keys()).replace("<STR_LIT>"[idx], "<STR_LIT>")<EOL>if counts["<STR_LIT>"[(idx-<NUM_LIT:1>)%<NUM_LIT:4>]] > counts["<STR_LIT>"[(idx+<NUM_LIT:1>)%<NUM_LIT:4>]]:<EOL><INDENT>edgeposes["<STR_LIT>"[(idx-<NUM_LIT:1>)%<NUM_LIT:4>]] = edge[k]<EOL><DEDENT>else:<EOL><INDENT>edgeposes["<STR_LIT>"[(idx+<NUM_LIT:1>)%<NUM_LIT:4>]] = edge[k]<EOL><DEDENT><DEDENT><DEDENT>relative_pos = {f: centres[f][f] for f in "<STR_LIT>"}<EOL>if len(edgeposes) == <NUM_LIT:4>:<EOL><INDENT>for i in range(<NUM_LIT:4>):<EOL><INDENT>edgeposes["<STR_LIT:L>"], edgeposes["<STR_LIT:F>"], edgeposes["<STR_LIT:R>"], edgeposes["<STR_LIT:B>"] =edgeposes["<STR_LIT:F>"], edgeposes["<STR_LIT:R>"], edgeposes["<STR_LIT:B>"], edgeposes["<STR_LIT:L>"]<EOL>if edgeposes == relative_pos:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>value += <NUM_LIT:5><EOL><DEDENT><DEDENT>else:<EOL><INDENT>value += <NUM_LIT:3><EOL><DEDENT>return value<EOL>
Compute the state value of the cross solving search.