本次给大家带来的是大佬玩家解出的太极迷阵的99关通关方法,这个方式是使用一段java代码,看了真是佩服极了,下面就给大家附上详细内容,卡关的玩家终于可以过关啦!
太极迷阵99关通关方法
package myclass;
import java.util.Arrays;
public class TaiJiPlus {
// 首先找黑球当1 黑线其中1条对准黑的当1
// a 初始是黑还是白 白:0 黑:1
// b 初始黑线的位置 无黑线:0 有黑线:1
static String ball = "000110100010010100110000";
static String line = "100010110101010111010101";
static StringBuilder a = new StringBuilder(ball);
static StringBuilder b = new StringBuilder(line);
// 最终答案状态
static String aa = ball.replaceAll("1", "0");
static String cc = ball.replaceAll("0", "1");
// 定义答案如果被赋值则有答案
static String z = null;
// 将轴线状态用数组保存,便于计算状态
static String[] bb;
static {
bb = new String[b.length()];
for (int i = 0; i < b.length(); i++) {
bb = b.toString();
yy1(b);
}
}
// 递归方法传入上一层的参数,num1为上层轴线状态组合,c1为上层小球状态
static void abc(StringBuilder num1, StringBuilder c1) {
for (int i = 0; i < bb.length; i++) {
if (Integer.parseInt(num1.substring(num1.lastIndexOf("+") + 1)) >= num(b)) {
b = yy1(b);
continue;
}
StringBuilder num2 = num1.append("+" + num(b));
StringBuilder c2 = add(c1, b);
if (aa.equals(c1.toString()) || cc.equals(c1.toString())) {
z = num1.toString().substring(1, num1.lastIndexOf("+"));
System.out.println("答案状态为:" + c1);
System.out.println("答案是:" + z);
}
if (z != null) {
break;
}
// 递归,将参数传进去
abc(num2, c2);
if (z != null) {
break;
}
// num1末尾已经拼接上了+?,必须再将末尾+?删掉才能恢复成循环开始的字符串
num1.delete(num1.lastIndexOf("+"), num1.length());
b = yy1(b);
}
}
public static void main(String[] args) {
StringBuilder num = new StringBuilder("+" + num(b));
StringBuilder c = add(a, b);
abc(num, c);
}
// 二进制异或的方法
static StringBuilder add(StringBuilder a, StringBuilder b) {
int aa = Integer.parseInt(a.toString(), 2);
int bb = Integer.parseInt(b.toString(), 2);
StringBuilder c = new StringBuilder(Integer.toBinaryString(aa ^ bb));
if (c.length() < a.length()) {
do {
c.insert(0, '0');
} while (c.length() < a.length());
}
return c;
}
// 轴线偏移的方法
static StringBuilder yy1(StringBuilder a) {
if (a.lastIndexOf("0") == a.length() - 1) {
a.insert(0, '0');
} else if (a.lastIndexOf("1") == a.length() - 1) {
推荐阅读
Tags:
责任编辑:小黑游戏