nimlib

Crates.ionimlib
lib.rsnimlib
version0.1.1
sourcesrc
created_at2023-01-25 17:01:38.831438
updated_at2023-02-11 01:20:17.358888
descriptionA Rust library for Nim games: calculate nimbers and possible moves
homepagehttps://github.com/Tanja-4732/nimlib#readme
repositoryhttps://github.com/Tanja-4732/nimlib
max_upload_size
id767622
size42,731
Tanja (Tanja-4732)

documentation

https://docs.rs/nimlib

README

NimLib

githubcrates-iodocs-rs

A Rust library for Nim games: calculate nimbers and possible moves

A game called Nim

Nim refers to a set of (mathematical/strategy) games where two players take turns in removing coins from stacks of coins. The player who makes the last legal move wins.

Every Nim game consists of a set of rules, which define how many coins may be removed from a stack in a single move. Each move affects exactly one stack of coins, possibly requiring the stack to be split into two non-empty stacks.

A version of Nim called Poker-Nim is played with the addition of coin-pools, where removed coins are kept in the player's pool, to be placed in future moves, if allowed by the rules, and desired by the player.

About the library

This library calculates the nimbers for stacks of a given height, and the possible moves for a given position.

Nimbers

The nimber of a stack can be thought of as some kind of score or evaluation of how good this position is for the player who is to move.
See the nimlib::nimbers module for functions for calculating nimbers.

A nimber of 0 means that the player who is to move has no winning strategy, and will lose the game, no matter what move they make, given their opponent plays optimally.
Conversely, a nimber greater than 0 means that the player who is to move has a winning strategy, and will win the game, no matter what move their opponent makes, given the player to move plays optimally.

Moves

The nimlib::moves module provides functions for calculating the possible moves for a given position.

A position simply refers to a list/set of stacks, the nimber of a position is the XOR-sum of the nimbers of the stacks in the position, the rules regarding winning conditions for the entire position are the same as for the individual stacks.

License

GNU Lesser General Public License v3.0

Copyright (C) 2023 @Tanja-4732

NimLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

NimLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with NimLib. If not, see https://www.gnu.org/licenses/, specifically https://www.gnu.org/licenses/lgpl-3.0.html.

Commit count: 56

cargo fmt