Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @RezaSi,validated by @Wontonimo,@darkhorse64 and @trictrac.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @RezaSi,validated by @Wontonimo,@darkhorse64 and @trictrac.
If you have any issues, feel free to ping them.
There is one very important thing missing from the statement. During a game, each player plays two matches with reversed colors in order to avoid the first player advantage and keep the game balanced. The final score is the sum of the points scored by each player during the two matches.
Therefore, a bot should be able to restart with a fresh state. For instance, if the number of available moves is 100 (resp. 99), you have a new game and you are the first (resp. second) player. I found this was the easiest way for a proper restart detection.
Edit: the statement has been updated
When a player has a row of 6 in his color, how many scores should be counted?
2 or 4?
It should be stated in the rule of game.
Yes, 4 points (every combination of 3 tiles counts)
The instructions are quite unclear indeed…
Also, let’s use this answer to clarify that the 100th move, if it’s an opponent move, is not printed (you can’t stdin it). The reasons for omitting all these details are very unclear to me.
Welp, the mirrored games were added later and everyone (including approvers :v) forgot about the statement.
Apparently, using specific strategy you can force a draw.
yup, the game’s a draw. any even-sized board can be drawn trivially by either player. Either player can mirror the other player’s moves or make any other move if they can’t. Changing the board size to 9x9 should fix this since there’s an extra spot in the middle. It gives an advantage to player 1 since they get an extra turn, but the advantage is lost in round 2 where the other player goes first, and whoever gets the most points in total across both rounds wins.
Approvers these days…
can you 100% force it when you have to start?
I tried it out and I don’t get it 100%. However when I am not allowed to play for draw, I most of the times win.
Still I only get placed in the middle of the ranking board (which makes sense, as I rarely win), so I don’t find that strategy concerning
Most likely your implementation is incorrect. We can mathematically prove that the strategy described by @Waffle3z for O forces a draw. The argument roughly goes like this:
I have encountered a crash
`The game has crashed. Please contact the author and enclose the following error:
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at com.codingame.game.Player.getAction(Player.java:16)
at com.codingame.game.Referee.gameTurn(Referee.java:174)
at com.codingame.gameengine.core.GameManager.start(GameManager.java:122)
at com.codingame.gameengine.core.RefereeMain.start(RefereeMain.java:69)
at com.codingame.gameengine.core.RefereeMain.main(RefereeMain.java:52)`
I dont see the problem since your score wont be good : you gonna be stuck in the middle of your current league
Actually a very nice idea… I wrote a Monte Carlo Tree Search for it, but that’s where the problems seem to start. Each search has such an extreme variable length that it can be anything from 0ms to >100ms. Even reading the input sometimes takes ~50ms, which extremely reduces the search time, which itself also constantly takes far too long.
I made all sorts of adjustments and set a buffer time of 20ms, but no chance. Since I don’t have this variable runtime locally myself, I simply can’t understand it.
what a shame
50ms to read the input sounds like something is terribly wrong.
Also, are you allocating memory for new nodes every time you create children? It’s better to use a pool of pre-allocated nodes and maintain indices to those instead.
Are you starting your timer after reading the first input of each turn?
I’ve got the same error.
After looking at the referee, it’s when you print only one number instead of the 2 coordinates.
@RezaSi the referee should be improved to handle this possibility more cleanly.
Unfortunately, the drawing programs don’t get stuck in the middle. Because strong players have to always start from the bottom, they have to cross the drawing programs, and give them some points. The weak programs, however, will stay at the bottom and will never get to play against them.
After entering my program a few times, @MSmits has climbed from rank 12 to rank 5. And he will climb again when I enter again.
It would be nice if they could be forced to re-enter the arena from the bottom from time to time. The current pairing algorithm will allow them to climb the ratings forever as long as they do not enter again.
I’ll resubmit, no problem. Let me know when you are done with the multi. Then I will resubmit again.
By the way: It is not exactly a drawing program. Just mostly. What I do every turn is try to solve the game. If i solve it, I play the best move and if not, I mirror the opponent.
So it’s a drawing program with somewhat of a brain
Hi. Thanks for your reply. Please don’t worry about resubmitting. It is not a big deal. And you will be protecting my first place from now on
As referenced above, sadly once you get to Wood 1, the optimal strategy is to draw until you can solve the game. While it was fun to learn to beat the Wood 3/Wood 2 levels, this means the top-level play is pretty uninteresting. At that level it’s mostly about having the most performant minimax algorithm.
I don’t think moving to an odd-sided board would resolve the problem - you’d still be able to mirror and force a draw until you found a solve that has positive value. There needs to be a way to force symmetry-breaking to make top-level play interesting from a strategic perspective (rather than just an optimization point). In chess this is solved by piece capture, and in Ultimate Tic-Tac-Toe this is resolved by your move restricting your opponent’s.
Most ideas to resolve this are probably a significant change in game design. For instance - having an asymmetric board (such as where ~10 random cells are removed from play at the start) would prevent symmetric play from even being possible.