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


Problems implementing Battleship - slimy_asparagus - 01-26-2021

I have made the most progress implementing Battleship with large pieces. I attach a .lud file. In principle this seems a really straightforward approach. However I am facing a number of issues.

1. The look of the pieces is not functional.
2. Depending on the graphics metadata the hiddenness may be broken.
3. I can't seem to get the "shooting" phase to work as I expect. This issue apparently has nothing to do with large pieces.

The attached file replaces the "tile" implementation with simple "piece" definitions as I think that is most illustrative.
So the five ship types are all 1 square large whereas they should be 5,4,3,3,2 respectively.

For 1. I think it would be best if a ship looked like a number of squares in a line with each square of the ship having the appropriate letter code on it. This is what I was trying to implement when I replace (piece...) with the commented out (tile ...) definitions.

Also with the proposed graphics metadata and (tile....) piece definitions the hiddenness is broken.

I have no idea why the shooting phase is not working. The idea was that

a.) The player would select a hidden square occupied by an opponent's piece.
b.) That square would be unhidden.
c.) Some sort of marker would be placed. (I would probably like to be a little bit more sophisticated than a Dot, but it would do for now.)


EDIT: The attachment was missing. Fixed.


If this is too much to answer, then please could we focus on the first two questions (which are clearly linked). Once that  is fixed I could produce a more narrowly focussed test case for the last part.

Afterthought: Is the problem with the shooting phase because I forgot to add a stacking parameter set to true?


RE: Problems implementing Battleship - Eric Piette - 01-27-2021

Hi,

For the playing phase you are using that:

Code:
(set Hidden at:(last From) false to:All)


Unfortunately, the roleType All (which is a special case) was not implemented, I just did it and that will be in the next release to use it as you expect.

However in waiting the next release you can replace that by:

Code:
(and
    (set Hidden at:(last From) false to:P1)
    (set Hidden at:(last From) false to:P2)
)


To make that phase to work.

Can you try that and tell us if some issues are still in your game concerning logic or graphics (for the second one, Matthew will take a look).

Regards,
Eric


RE: Problems implementing Battleship - slimy_asparagus - 01-27-2021

Eric,

Thanks. That worked. I am considering how to move forward. I will come back with a working example for Matthew.

Nicholas


RE: Problems implementing Battleship - slimy_asparagus - 01-30-2021

I have a really bizarre idea for how to progress this. The idea is to convert the large pieces at the point they are placed. I think it may be doable and would give me the best of both worlds.


RE: Problems implementing Battleship - slimy_asparagus - 01-31-2021

I guess this one is for Matthew. I am officially stuck on both approaches.

First Approach

This approach uses Large Pieces and once placed they remain as large pieces. This hit the following difficulties:

1. The look of the pieces is not functional.

2. The hiddenness may be broken.

3. I can't work out how to indicate a hit on a ship.

The fundamental problem here is that I am trying to use the Large pieces in ways that are totally undefined. I am not surprised it ran into difficulties. I have no idea if this is an approach that the Ludii team will (or should) ever contemplate supporting.

Conversion Approach

The first approach works fine during the setup phase. The issue is that in the shooting phase I really want to treat the large pieces as a collection of ordinary pieces. If I can effect that change it should work perfectly. An example of my effort is here:

Code:
            (piece "Carrier" Each)
            (tile
                "CarrierTemplate"
                Each
                { { F F F F } { L F F F F } }
                (move
                    (from if:(is In (from) (sites Hand Mover)))
                    (to (intersection (sites Mover "Defence") (sites Empty)))
                    (then
                        (do
                            (set Var "TileTo" (last To))
                            next:(do
                                (forEach
                                    Site
                                    (sites LargePiece at:(var "TileTo"))
                                    (add
                                        (piece (id "Carrier" Mover))
                                        (to (var "TileTo"))
                                        stack:True
                                    )
                                )
                                next:(remove (var "TileTo") level:0)
                            )
                        )
                    )
                )
            )
This compiles but no moves are allowed, no pieces are in the hand. I have tried playing around with it, but no enlightenment dawns.

One More Thing
In an effort to understand what is going on with the Conversion approach I tried to analyse using the new debug tools. I loaded the First Approach file and ran a game as indicated in the attached trial. Then I used the Test Ludeme Dialog to check the code (sites LargePiece at:X) for various values of X. The results I get are:

26: [3,26,27,28,29]
74: [8,74,94,114]
158: [10,158,159]
105: [7,105,106,107]
129: [9,109,129]

In all cases I don't understand why the bolded site is listed.

Conclusions

There is no promise in the documentation to think the First Approach should work. It would be reasonable to extend support for Large Pieces to make it work. However as far as I can see, the Conversion Approach should work with no additional support and I don't see why it doesn't.


RE: Problems implementing Battleship - MatthewStephenson - 02-02-2021

Hi,

Regarding the first approach, for these two points:

1. The look of the pieces is not functional.
2. The hiddenness may be broken.

Both of these have been fixed and will be in the next release, hidden information for large pieces was just not properly implemented.

Eric is going to look into the hit markers later this week and get back to you.

Cheers,
Matthew


RE: Problems implementing Battleship - slimy_asparagus - 02-02-2021

Matthew,

Thanks for the update. Out of curiosity I am surprised you went for the first approach. I thought the conversion approach looked less demanding on Ludii.


RE: Problems implementing Battleship - slimy_asparagus - 02-13-2021

(02-02-2021, 10:47 AM)MatthewStephenson Wrote: Hi,

Regarding the first approach, for these two points:

1. The look of the pieces is not functional.
2. The hiddenness may be broken.

Both of these have been fixed and will be in the next release, hidden information for large pieces was just not properly implemented.

Eric is going to look into the hit markers later this week and get back to you.

Cheers,
Matthew
Matthew,

Thanks. These issues 1. and 2. seem to be resolved now with 1.1.14. I will have another go at placing hit markers so even if I cannot fix them at least there is something more definite to investigate.


RE: Problems implementing Battleship - slimy_asparagus - 02-15-2021

Matthew,

As I said this is working much better. However I am still seeing issues that relate to the fact that during the setup phase Large Pieces work best and in the shooting phase it would be much better if I could convert the Large Pieces to single pieces. I outlined this in the "Conversion Approach" above.

For example it seems that a Large Piece is only present at one of its spaces. So it seems if I make one of the other spaces visible nothing happens. If make that one space visible then suddenly everything is visible. This is not how Battleships is supposed to work. Also when you get a hit you are supposed to know what you hit. This would work more easily with the Conversion Approach.

I attach the latest .lud file and a trial.

Also some things that look wrong to me from the test Ludeme dialog:

"(sites LargePiece at:181)" returns "[11]"
"(sites LargePiece at:161)" returns "[]"
"(sites LargePiece at:141)" returns "[]"
"(sites LargePiece at:121)" returns "[]"
"(sites LargePiece at:101)" returns "[1,101,121,141,161,181]"

I would expect all of these to return ""[101,121,141,161,181]".


RE: Problems implementing Battleship - MatthewStephenson - 02-17-2021

Hi,

I don't think there is any way to only hide or reveal only a part of a large piece.

Eric is away this week, but I will ask him to look more into this and your conversion approach when he gets back. Smile

Cheers,
Matthew