7 个版本 (4 个破坏性更新)

0.5.0 2023 年 2 月 2 日
0.4.0 2019 年 4 月 27 日
0.3.2 2019 年 1 月 20 日
0.3.1 2018 年 11 月 13 日
0.1.0 2018 年 11 月 6 日

#245 in 游戏

MIT/Apache

56KB
1K SLoC

iching

Crates.io Documentation MIT/Apache Lines of Code

这个库包含使用易经进行占卜的方法。相关的 CLI 应用程序灵感来源于原始的 ching(6) Unix 程序。

易经(又称《变易之书》)是一种基于占卜术(为随机数赋予意义)的古老占卜方法。通过生成 6 到 9 之间的六个数字来创建一个六爻,其意义包含在易经书中。

你可以在 维基百科 上找到关于易经 2000 多年历史的许多信息。

安装和运行 CLI 应用程序

要安装 CLI 应用程序,只需运行

cargo install iching

安装完成后,你可以通过运行 CLI 并不带任何参数来访问帮助屏幕。

如果你发现任何问题,请通过 Github 提交。

使用库的简化示例

use iching::{Hexagram, HexagramOrdering, HexagramRepository};

// Implementing the HexagramRepository trait is the most complex
// aspect of using this library. See the included CLI app for an
// example implementation called HexagramExampleRepository.
let hexagrams: &mut dyn HexagramRepository<HexagramInfo = HexagramExampleInfo> = &mut HexagramExampleRepository::new();

// Don't forget to initialize repository after construction, else
// it could fail to work or even panic.
hexagrams.initialize().expect("Initialization of hexagrams has failed");

// Create a new random hexagram.
let new_hexagram = Hexagram::from_coin_tosses();
// Get the number of the hexagram according to changing lines and ordering
let hexagram_number = new_hexagram.as_number(false, HexagramOrdering::KingWen);

// Fetch the hexagram's info from the repository that was initialized earlier.
let hexagram_info = hexagrams.get_by_number(hexagram_number)
                           .expect("Failed to get hexagram info by number (pre)");

// Print the hexagram info for the user
print!("{hexagram_info:?}");

许可证

iching 是免费且开源的软件,根据 MIT 许可证和 Apache 许可证 2.0 的条款分发。

除非你明确说明,否则根据 Apache-2.0 许可证定义的,你有意提交给作品以包含在内的任何贡献,将按照上述方式双许可,没有额外的条款或条件。

依赖项

~2–10MB
~94K SLoC