//my personal variables
let w = 10;
let h = 10;
let lgrid = new Array(w);
let rgrid = new Array(w);
let waux = 10;
let haux = 10;
let x = "✔";
let o = "⬤";
let randomize = true;
let lauxgrid = new Array(w);
let rauxgrid = new Array(w);
//Write arrays to html
function writegrid() {
for (let i = 0; i < w; i++) {
for (let j = 0; j < h; j++) {
$('#lc' + i + '-' + j).html(lgrid[i][j]);
$('#rc' + i + '-' + j).html(rgrid[i][j]);
}
}
}
function writeauxgrid(){
for (let i = 0; i < waux; i++) {
for (let j = 0; j < haux; j++) {
$('#lac' + i + '-' + j).html(lauxgrid[i][j]);
$('#rac' + i + '-' + j).html(rauxgrid[i][j]);
}
}
}
function inittable(){
for (let i = 0; i < w; i++) {
//create rows
$('#local').append('
');
$('#remote').append('
');
for (let j = 0; j < h; j++) {
//create cells
$('#lt' + i).append(' | ');
$('#rt' + i).append(' | ');
//add divs to cells
$('#lcx' + i + '-' + j).append('');
$('#rcx' + i + '-' + j).append('');
//add arrays to grids
lgrid[i] = new Array(h);
rgrid[i] = new Array(h);
}
}
}
function initauxtable(){
for (let i = 0; i < waux; i++) {
//create rows
$('#localaux').append('
');
$('#remoteaux').append('
');
for (let j = 0; j < haux; j++) {
//create cells
$('#lax' + i).append(' | ');
$('#rax' + i).append(' | ');
//add divs to cells
$('#lacx' + i + '-' + j).append('');
$('#racx' + i + '-' + j).append('');
//add arrays to grids
lauxgrid[i] = new Array(haux);
rauxgrid[i] = new Array(haux);
}
}
}
function randomizetable(){
for (let i = 0; i < w; i++) {
for (let j = 0; j < h; j++) {
let r = Math.floor(Math.random() * 2);
if (r == 0) {
lgrid[i][j] = x;
rgrid[i][j] = o;
} else {
lgrid[i][j] = o;
rgrid[i][j] = x;
}
}
}
}
function randomizeaux(){
for (let i = 0; i < waux; i++) {
for (let j = 0; j < haux; j++) {
let r = Math.floor(Math.random() * 2);
if (r == 0) {
lauxgrid[i][j] = x;
rauxgrid[i][j] = o;
} else {
lauxgrid[i][j] = o;
rauxgrid[i][j] = x;
}
}
}
}
function main() {
inittable();
initauxtable();
if (randomize) {
randomizetable();
writegrid();
randomizeaux();
writeauxgrid();
}
}
$(function () {
main();
});