Skip to content

Commit

Permalink
Merge pull request #895 from GKnirps/implement_king
Browse files Browse the repository at this point in the history
Implement King in rust
  • Loading branch information
coding-horror authored Aug 29, 2023
2 parents 9e0065b + 0e86198 commit f062b60
Show file tree
Hide file tree
Showing 5 changed files with 631 additions and 1 deletion.
16 changes: 16 additions & 0 deletions 53_King/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions 53_King/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "king"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
fastrand = "^2.0.0"
28 changes: 28 additions & 0 deletions 53_King/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
King
====

Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html)

Conversion to [rust](https://www.rust-lang.org/).

Porting Notes
-------------

### Floats

The original code implicitly uses floating point numbers in many places which are explicitly cast to integers. In this port, I avoided using floats and tried to replicate the behaviour using just integers. It is possible that I missed some places where rounding a value would have made a difference. If you find such a bug, please notify me or make implement a fix yourself.

### Signed Numbers

I used unsigned integers for most of the program because it was easier than to check for negative values all the time. Unfortunately, that made the code a bit whacky in one or two places.

Since I only allow input of positive numbers, it is not possible to exit the game when entering the stats to resume a game, which would be possible by entering negative numbers in the original game.

### Bugs

I tried to fix all bugs listed in the [main README for King](../README.md). I have tested this implementation a bit but not extensively, so there may be some portation bugs. If you find them, you are free to fix them.

Future Development
------------------

I plan to add some tests and tidy up the code a bit, but this version should be feature-complete.
Loading

0 comments on commit f062b60

Please sign in to comment.