Ludii Forum
Throngs latest attempt - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Problems (https://ludii.games/forums/forumdisplay.php?fid=5)
+--- Forum: Game Problems (https://ludii.games/forums/forumdisplay.php?fid=17)
+--- Thread: Throngs latest attempt (/showthread.php?tid=255)



Throngs latest attempt - dale walton - 11-14-2020

Thanks for the new documentation.  It would help to have a bit more background about the uses of Pending. - But I think I now understand (apply) and (moveAgain) better.

So I have tried another attempt at Throngs after scores of different approaches, I think this approach should work: Basically I need one state variable (I used Pending, but Var or Value Player might work?)
I use it to keep track of two things: the remaining influence inherited from the initial site selection; and whether it is the first or second turn in the double moves. (I use defines to keep this clear)

The compiler seems to properly interpret my defines.  However the game still does not compile, and I don't know why.  Perhaps you don't have a category for games that do the kind of thing I am trying to do, or perhaps there is something I am still doing wrong.  Please take a look and identify the problem for me.


RE: Throngs latest attempt - cambolbro - 11-14-2020

Hi,

One possible issue I see is that you've defined MoveInTurn with an argument as follows:

    (define "MoveInTurn" #1)

but then you call it like this:

    (then ("SetInfluence" (+ "MoveInTurn" "MoveFinished")))

Since the define has an argument #1, then probably you need to bracket it and pass a value in, like a function, e.g.:


   (then ("SetInfluence" (+ ("MoveInTurn" 1) "MoveFinished")))   
   
or: 

   (then ("SetInfluence" (+ ("MoveInTurn" Mover) "MoveFinished")))   

or: 

   (then ("SetInfluence" (+ ("MoveInTurn" ~) "MoveFinished")))

where the ~ indicates "not used" for a parameter.

In general, it's safer to bracket ALL defines to scope them, even if they don't have arguments, just to be sure.

Or maybe you meant to write:

    (define "MoveInTurn" 1) ???

Regards,
Cameron


RE: Throngs latest attempt - dale walton - 11-14-2020

No, I checked the compiler listing and it is doing what I intended, which is to stand in as a #1 (pass an argument) argument in the code (just for readability of the intention).  Probably not a good standard as easy to mess up as you point out, but this is not the issue with the compilation not working.

I have attached part of what appeared during the compilation attempt, that shows how the compiler parsed the defines, and I reformatted it a little to make it readable, and reviewed it. It seems OK to me, but is not yet the whole thing.

I got this by copy pasting the file into the editor, and using the compile button.  Otherwise the compile messages are suppressed.  The output was very long, but interpreting what it means in terms of where the error is would require a deep understanding of how your compiler is programmed.


RE: Throngs latest attempt - Eric Piette - 11-16-2020

Hi Dale,

I just looked your file and you have an error you do often in that file.
For many calls of the define you have a parameter which is not in the define.

For example, the define "TCapture" has no parameter however you call it with ("TCapture" "MoveInTurn")
And that's the same for many others too.

This is why the compiler can not help you, because that's not possible for it to understand the calls of these defines.

As an advice to avoid such complex description to fix, you should do your game step by step. Simple step at the start, then you add one define, you try to compile ect... until you reach what you want. In doing that, you will directly know where is the problem in your current description.

Regards,
Eric


RE: Throngs latest attempt - dale walton - 11-16-2020

Eric, I don't think that is the problem. TCapture does have a parameter because "MoveInTurn" is the parameter #1 and occurs in Tcapture as well. The value for this parameter is being passed down two levels as intended, and I have seen the compiler output showing how it interpreted everything and it is correct. I have also done this without using a define representing #1 and it has the same problem. If you don't believe me I can send it. I did this to test how Ludii does define replacements and to document the intent of what I am doing, which is necessarily complicated because of the nature of the game with double turns each containing variable length/number-of-decision moves. If you looked at the second file I sent. It is how the compiler understood tand replaced the defines, and the end of a long process of trying to match it to possible game configurations. - And the expansion IS correct as I intended it, the syntax was accepted as OK, but the game "couldn't be compiled"

I think the problem is more that the compiler game find a combination of game-flags that properly fits the mechanics of the game. But it also could be something in the graphics or metadata parts of the code.

I do try to use the process you describe, but often find that towards the end, I suddenly get garbage from the compiler, because the syntax is correct, but what I am trying to do is not. eg changes the flags the compiler sets for the game. - or because the added code requires an addition of a corresponding statement elsewhere that I am not aware is needed.

Can you check to see whether the compiler has a case that corresponds to what I am trying to do and what kind of game this game should be, if it can be handled?
I am using the pending value as a state variable to control both the kind of move, its range, and who the next player is (ie when moveAgain is applied ) and so on. It is a kind of machine, and perhaps this is something that can't yet be done? eg, can a metagame where one player decides which rules apply to the next playr's turn be handlesd by Ludii using a state variable to carry the choice information?

For example if I used (set Value Mover... Instead of (set Pending, or used (set Var .. (but Var doesn't seem to take integer values) how does the compiler treat it differently? Can a game use both (set Score Mover and (set Value Mover in the same game? If I used the pot to hold this information instead, what would happen?

If the new guide had more examples and info about pending and about phases, it would be helpful. Is the pending integer always referring to a site?

(sorry for so many questions)


RE: Throngs latest attempt - Eric Piette - 11-17-2020

Hi Dale,

No I confirm the problem is the one I explained to you.

Here your define "TCapture" with no parameter (#1 or more)


Code:
(define "TCapture"
  (forEach
    Piece
    (move
      Add
      (piece (mover))
      (to
        if:(le "MoveFinished" (+ 2 ("InfluenceAt" (to))))
        (apply
          (and
            (remove (to))
            ("SetInfluence" (+ "MoveInTurn" (+ 2 ("InfluenceAt" (last From)))))
          )
        )
      )
    )
    Next
  )
)

But you call it with a parameter

Code:
("TCapture" "MoveInTurn")

So I do not know for the other parts but that is wrong.
The file is too huge with such problem to detect any other problem.

I advice you to rewrite that game in copy and paste first the base of that game (with no define and just the easiest parts) and slowly to add one by one your define in calling them.
At each step you modify the new file, run the compilation, if it passes continue to add more, if not, you know where is the first problem and you will probably be able to fix it. if you do not understand the problem in the new file you did, post the new file here in telling me what is the last thing you added in it. That's the easiest way to help you with that.

For you other questions, no I can not check anything if the compiler does not compile the game. Try what I explained above and you should easily find the first problem. And for the define I put in the top of that message, you can not call it with a parameter if no #1 (or more if more parameters) is "written" in it.

Regards,
Eric


RE: Throngs latest attempt - dale walton - 11-19-2020

"MoveInTurn" is defined and gets replaced with  "#1" creating a parameter.  But since this is bad design and unnecessary, we needn't argue about it. I get the same problem when I use  #1 whereever  "MoveInTurn" appears.  - see attached.


RE: Throngs latest attempt - Eric Piette - 11-19-2020

Hi,

You have still some issues of the same kind in your file.
As an example the (define "Continue2Move" ...) has a #1 needed when you call it, but I see in the (play ...) a call of it with no argument provided.

Regards,
Eric


RE: Throngs latest attempt - dale walton - 11-19-2020

OK, I will look again. Thanks

I can see it now, and will run a test to see whether that solves the problem