为了账号安全,请及时绑定邮箱和手机立即绑定

简单实现周易揲蓍法--程序

标签:
Java

package execute;

public class TheoryZhou
{

public static final long BIG_ENTRY=7*7; //初始49蓍草
private long LEFT_NUM=0; // 左手蓍草数
private long RIGHT_NUM=0; //右手蓍草数
private long [] xx= {0,0,0,0,0,0}; //卦体
private int seq=1; //变

public  void varySeq ( long entry ,int index) //变 方法
{
    System.out.print((index+1)+"爻-"+seq+"变:总数 "+entry+"   ");

    long entryLeft=Math.round(Math.random()*(entry-2))+2;
    long entryRight=entry-entryLeft;
    System.out.print("右堆 "+entryRight+"   ");
    entryLeft--;
    System.out.print("左堆 "+entryLeft+"   ");
    RIGHT_NUM=1;

    LEFT_NUM= (entryLeft%4==0 ? 4:entryLeft%4) + (entryRight%4==0?4:entryRight%4);
    System.out.println("左手 "+LEFT_NUM+"   ");
    xx[index]+= LEFT_NUM+RIGHT_NUM;
    if(seq==3)
    {
        seq=1;
    }
    else
    {
        seq++;
        varySeq(entry-LEFT_NUM-RIGHT_NUM,index);
    }
}

public static void main(String[] args)
{
    TheoryZhou one = new TheoryZhou();

    for(int index=0;index<one.xx.length;index++)
    {
        one.varySeq(BIG_ENTRY,index);
        System.out.println((index+1)+"爻 合揲: "+one.xx[index]);
    }

    long black=0;
    for(int index=5;index>=0;index--)
    {
        black=(BIG_ENTRY-one.xx[index])/4;
        if(black==6)
        {
            System.out.println("--"+"   老阴"+black);
        }
        else if(black==8)
        {
            System.out.println("--"+"   少阴"+black);
        }
        else if(black==7)
        {
            System.out.println("——"+"   少阳"+black);
        }
        else
        {
            System.out.println("——"+"   老阳"+black);
        }
    }
}

}

——————————————————————————————————
test:
1爻-1变:总数 49 右堆 21 左堆 27 左手 4
1爻-2变:总数 44 右堆 31 左堆 12 左手 7
1爻-3变:总数 36 右堆 28 左堆 7 左手 7
1爻 合揲: 21
2爻-1变:总数 49 右堆 42 左堆 6 左手 4
2爻-2变:总数 44 右堆 34 左堆 9 左手 3
2爻-3变:总数 40 右堆 26 左堆 13 左手 3
2爻 合揲: 13
3爻-1变:总数 49 右堆 8 左堆 40 左手 8
3爻-2变:总数 40 右堆 29 左堆 10 左手 3
3爻-3变:总数 36 右堆 25 左堆 10 左手 3
3爻 合揲: 17
4爻-1变:总数 49 右堆 26 左堆 22 左手 4
4爻-2变:总数 44 右堆 6 左堆 37 左手 3
4爻-3变:总数 40 右堆 31 左堆 8 左手 7
4爻 合揲: 17
5爻-1变:总数 49 右堆 19 左堆 29 左手 4
5爻-2变:总数 44 右堆 31 左堆 12 左手 7
5爻-3变:总数 36 右堆 10 左堆 25 左手 3
5爻 合揲: 17
6爻-1变:总数 49 右堆 26 左堆 22 左手 4
6爻-2变:总数 44 右堆 17 左堆 26 左手 3
6爻-3变:总数 40 右堆 4 左堆 35 左手 7
6爻 合揲: 17
-- 少阴8
-- 少阴8
-- 少阴8
-- 少阴8
—— 老阳9
—— 少阳7

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消