public class guaxiang {
public static void main(String[] args) {
guaxiang guaxiang = new guaxiang();
for (int i = 0; i < 6; i++){
int num = guaxiang.yao();
// System.out.print(num);
if (num == 6 || num == 8) System.out.println(num + " ■■■■ ■■■■");
else if (num == 7 || num == 9)System.out.println(num + " ■■■■■■■■■■■■");
}
}
//返回一爻
public int yao(){
int shicaoSum = 55;
shicaoSum = shicaoSum - 6;
Random random = new Random();
//一变 鸿蒙初开
int tdr[] = tiandiren(random,shicaoSum);
int bian1 = bian(tdr[0],tdr[1],tdr[2]);
shicaoSum = shicaoSum - bian1;
//二变
int tdr2[] = tiandiren(random,shicaoSum);
int bian2 = bian(tdr2[0],tdr2[1],tdr2[2]);
shicaoSum = shicaoSum - bian2;
//三变
int tdr3[] = tiandiren(random,shicaoSum);
int bian3 = bian(tdr3[0],tdr3[1],tdr3[2]);
shicaoSum = shicaoSum - bian3;
return shicaoSum / 4;
}
//每一卦变化数
public int bian(int tian,int di,int ren){
int tianBian = tian % 4;
if (tianBian == 0) tianBian = 4;
int diBian = di % 4;
if (diBian == 0) diBian = 4;
int renBian = ren;
return tianBian + diBian + renBian;
}
//返回天,地,人的数
public int[] tiandiren(Random random,int shicaoSum){
int[] tdr = new int[3];
//天
tdr[0] = returnRandom(random,shicaoSum);
//地
tdr[1] = shicaoSum - tdr[0];
tdr[1] = tdr[1] - 1;
//人
tdr[2] = 1;
return tdr;
}
//返回一个随机的天数(生成的随机数既是天数)
public int returnRandom(Random random,int shicaoSum){
return random.nextInt(1,shicaoSum);
}
}
五十五蓍草算卦代码(有些地方写的很呆,主要是蓍草算卦中有这一部步骤,代码可以简化,但是感觉缺点仪式感,至于灵不灵,难说( *︾▽︾))
最新推荐文章于 2024-08-31 10:44:02 发布