Skip to content

Commit

Permalink
docs: Update Readme
Browse files Browse the repository at this point in the history
Updated Readme code sample to reflect current API

Add instructions for building on Mac OS

Remove requirement of nightly Rust compiler, as it is no more needed
  • Loading branch information
vitvakatu committed Dec 22, 2020
1 parent 860a550 commit d5510da
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,35 @@ You will need Python 3.7 or newer.

#### Rust

You will need the nightly build of Rust:
You will need to install the latest Rust:

https://www.rust-lang.org/tools/install


`rustup toolchain install
nightly`

Now Rust Nightly is installed but not activated.

To switch to nightly
globally, change the default with `rustup default nightly`:

```console
$ rustup default nightly
info: using existing install for 'nightly'
info: default toolchain set to 'nightly'

nightly unchanged: rustc 1.9.0-nightly (02310fd31 2016-03-19)

```

Now any time you run `cargo` or `rustc` you will be running the
nightly compiler.
https://rustup.rs/

### Installing

Clone the sc2-pathlib repository and run `cargo build --release` in the sc2-pathlib directory. This should create a `libsc2pathlib.so`(Linux), a `sc2pathlib.dll`(Windows), or a `libsc2pathlib.dylib` file in `sc2-pathlib\target\release`. If on Windows, you need to rename the `sc2pathlib.dll` file to `sc2pathlib.pyd`.
On Linux or Mac OS, rename it to `sc2pathlib.so`.

Clone the sc2-pathlib repository and run `cargo build --release` in the sc2-pathlib directory. This should create a `sc2pathlib.so`(Linux) or a `sc2pathlib.dll`(Windows) file in `sc2-pathlib\target\release`. If on Windows, you need to rename the `sc2pathlib.dll` file to `sc2pathlib.pyd`.

Alternatively, you can run `build.bat` which automates the process above for Windows or `linux_build.sh` to automate on Linux.
Alternatively, you can run helper scripts:
- `build.bat` on Windows
- `linux_build.sh` on Linux
- `mac_build.sh` on Mac OS

Copy `sc2pathlib.so`/`sc2pathlib.pyd` to the directory where your Python program resides to be able to import it as a Python library.

#### Example
```
>>> import sc2pathlib
>>> pf = sc2pathlib.PathFind([[1,1,1,1],[0,0,0,1],[1,1,0,1],[1,1,1,1]], (0, 0), (2, 0))
>>> pf.find_path([[1,1,1,1],[0,0,0,1],[1,1,0,1],[1,1,1,1]], (0, 0), (2, 0))
>>> pf = sc2pathlib.PathFind([[1,1,1,1],[0,0,0,1],[1,1,0,1],[1,1,1,1]])
>>> pf.find_path((0, 0), (2, 0))
([(0, 0), (0, 1), (0, 2), (0, 3), (1, 3), (2, 3), (3, 3), (3, 2), (3, 1), (2, 0)], 94142)
([(0, 0), (0, 1), (0, 2), (0, 3), (1, 3), (2, 3), (3, 3), (3, 2), (3, 1), (2, 0)], 9.414199829101562)
>>>
```

## PathFind
#### Parameters
`grid`: A two-dimensional array using 1 for pathable and 0 for obstacles.
`grid`: A two-dimensional array using 1 for pathable and 0 for obstacles.
Example:
`[[1,1,1,1],[0,0,0,1],[1,1,0,1],[1,1,1,1]]`

Expand Down

0 comments on commit d5510da

Please sign in to comment.