Ludii Forum
Understanding Patterns - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Grammar Problems (https://ludii.games/forums/forumdisplay.php?fid=24)
+--- Thread: Understanding Patterns (/showthread.php?tid=749)



Understanding Patterns - patzer - 11-11-2021

I'm trying to understand how to specify patterns using
Code:
(is Pattern ...)


In particular, I'm looking at the example on page 86 of the Ludii Game Logic Guide

 
Code:
(is Pattern {F R F R F R F})

So this specifies four adjacent pieces in a square all of the same type. I'd like to change this to match four pieces in a square with a space between each piece (i.e. the four pieces are in the corner cells of a 3x3 region). I've done a text search through all the .lud files and don't find much in the way of examples to try and generalize from. I've tried

 
Code:
(is Pattern {F F R F F R F F R F F})


But this doesn't seem to work.


RE: Understanding Patterns - Eric Piette - 11-15-2021

Hi,

The syntax for what you wish is

Code:
(is Pattern {F F R F F R F F R F F} whats:{(mover) 0 (mover) 0 (mover) 0 (mover) 0})


Here that means the pattern you are describing has to be checked with alternately a piece corresponding to the index of the mover (so if you have only one piece this index is the same as the piece) and then an empty site.

I join in attachment the lud file showing you that in a concrete (easy) example game.

Regards,
Eric


RE: Understanding Patterns - dale walton - 01-06-2023

Please add this information to the Guide. The use of 0 for (any player including empty) is not intuitive until one knows a lot about Ludii.

Also: Are patterns automatically rotated to every direction; are they automatically reflected?


RE: Understanding Patterns - Eric Piette - 01-25-2023

Hi,

I added this to the Ludii Guide.

They are automatically rotated, yes.
But I am always interested, if you have any issues with it, because this ludeme is not used a lot currently.

Regards,
Eric


RE: Understanding Patterns - dale walton - 01-25-2023

I avoid ludemes that I don't understand, unless some other approach is not working. Patterns could be useful. I was trying to find ways of testing for three pieces in a row where the piece placed matched exactly one of them, and the rows could be any direction, and the last placed piece could be in any position in the row...

I think I found another way to do it.


RE: Understanding Patterns - dale walton - 09-19-2023

I would like to use Patterns to find patterns of empty spaces. 
Currently in whats, 0 means anything, correct?
But is there a number to represent specifically the space should be empty? and is there a number to represent that the space should be occupied by any player?

In the particular game Affinage) I want to find empty cross-shapes next to the last piece played and then check whether they are fully surrounded orthogonally as well as equally surrounded by both players in a specified direction  (e.g. adjacent or orthogonal)  This will allow me to eliminate some ifAfterwards:(can move ... ) checks which are very time consuming.
In the hex version it is open tripplets surrounded by a ring of pieces in a particular sequence that needs checking.