Skip to content

A Rust based implementation of the 1978 Oregon Trail CLI BASIC program.

License

Notifications You must be signed in to change notification settings

quantifex/rust_oregontrail_1978

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oregon Trail (1978 edition) in Rust

codecov

Program Flow / State Machine

graph TD
    A[Start<br>Print Instructions] --> Turn{Start Turn};
    Turn ---->|Traveled >= 2040 Miles| Oregon[Successfully<br>Reached Oregon];

    Turn -->|Illness or Injury| Doctor;
    Doctor --> |Can't Afford $20| Pneumonia;
    Doctor --> |Can't Afford $20| Injuries;
    Pneumonia --> Death;
    Injuries --> Death;

    Turn ---->|Traveled > 40 Weeks| Death[You have died];

    Turn -->|Need Food| Hunt[Hunt];
    Turn -->|Stop at a Fort| Fort[Fort<br>Buy Supplies<br>Buying 33% more expensive];
    Turn --> E[Eat];
    E -->|Travel| R[Riders Ahead];
    R --> Turn;
    Fort -->|Lose 45 Miles| E;
    Hunt -->|Not enough food| Starve[Starvation]
    Hunt -->|Lose 45 Miles| E;
    Starve --> Death

    style Oregon fill:#bbf,stroke:#6f6,stroke-width:2px,color:#fff,stroke-thick: 5 5
    style Death fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-thick: 5 5

Loading

Calculations

Random Number Generation:

  • rand(range) = random number between 1 and (range-1)

Travel:

  • Miles Traveled += 200 + ((Oxen Spend - 220)/(5 + rand(10)))

Development Environment

docker build -t oregon .
docker run -v $(pwd):/home/rust_oregontrail_1978 -it oregon

Testing

cargo test

# Prepare for code coverage (included in Dockerfile)
cargo install grcov
rustup component add llvm-tools-preview
rustup toolchain install nightly

# Test w/ code coverage
export RUSTFLAGS="-Zinstrument-coverage"
cargo +nightly test
grcov . --binary-path target/debug -s . -t html --branch --ignore-not-existing --excl-start "// GCOVR_EXCL_START" --excl-stop "// GCOVR_EXCL_STOP" -o ./coverage/

Build

cargo build --release

Run

# Development
cargo run

# Release
target/release/rust_oregontrail_1978

About

A Rust based implementation of the 1978 Oregon Trail CLI BASIC program.

Resources

License

Stars

Watchers

Forks

Packages

No packages published