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 Gale #724

Merged
merged 7 commits into from
Oct 31, 2023
Merged

add Gale #724

merged 7 commits into from
Oct 31, 2023

Conversation

RainRat
Copy link
Contributor

@RainRat RainRat commented Sep 20, 2023

No description provided.

@ianfab
Copy link
Member

ianfab commented Sep 29, 2023

Thanks. I have some doubts though whether this is worth it, considering that this seems like a very special case and rather many new config values for a single variant, so I currently slightly tend towards not merging this.

However, supporting file wildcards and rank 10 squares in the bitboard parsing of course would be useful, so that might be worth an independent PR. I would just suggest to use a a* syntax for that, since the * was at least by me intended like a wildcard, so *1 means the file is a wildcard, while a* would mean the rank is a wildcard.

@RainRat
Copy link
Contributor Author

RainRat commented Sep 30, 2023

Well, your project so up to you.

The different wildcard for files looks doable.

@RainRat
Copy link
Contributor Author

RainRat commented Sep 30, 2023

Well, I flipped the order in the commit message, but you know what I mean

@RainRat
Copy link
Contributor Author

RainRat commented Oct 13, 2023

Ok, what about instead of four configuration rules, there was a single ConnectionRule config where different connection rules were added as needed.
ie.

# [ConnectionRule]: connection-win rule [cross, cross-rotated, opposite, center, none]
# - cross: white trying to connect north-south, black east-west (ie. Gale)
# - cross-rotated: white trying to connect east-west, black north-south
# - opposite: either player trying to connect north-south, or east-west (ie. Tak)
# - center: either player trying to connect any 4-square corner with 9-square center (ie. Abak)

Any other misc connection rule that was mutually exclusive with the other connection rules could be added here as well.

This config is just an example, I am still only planning to add Gale in this Request.

@ianfab
Copy link
Member

ianfab commented Oct 13, 2023

I prefer your current approach compared to the new suggestion, it feels more transparent and flexible.

I think there is a bug in your current implementation though if I understand it correctly. It does not seem to check whether the starting zone is occupied, it just loops over all starting squares. That is also where I think the implementation could potentially be much more efficient. E.g., one could first determine the two var->connectRegion1[~sideToMove] & pieces(~sideToMove) and var->connectRegion2[~sideToMove] & pieces(~sideToMove) and both have to be truthy to have a chance of connecting at all.

And one could then beyond that probably also check the connectivity on a Bitboard level, basically the same as you do now, just not doing it per square, like

if (   (var->connectRegion1[~sideToMove] & pieces(~sideToMove))
    && (var->connectRegion2[~sideToMove] & pieces(~sideToMove)))
{
    Bitboard target = var->connectRegion2[~sideToMove];
    Bitboard current = var->connectRegion1[~sideToMove] & pieces(~sideToMove);
    while (true)
    {
        Bitboard new = 0;
        for (Direction d : var->connect_directions)
            new |= shift(d, current | new) & pieces(~sideToMove); // the "| new" here probably saves a few loops
        if (!(new & ~current) || (new & target))
            break; // either got stuck or succeeded
    }
    // check result
    ...
}

Not necessarily the best implementation, but might be a rough direction one could go towards to speed it up.

Edit: Doing the same from both sides and doing a meet in the middle might potentially be more efficient, but haven't really thought much about it.

@RainRat
Copy link
Contributor Author

RainRat commented Oct 21, 2023

  1. The ConnectionRule suggestion. I am just looking ahead. Adding the four zones is still a fine solution for the game I want to add. I had a look at Ludii at Connection games. Besides hexes and more complicated geometry there was:
  • Crossway, Gale, Resolve, Scaffold, Tara, Troll - would be covered by proposed "cross" or "cross-rotated"
  • Gonnect, Tak - would require an additional rule configuration anyway to specify that either player can connect north-south, or east-west.
  • Abak - connect any 4-square corner with 9-square center. would require an additional zone and an additional rule configuration to specify how it interacts.
  • Pippinzip, Pippinzip (Zipline) - "If Black connects any two sides of the board with a single orthogonally-connected group, they win; White wins if they connect all four sides with a group connected either orthogonally or diagonally." at least one additional rule configuration.
  1. Starting zone occupation. Yes, I just tested with Gale, where both sides are guaranteed to be occupied. Using your suggestion.
  2. Bitboard optimizations. Using your suggestion.
  3. Reserved word "new" can't be as a variable name. Changing your suggestion.
  4. I understand what you mean by meeting in the middle. If you think it's worth it, I can take a shot.

@ianfab
Copy link
Member

ianfab commented Oct 24, 2023

Thanks, it looks good to me now. However, after merging the other PR this now seems to have merge conflicts to resolve.

@RainRat
Copy link
Contributor Author

RainRat commented Oct 28, 2023

I think this solves the conflicts.

@ianfab ianfab merged commit dc28770 into fairy-stockfish:master Oct 31, 2023
15 checks passed
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