It is in function getCoordinateFor. You are checking if some cell of the field is equal to botId, but it has a problem when both players are staying on the same cell. Because then the cell is equal to '01' so your code returns index === -1
Your version:
function getCoordinateFor(settings, field, botId) {
const index = field.findIndex(f => f === botId);
return indexToCoordinate(settings, index);
}
Should be corrected to something like:
function getCoordinateFor(settings, field, botId) {
const index = field.findIndex(f => f.includes(botId));
return indexToCoordinate(settings, index);
}
Hi,
I find two bugs in your starter bot for javascript language. They are both in the
logic.js
file.It is in
function isInBounds
. You are checking the coordinates as follows:So it means that all 0 coordinates for X & Y axes are returned as false. The corrected version should be:
It is in
function getCoordinateFor
. You are checking if some cell of the field is equal tobotId
, but it has a problem when both players are staying on the same cell. Because then the cell is equal to'01'
so your code returnsindex === -1
Your version:
Should be corrected to something like: