Currently, I am working on developing a 3D 4x4x4 tic tac toe game using three.js. In order to determine the win condition for combinations, I have created a boolean array. With a total of 64 blocks (16*4), I have initialized a boolean array of size 64 with default values set to false. Whenever a user clicks on a block, it dynamically changes the corresponding object to true.
For checking the horizontal win condition, I have implemented the following logic:
var camera, scene, renderer, mesh, material, controls;
var targetList = [];
var targetListBool = new Array(64).fill(false);
console.log(targetListBool);
// Other code segments omitted for brevity
However, I seem to be facing an issue with the final for loop that checks for horizontal win combinations. The goal is to alert 'win' if there are 4 consecutive horizontal blocks clicked in each plane. It appears that the if statement within the for loop is not properly detecting the changed values from the click events. Any assistance or guidance on resolving this would be greatly appreciated as I am relatively new to three.js and JavaScript. Thank you.