Ludii Forum
(count Groups NotOwn) - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Suggestions (https://ludii.games/forums/forumdisplay.php?fid=10)
+--- Forum: Ludii Features / Services (https://ludii.games/forums/forumdisplay.php?fid=11)
+--- Thread: (count Groups NotOwn) (/showthread.php?tid=67)

Pages: 1 2


(count Groups NotOwn) - dale walton - 06-01-2020

Not sure if this is a grammar or a feature question.

A player's pieces may divide the board into different dynamic regions (no necessarily tight to an opponent's as in Go)  These are essentially groups of NotOwn sites.

I have a game which needs to count them in its end condition. In the documentation count Groups acts only on players roles. Does it also work on regions such as (sites NotOwn) and if not would you extend it to do so? Also for NotEnemy - or any other site definition.

The essential end condition would be something like:

(end (if (lte (count Groups Mover) (count Groups NotOwn)) ) (result Player Win))

I understand that my games are not designed to be particularly easy for AIs to optimize.


RE: (count Groups NotOwn) - cambolbro - 06-01-2020

Hi,

We have a Territory ludeme which might be useful, it's used in Go.lud.

Regards,
Cameron


RE: (count Groups NotOwn) - dale walton - 06-01-2020

From what I can see, that only gives the size of the territory, not its topology. I'm looking for the number of individual territories. It is almost exactly the function used in scoring games by player's territory count, where the territories relate to the sites of each player's pieces, but in this case I need to also know for sites based on the board minus the players pieces.

I would think to provide what you currently have, it must convert player's pieces to sets of sites, but the documentation and syntax does not show it. The: (count groups Mover) is available. If the syntax were (count groups (sites Mover)) then it would be clear what I want to do is supported. Or if the documentation listed site states as well as player states.


RE: (count Groups NotOwn) - dale walton - 06-02-2020

As mentioned above, I can't find anything that actually tells me what a territory is as a ludeme. If it is exactly a region of all mutually connected sites after sites occupied by the player have been removed, I could use it.

I worry that territory for go is potentially something different because I see no scripting of, for example, shared territory and scoring in the go .lud - maybe there are special classes for go?

For efficiency the game engine would probably want to update any kind of group allowed in a game every turn, as opposed to recalculating it from scratch, but that needn't keep groups from being broader than only sets of pieces.

So is player territory size just a game state per player being updated each move, or is territory really equivalent to a list of lists of connected sites, that could be recalculated or tracked in various ways by the engine, from which territory size is derived, or is territory something else?

Is a territory a group of NonOwned sites? Is it countable?

For simplicity in scoring, player group counts are going to be much more commonly involved than player territory counts, but there is a specific mathematical reason for counting them in my game, because a player's territory count sets a lower limit on the number of groups that an opponent can reduce his pieces into, and so when the difference between territory count and group count is not negative, the opponent no longer has any chance of doing better. Among other things, it allows the game to end conclusively without filling the board (I have fewer groups than you can get) and gives a fair method of ending or of scoring multi-player games ended by passing.

A two-player work-around would be to allow a player to choose to end the game, and then add enemy pieces to all the empty spaces, and then count both player's groups: the winner being the player with the fewest groups, or the last to play if equal. Ending by mistake would be equivalent to resignation. Missing a win condition might allow the opponent to claim it. And this doesn't work for multi-player.


RE: (count Groups NotOwn) - dale walton - 06-04-2020

Hope I'm not being a pest, I come from the era of procedural programming, and it can take a while to get my head around a liguistic approach. Ludii is meant as a game vocabulary....

So to try to express the need in vocabulary terms: what I am looking for is probably a (count (regions (sites boundedBy ({players})) adjacent)) -- where boundedBy ({players}) means (difference (sites board) (sites ({players})) and adjacent is the type of connection relationship that determines whether two sites are in the same region. and "regions" signifies that the count is of the number of distinct regions, and not of the number of sites in the union of the regions.

In other words, the board minus the sites occupied by those players is grouped into connected areas (defaulted as connection by adjacency) which can be counted.
Other types of connection could be oriented knight's moves for example.

If only a single player's sites are involved, then they could be considered as territories for that player eg. ( count (regions (NotOwn))) would be the same as (count territories (Mover)) plural to distinguish it from from counting the number of contained sites.

Different games could have different types of territories implemented as well.

(count (Regions (sites(Empty) adjacent) could then be written as (count territories (Empty))


RE: (count Groups NotOwn) - dale walton - 06-15-2020

Do you support counting groups belonging to a Team?

Edit: Not a sum of the count of the groups of each player in the team, which could be done by combinining separate counts, - but rather a count of groups formed by considering pieces of both players to be held in common.

Do you support overlapping Teams, eg two teams each including a player and the neutral player (for scoring) or teams that all include the shared player (for moving), or teams that all include the next player (for moving or for scoring).


RE: (count Groups NotOwn) - Eric Piette - 06-22-2020

That's a lot of questions Wink

I will try to answer to the last ones, if you need more, please send us another reply with the specific questions.

>> Do you support counting groups belonging to a Team?
Not in the version 9.0.3, to get the connections or groups, we use the union find data structure (https://en.wikipedia.org/wiki/Disjoint-set_data_structure) but in the version 0.9.3, it is working by player, not by piece or by team. That's something we will do for the release 1.0.0

>> So to try to express the need in vocabulary terms: what I am looking for is probably a (count (regions (sites boundedBy ({players})) adjacent)) -- where boundedBy ({players}) means (difference (sites board) (sites ({players})) and adjacent is the type of connection relationship that determines whether two sites are in the same region. and "regions" signifies that the count is of the number of distinct regions, and not of the number of sites in the union of the regions. In other words, the board minus the sites occupied by those players is grouped into connected areas (defaulted as connection by adjacency) which can be counted.

I am not sure what you try to get here. Can you make an example with a simple board, something like a square board of size 5 with sites from the bottom left to the top right indexed 0 to 24. Tell me where are the pieces and what region you try to get according to their positions.


RE: (count Groups NotOwn) - dale walton - 06-22-2020

Thanks for your information. I look forward to 1.0.0. Are you implementing both by piece and by team? Are you implementing by site? or do you have a separate count for territory that you are implementing.

For example, how would I find the count of the regions of the board that are bounded by a given team, as opposed to the number of groups the team has? Bout these counts would be useful to me.


RE: (count Groups NotOwn) - dale walton - 07-29-2020

Noted that 1.0 has counting elements of groups by team.

But what I actually need is the number of NonAdjacentRegions within a given region. - not the number of elements. This could also be used for a large variety of scoring systems as well, depending how sites are selected.

Also could (sites NotOwn) could be allowed as a short hand for (union (sites Occupied by:NonMover) (sites Empty))
so that:

(Count NonAdjacentRegions (sites NotOwn)) would tell me how many regions a player's pieces divide the board into.


RE: (count Groups NotOwn) - cambolbro - 07-30-2020

Hi,

> But what I actually need is the number of NonAdjacentRegions within a given region.

These is actually an optional <region> parameter to (count Groups ...) but it is not implemented yet. We will look into implementing it.

> Also could (sites NotOwn) could be allowed as a short hand for (union (sites Occupied by:NonMover) (sites Empty))

You can achieve this by creating a (define "SitesNotOwn" (union (sites ...))), then you can simply call "SitesNotOwn" anywhere in your description.

Regards,
Cameron