Ludii Forum
remember unique:True - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Ludii Player Problems (https://ludii.games/forums/forumdisplay.php?fid=6)
+--- Thread: remember unique:True (/showthread.php?tid=668)



remember unique:True - dale walton - 08-07-2021

I've had a case in a long buggy script where remember #1 unique:True didn't work (because when the same values were forgotten a result based on them was still active.)

However this part of the script worked when I made the sole change of instead using:

(if
    (not (is In (site) (values Remembered #1)))
    (remember Value #1 (site))) // unique:True)



Therefore I surmise there is a bug in the unique parameter.


Here is a bit more of the script to show you the kind of thing I was doing

(define "AddSuicideSites"  // parameter  Variable name "SuicideP1" or  "SuicideP2"
(forEach Site
  ("PlayableSitesNotYetOnList" #1)
  (apply
  if:(and
    (not ("IsMarkerPlayerAtSite" Mover (site)))
    (not
    ("IsBlockedByBetween" Mover
      (site)
      ("Sites2Check" #2)
  )))
  (if
    (not (is In (site) (values Remembered #1)))
    (remember Value #1 (site))) // unique:True)
)))


My move output on the both version version looked like:
9. [(SitePlaced= 25), (Add Ball1 to 25/0), (Remember Value 'SuicideP2' 12), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 26), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 23), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 19), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 13), (Remember Value 'DebugAddSites' 26), (Remember Value 'DebugBallSites' 126), (Remember Value 'SuicideP2' 12), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 26), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 23), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 19), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 13), (Remember Value 'DebugAddSites' 26), (State 7=1), (Remember Value 'SuicideP2' 12), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 26), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 23), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 19), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 13), (Remember Value 'DebugAddSites' 26), (State 14=1), (Remember Value 'SuicideP2' 12), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 26), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 23), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 19), (Remember Value 'DebugAddSites' 26), (Remember Value 'SuicideP2' 13), (Remember Value 'DebugAddSites' 26), (State 18=1)]

10. [(SitePlaced= 17), (Remove 17), (Remove 17), (Add Ball2 to 17/0), (Forget Value 'SuicideP2' 12), (Forget Value 'SuicideP2' 13), (Forget Value 'SuicideP2' 19), (Forget Value 'SuicideP2' 23), (Forget Value 'SuicideP2' 26), (Remember Value 'DebugOwnBalls' 17), (State 7=0), (State 14=0), (State 17=0), (State 18=0), (State 20=0), (Add I2 to Edge 69/0), (State Edge 69=5), (Add I2 to Edge 69/1), (State Edge 69=5)]

But the result on the game was different: in the non-working version the sites 12,13,19,23,26 could not be added to, but on the working version they could.  The relevant add code is:

(move Add
    (piece (id "Ball" Mover))
    (to
    (difference
      (sites Empty)
      (sites (values Remembered #1))
    )
    (apply (set Var "SitePlaced" (to))) 
    )
    stack:True
    (then
    (if
      (= 1 ("Liberties" Mover Next (var "SitePlaced")))
      ("UpdateOwn" 1)
  )))


I hope this is enough for you to work with, because I have no idea how to write an example an be assured to get the same result.


RE: remember unique:True - Eric Piette - 08-18-2021

Hi,

As far as I can tell after some tests that seems to work, that's not possible to add the value to the remembered ones if it is already in them because of the previous states.

Regards,
Eric