Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kill by surronding #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Simondharcourt
Copy link

Hello !
I saw your djambi project which I found amazing and wanted to contribute to the project.
Here is a suggestion to add the rule of the surronding of a chief.
Please let me know what you think of it.

@Simondharcourt Simondharcourt force-pushed the add-kill-by-surronding branch from b06c974 to 64a7761 Compare March 1, 2024 09:08
@mabdelaal86
Copy link
Owner

Thanks a lot for the contribution. It is very appreciated.
I will review your PR as soon as possible.

@Simondharcourt Simondharcourt force-pushed the add-kill-by-surronding branch from 64a7761 to c44c10a Compare March 1, 2024 13:35
Copy link
Owner

@mabdelaal86 mabdelaal86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will review the surrounding rule, and may come back with other comments.

README.md Outdated
## Roadmap

- [x] Simple AI algorithm.
- [x] Undo last play is missing.
- [x] implement traitors when chief is surrounded
- [ ] improve IA algorithm
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'AI' instead of 'IA'.
And kindly consider starting all sentences with a capital letters here, just for completeness with other sentences in this list.

return true;
}
visited.add(location);
List<Cell> directions = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Cell.allDirections instead.

];

for (Cell direction in directions) {
Cell newPosition = Cell(location.x + direction.x, location.y + direction.y);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the overloaded + operator of Cell class. So it can be:

final newPosition = location + direction;

for (Cell direction in directions) {
Cell newPosition = Cell(location.x + direction.x, location.y + direction.y);
if (!newPosition.isValid) {
continue; // Cell is off the board, considered as not surrounded.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you mean "continue to examine other directions" instead of "considered as not surrounded"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed

@@ -22,4 +21,6 @@ class Party {

Member? getMemberAt(Cell cell) =>
aliveMembers.firstWhereOrNull((m) => m.location == cell);

bool get isActive => chief.isAlive && !chief.isSurrounded() && movableMembers.isNotEmpty;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping isActive property close to isLost, as the logic is very related.

@Simondharcourt
Copy link
Author

I will review the surrounding rule, and may come back with other comments.

Great, thanks for the review. I updated the code in consequence

@mabdelaal86
Copy link
Owner

I have reviewed the kill by surrounding rules, and played the game with your changes. I found many deviations between your implementation and the rules (based on my understanding).

The following is what stated regarding killing by surrounding in the document that you have added:

The second great irony is that if a Leader becomes completely immobilized,
fully encircled by corpses either friend or foe that prevent him from moving, and does
not have a remaining Necromobile to rescue him by moving the surrounding dead to
a more favorable place of rest, he likewise perishes and is eliminated from the game.

But the forces of a Leader who perishes by encirclement become satellites only
when a Leader first occupies the Labyrinth or already occupies it following the
encirclement. While waiting for devolution (transfer of control), the other players
have no ownership over the pieces of the encircled Leader.

So, I see the following deviations in your implementation:

  1. If a Leader has a Necromobile, it is NOT considered encircled by corpses.
  2. If a Leader encircled by corpses and doesn't have a Necromobile, he perishes (get killed).
  3. Pieces of encircled Leader are controlled (or owned) by the Leader in the Maze (Labyrinth) or the first Leader occupies the Maze.
  4. While pieces are waiting for devolution (transfer of control), they can't be moved or killed (This part is from Wikipedia)

@Simondharcourt
Copy link
Author

Thank you for your review. I will apply some changes to correct it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants