INDAPlus21 / INDAPlus21/dpeilitz-chess
Pass
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
_I recognise the struggle, därför får du inte komplettering._
## Komplettering (egentligen inte) (som den hade sett ut)
**Almost there!**
Attans! Only tests missing?
```rust
running 4 tests
test tests::tests::it_works ... ok
test tests::tests::game_in_progress_after_init ... ok
test tests::tests::promotion_test ... ok
test tests::tests::move_works ... FAILED
failures:
---- tests::tests::move_works stdout ----
(0, 1)
(0, 2)
(0, 2)
thread 'tests::tests::move_works' panicked at 'assertion failed: `(left == right)`
left: `None`,
right: `Some((Peasant, White))`, src\tests.rs:35:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
tests::tests::move_works
test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass '--lib'
```
Your code has a lot of improvement potetial.
For example, you have some instances of copy-pasta, which can be combated with local closures or help functions. Some of your `match`-statements can also be replaced with `if`-statements and arithmetics.
```rust
let rank: usize = match rank_inp {
'a' => 7,
'b' => 6,
'c' => 5,
'd' => 4,
'e' => 3,
'f' => 2,
'g' => 1,
'h' => 0,
_ => 0,
};
let file: usize = match file_inp {
1 => 7,
2 => 6,
3 => 5,
4 => 4,
5 => 3,
6 => 2,
7 => 1,
8 => 0,
_ => 0,
};
```
or shorter
```rust
let rank: usize = match rank_inp as u32 {
_code if _code >= 97 && _code <= 104 => 104 - _code,
_ => panic!("Index is outside of scope. Invalid rank!")
};
let file: usize = if file_inp >= 1 && file_inp <= 8 {
8 - file_inp
} else {
panic!("Index is outside of scope. Invalid file!")
};
```
Also, it is more efficient to search for check from the kings perspective, rather than from all of the opponent's pieces.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Rust test suite and reading src/tests.rs, especially the failing move_works test and its assertion. Trace the move behavior that produces None instead of Some((Peasant, White)); done means the test suite passes, with the additional review concerns addressed where applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100