Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reversi hole #1123

Closed
JRaspass opened this issue Mar 9, 2024 · 17 comments
Closed

Add Reversi hole #1123

JRaspass opened this issue Mar 9, 2024 · 17 comments
Labels
hole-idea An idea for a new hole. idea

Comments

@JRaspass
Copy link
Collaborator

JRaspass commented Mar 9, 2024

No description provided.

@JRaspass JRaspass added idea hole-idea An idea for a new hole. labels Mar 9, 2024
@5cw
Copy link
Contributor

5cw commented Mar 14, 2024

currently the description reads "In Reversi, you can only place a tile if there are one or more opponent tiles between it and an opponent's tile either horizontally, vertically, or diagonally."

correct me if I'm wrong but shouldn't this read "one or more opponent tiles between it and an allied tile" or something to that effect?

@bricknellj
Copy link

bricknellj commented May 29, 2024

Not sure if it should be worth fixing or not, but I was playing around with a solution and found that I could shave a few bytes and solve pass ~1/20 if I make assumptions about the runs of enemy tiles which isn't typically true. Should this be a multi-run hole like sudoku, etc, to prevent this?

@SirBogman
Copy link
Contributor

Not sure if it should be worth fixing or not, but I was playing around with a solution and found that I could shave a few bytes and solve pass ~1/20 if I make assumptions about the runs of enemy tiles which isn't typically true. Should this be a multi-run hole like sudoku, etc, to prevent this?

We probably need a few static test cases that always show up to prevent edge cases. This is how we usually end up handling this kind of thing for poker, mahjong, etc.

@mousetail
Copy link
Contributor

Not sure if it should be worth fixing or not, but I was playing around with a solution and found that I could shave a few bytes and solve pass ~1/20 if I make assumptions about the runs of enemy tiles which isn't typically true. Should this be a multi-run hole like sudoku, etc, to prevent this?

Do you have examples of test cases that would test for this 🧀 ?

@bricknellj
Copy link

bricknellj commented May 30, 2024

@mousetail It seems anecdotally that the maximum length of enemy tiles you need to account for is typically 5 in a row, but semi often its 4, and very occasionally only 3. Having a test case that requires finding a long straight or diagonal in a few directions would work.

@bricknellj
Copy link

bricknellj commented May 30, 2024

For instance, this arg only needs runs of 2 checked
........ ........ ..O..... .OOOOOO. XXOOOX.. XXXXXO.. .XXO..O. .X..O...

@SirBogman
Copy link
Contributor

Yes, this is a good example. I think that we need some hard-coded edge cases that always run. For example, I would start with these:

OXXXXXX.
XX......
X.X.....
X..X....
X...X...
X....X..
X.....X.
........

.XXXXXX.
XX......
X.X.....
X..X....
X...X...
X....X..
X.....X.
.......O

and the answers would be

OXXXXXX!
XX......
X.X.....
X..X....
X...X...
X....X..
X.....X.
!......!

!XXXXXX!
XX......
X.X.....
X..X....
X...X...
X....X..
X.....X.
!......O

That would help to guarantee that the longest runs in all directions can be processed. And that they can be detected at the first and last position in the string. Maybe these board setups couldn't happen in a regular game, but I don't think we care.

@SirBogman
Copy link
Contributor

Actually we should do this with O in each of the four corners to make sure we can match in any direction.

@SirBogman
Copy link
Contributor

Ideally every valid combination of direction and length should be guaranteed to occur.

Lengths (number of X): 1, 2, 3, 4, 5, 6
Directions: N, NE, E, SE, S, SW, W, NW

There are 48 of these. If some of them don't occur, then some solutions could take advantage of that by not supporting them.

@mousetail
Copy link
Contributor

@SirBogman Currently the description says we guarantee that the input is reachable from the initial state. Seems a lot of your test cases are not actually reachable.

@mousetail
Copy link
Contributor

I made a pull request #1171 to add static test cases. I could not figure out a way to create the full diagonal flip from the initial starting position, but if someone can figure that out feel free to add the test case.

@nwellnhof
Copy link

nwellnhof commented Jun 1, 2024

We should add test cases where the maximum number of either horizontal, vertical or diagonal moves (16) is possible. Otherwise, you can cheat. For example, the following two inputs rotated by 0, 90, 180 and 270 degrees.

OX-OX---
OX-OX---
OX-OX---
OX-OX---
OX-OX---
OX-OX---
OX-OX---
OX-OX---

OOOOOO--
OXXXXXX-
OX------
OX-OOO--
OX-OXXX-
OX-OX---
-X--X---
--------

These cases are probably not reachable from the initial state. If this requirement is to be kept, we should at least find some test cases with 10 or more possible moves in a single direction.

@mousetail
Copy link
Contributor

@nwellnhof I don't think it's possible to reach 16 moves in a single direction from the initial state, so I'd consider this to not be "abuse" but just clever reading of the rules.

I also don't see how that assumption specifically would save bytes.

Maybe a test case that has two options in the same direction would be good though. Those are possible to reach and could be abused.

@nwellnhof
Copy link

I also don't see how that assumption specifically would save bytes.

I don't want to reveal too much about possible solutions, but the basic idea is that you repeat an operation 9 times, although it should be repeated 10 or more times to cover all cases. This allows to save one byte and I can demonstrate the issue in at least one language where a wrong solution passes most of the time.

@mousetail
Copy link
Contributor

@nwellnhof

I see what type of code might run into this problem. Still I think limiting at 9 per direction is reasonable unless you can prove it's possible to reach all 10.

@nwellnhof
Copy link

Here's a reachable test case allowing 11 horizontal moves:

O..XO.XO
.XXO.XOX
.XOOXOX.
X.XXOOOX
..XXOOXX
..XXOOX.
..XO.XOO
..XOO.OO

And 11 diagonal moves:

O.......
XXXX.X..
OXXXX...
OOXXXXX.
OOXXXXX.
OXOOXX..
OO.OOXX.
O.OOOOO.

@mousetail
Copy link
Contributor

@nwellnhof Thanks! I created a pull request to add those test cases (and their mirrors)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hole-idea An idea for a new hole. idea
Projects
None yet
Development

No branches or pull requests

6 participants