https://www.codingame.com/training/hard/a-game-of-go
Send your feedback or ask for help here!
Created by @Tux4711,validated by @IAmNoob,@tyrcho and @Redstrike.
If you have any issues, feel free to ping them.
https://www.codingame.com/training/hard/a-game-of-go
Send your feedback or ask for help here!
Created by @Tux4711,validated by @IAmNoob,@tyrcho and @Redstrike.
If you have any issues, feel free to ping them.
Hi, nice puzzle but I think there might be a problem on the KO rule test of the validator. I didn’t implemented this rule but upon submission, I’ve got 100% but on the test 6 on IDE, I fail wich is normal since I do not yet check for KO rule.
Maybe some move that are illegal next so the result is the same …
Hi,
I cannot understand the test 05, non-suicidal move.
For me, the move 6 (w 0 1) is suicidal
for me the move 6 is surrounded left-right-bottom by white. Am I wrong ?
This is the board state before playing the 6th move, putting W on (0, 1) is valid :
W.WB.
.WB..
WB..W
...WB
...B.
Edit: to expand a little, there’s a concept called liberty in go. If a group of stones has at least one stone with a free cell as a neighbor, then the group lives. Otherwise it dies.
In this case the cell (1, 0) is free and allows the group to live, so the move is valid.
Ok, I got this, it is not suicidal because putting the stone will let it be part of a group, and the group has at lease one liberty.
and then move 7 (B 1 0) is not suicidal because the it encircles the white group at top-left, which is beaten.
So after move 7 I have
…B.
B.B…
WB…W
…WB
…B.
Thanks !
Fun puzzle, enjoyed it a lot. A minor improvement in the problem statement would be to clarify that “surrounded” means on the 4 orthogonal sides (left, right, up, down) only, not diagonally. As it stands, you have to infer from the examples or read externally-hosted game rules. Thanks for creating it!
Hey guys,
dont have the technical knowledge in javascript to find an easy way to organise the data(matrix of dots, Ws and Bs)
any1 can give me some pointers? I tryed nested arrays, but I’m struggling to print them now.
The straightforward way is to create an array of arrays, which you can initialize like this :
const board = [...Array(S)].map(_ => readline().split(''));
Where S
is the height of the board.
To print it, simply write something like this :
board.forEach(row => console.log(row.join(''));
Hi, I pass all the test and everything seems fine. But when I submit I don’t succeed the suicidal move…
Any subtlety comes to your mind?
I coded this move so that if all neighboors are from the oposite pion type, it is a suicidal move… It seems to don’t work…
Help XD (please)
hello,
It’s hard to say without knowing the logic of your implementation.
I would advise you to try “PLAY TESTCASE” for the “Suicidal move” test with displaying each move to the log.
Then I would try to “rotate” and/or mirror this test case in different ways and try your implementation on such changed test cases… Maybe you either find when it fails or some idea comes to your mind in the process…
For example you could try the following in different combinations:
The logic of implementation is the next one:
for the given move to make (exemple B at (0,0)), If a neighboor is of the same type as the move (B in the example) I keep looking for new neighboor of the same type. If at some points one of the pions is in touch with an empty field “.”, it means the group is free which means this can’t be a suicidal move…
There’s also the case where the move is technically suicidal, but placing the stone allows you to kill an enemy group (which happens first), freeing neighbors for your group.
Jst as a rzmark, I have beaten the challenge by removing the rules enforcing “you cannot place a pawn on an occupied cell”.
It was blocking my way on the “Non Suicidal” final case (not the training).
I dunno if there is a bug or something illogic between the test cases and the challenge cases…
Sounds reasonable, but implementation may contain bugs, so I would recommend to test for different cases as I described. For example, if you can’t pass “Suicidal move” then it is likely that the (hidden) “Suicidal move” test case is the same as your visible “Suicidal move” test case except for some transformation. Examples of transformations I described in my previous reply.
I wish you good luck!
Hi,
All my tests are good except the last one “Bigger field”.
After the move #3, I obtain this map :
....WWB..
...WWB.B.
.W.WBBB..
W.WBWWWB.
BWWBBWBB.
BBBBW.WB.
...BBWWW.
WBW.BBW..
.WB...W..
The next move is B 5 5.
I detected this move as suicidal one, seem effectively the case for me.
Have you the same map than me after move #3: W 6 6.
admin edit: formatting
This is my state of the board for this situation, I didn’t check if yours was exactly the same as it’s hard to read without formatting. B 5 5 is not suicidal because both the white group above it and the white stone left of it get killed.
....WWB..
...WWB.B.
.W.WBBB..
W.WBWWWB.
BWWBBWBB.
BBBBW.WB.
...BBWWW.
WBW.BBW..
.WB...W..
Thanks, all my tests pass OK now, but not in the final validator, I failed on “Bigger field” …
Hi,
Maybe That won’t help, but after a good look around I found something that unlocked me.
My managment of the flood fill algorithm was not good enough to remark if a group of pions were FREE or not for every scenario. So every tests worked well except the last one.
By printing like a mad lad I understood that one of the scenario was not covered properly by checking the neighboorhood value, and what the function returned (and all just for the first move).
What I suggest for anyone stuck like @Arnaud80 or me is to just analyse the first move of the last test case to see what’s wrong.
If all other test works find in a clean manner, solving the first move of the last test case might be sufficient