Ludii Forum
Problems implementing Battleship - Printable Version

+- Ludii Forum (https://ludii.games/forums)
+-- Forum: Questions (https://ludii.games/forums/forumdisplay.php?fid=13)
+--- Forum: About the Ludii Grammar (https://ludii.games/forums/forumdisplay.php?fid=15)
+--- Thread: Problems implementing Battleship (/showthread.php?tid=394)

Pages: 1 2 3 4


RE: Problems implementing Battleship - Eric Piette - 05-03-2021

Hi,

Ok for the GUI problem, I think Matthew is aware but just in case I will tell him to take a look.

Regards,
Eric


RE: Problems implementing Battleship - MatthewStephenson - 05-06-2021

Hi,

The problem with the image sizes should be fixed in the next release :)

Cheers,
Matthew


RE: Problems implementing Battleship - slimy_asparagus - 05-10-2021

(05-06-2021, 06:40 PM)MatthewStephenson Wrote: Hi,

The problem with the image sizes should be fixed in the next release :)

Cheers,
Matthew
Thank you Matthew,

So the remaining issues with my Battleship implementation are largely cosmetic. (They do affect game play a little but not enormously). I would be prepared to submit my implementation now trusting that it will all work out.

However I still have one more issue, cosmetic I guess.

When the game ends I think the whole board should be unhidden. I looked at how Mastermind does this. Basically every move has a then clause which checks to see if the game has ended and if it has unhide the board.

Now in this case, unhiding the board will mess up the victory condition so I need to set a variable and check that. Then in the end rules I simply check the variable.

Now I hit a further complication that there already is a (then ...) clause in that spot. Like this:

Code:
(define "ClearShotSpace"
    (do
        (set State at:(last From) ("Hit"))
        next:(set Hidden at:(last From) False to:Mover)
    )
)

......


    (then
        ("ClearShotSpace")
    )
So now I need to change the (then .. clause) to

Code:
    (then
        (do
            ("ClearShotSpace")
            next:("CheckForVictory")
        )
    )
So now when I put ("ClearShotSpace") in side a (do ,,, ) ludeme it seems to no longer work.

I attach a version which is broken in this way. If you remove the out (do ,,,) wrapper around  ("ClearShotSpace") it reverts to what works best so far.

I was hoping to produce a test case. However I am struggling with that.I wanted to create a deck of cards and deal those to the board, but I can't get that to work. So far I have tried

Code:
(deck cardsBySuit:25 suits:1)
And even if I got it to work, I would not know how to deal that to the board.


RE: Problems implementing Battleship - slimy_asparagus - 05-10-2021

I have checked that the changes promised for 1.1.18 work. Thanks again Matthew.

I have managed to come up with a simple test case for the latest problem it is attached. It is a simple game. There is one hidden piece. Each player takes turns to try and find the piece. However if I wrap the unhide instruction in a (do ludeme) it breaks.


RE: Problems implementing Battleship - Eric Piette - 05-17-2021

Hi,

All the ludemes concerning Cards are in a preliminary version, so for the moment we advise to not use them (moreover they are not our priority, I hope to continue to work on them next year).

Concerning your example file, what you currently do in it is right, that should be a (then ...) (I just modified the "to:Mover" to "to:All").
So I am not sure why you want to use a (do ....) here?
If that's because you already have a (then ...) in your battleship, you can just use a (and ....) to do both set of actions, no?

Regards,
Eric


RE: Problems implementing Battleship - slimy_asparagus - 05-28-2021

(05-17-2021, 06:27 AM)Eric Piette Wrote: Hi,

Sorry, it has taken me a long time to get round to looking at this.


(05-17-2021, 06:27 AM)Eric Piette Wrote: All the ludemes concerning Cards are in a preliminary version, so for the moment we advise to not use them (moreover they are not our priority, I hope to continue to work on them next year).
This is not at all a problem for me.



(05-17-2021, 06:27 AM)Eric Piette Wrote: Concerning your example file, what you currently do in it is right, that should be a (then ...) (I just modified the "to:Mover" to "to:All").
I don't see why you did this. I know it's only a silly example but I think I did mean to:Mover. In the silly example at least it makes a difference. I don't understand why you would do this.



(05-17-2021, 06:27 AM)Eric Piette Wrote: So I am not sure why you want to use a (do ....) here?
If that's because you already have a (then ...) in your battleship, you can just use a (and ....) to do both set of actions, no?
No, in battleships the order really does matter. Do I need to go into more details? Post number 33 attached the battleships code, though it is the current "working" code, with the code I am trying to implement commented out. So I don't think it is that easy to follow in that state.


The Unhide code is much simpler. It does not have (do...) ludemes nested inside other (do ...) ludemes. It simply shows that a (set Hidden) statement breaks when inside a (do .. ludeme). Why is (do ..) so fragile? If we are only meant to use it in some circumstances it is not documented what those circumstances are, not are they trapped by the compiler. And I currently I don't have an alternative, though I could look into nested (then....) ludemes.


RE: Problems implementing Battleship - slimy_asparagus - 05-28-2021

I have managed to get chaining (then.....) clauses to work.

I am still puzzled by the fragility of (do....) though.

I should be submitting a finished version soon. I more or less just need to write up rules.