# [Community Puzzle] Oware Abapa

https://www.codingame.com/multiplayer/bot-programming/oware-abapa

Created by @_CG_Maxime,validated by @darkhorse64,@Zorg1 and @dbdr.
If you have any issues, feel free to ping them.

Hi,

can a game result in a draw? As far as i understand the referee code, there is always a winner.
My simulation often runs in a situation like:

``````0 0 0 0 1 1
0 0 0 0 0 0
``````

with a score of 24 for the first player and 22 for the second player. Second player at the move.
Because he cannot make a valid move (nothing what would seed something on player one fields) he gets 2 points for the two seed in his fields.
Result: 24 vs 24.

What do I do wrong?

Hey,

Yes, draws are possible: https://www.codingame.com/replay/404992472
In your case, I think, the last move was by player 0, and since player 1 doesnâ€™t have a move that would â€śreachâ€ť player 0, i.e. supply him with a move, the remaining seeds are collected automatically. So, player 1â€™s score is also 24.

Any algo suggestions? I tried pure MCTS with light rollouts but it seems that my top-of-my-head-buggy-virus is better, probably doing something wrong. Also, is it just me or the gameâ€™s rules are quite simple but incredibly eefâ€™ed up to implement?

Thanks, you are confirming my findings. Perhaps it is due to the fact that the system reports a win for one of the players at the end, but nothing if it is a draw.

I am also trying to get a MCTS to work, but I am stuck at ~500 rollouts in 50ms at the beginning, which is way to few I think.
Checking possible moves and the scoring (check if it would take all opponentâ€™s seeds) is very cost intensive. And while Ultimate TicTacToe is max 81 moves, here is the limit 200â€¦

Itâ€™s a pain to handle some seemingly endless loops in this game, especially in MCTS rollouts. Also the game length is big, mostly over 100 plies. Due to that so far I have better results with classical minimax.

Hi, is this a possible bug ?

At the end with the blue move, all seeds of yellow should be captured, no ?
But the game doesnâ€™t capture them, and itâ€™s now yellowâ€™s turn (and yellow crash because he was expecting the game to be finished).

Iâ€™ve not seen a referee link, so cannot look by myself.

â€śHowever, if a move would capture all of an opponentâ€™s seeds, the capture is forfeited since this would prevent the opponent from continuing the game, and the seeds are instead left on the board.â€ť

2 Likes

Dunno how I missed it, but I did. Thanks.

Rules in this game are fairly easy. Very straightforward.
There arenâ€™t any esoteric corner cases, like forfeits (Grand Slam it seems itâ€™s called).

I retract

1 Like

The source code is here: https://github.com/MaximeCheramy/cg-oware

2 Likes

Is there a typo in the statement?

Line 1: 1 integer between 0 and 11 (inclusive): the house played.

But you must play on one of your own houses which are in the range [0,5].

1 Like

Hello,

I think thereâ€™s a bug in the referee:
Line271: while ((current < 6 && player.getIndex() == 1 || current >= 6 && player.getIndex() == 0) && (board[current] == 2 || board[current] == 3))

It should be:
while (((current < 6 && player.getIndex() == 1) || (current >= 6 && player.getIndex() == 0)) && (board[current] == 2 || board[current] == 3))

Operator precedence makes those two lines equivalent.

1 Like

Another edge case rule question:

• Last turn before the turn limit
• The current player makes a move that would leave all his houses empty without a possible move for the opponent to seed into them

Would the opponent still get to score the seeds in his own houses or would they not contribute to the score because of the turn limit?

The seeds donâ€™t get counted in the score, theyâ€™d be added at the start of the next players turn. I only recently fixed this in my bot after seeing a game it thought was a win turn into a loss due to getting this wrong.

1 Like