Code viewer for Mind: New Mind (clone by Bad Guy)

// Cloned by Bad Guy on 5 Dec 2020 from Mind "New Mind" by Bad Guy 
// Please leave this clone trail here.
 
const state = {walls: [], visited: [], ctx: null}

AB.mind.newRun = function() {
    const N = 20
    const S = 10 //scale
    state.walls = Array(N).fill(Array(N).fill(0))
    state.visited = Array(N).fill(Array(N).fill(0))
        
    const $ = id => document.getElementById(id)
    const map = document.createElement('canvas')
    map.height = map.width = N * S
    map.style.background = 'yellow'
    map.style.height = map.style.width = N * S + 'px'
    const ctx = map.getContext('2d')
    ctx.fillStyle = 'grey'
    ctx.fillRect(1 * S, 1 * S, N * S - 2 * S, N * S - 2 * S)
    $('ab-runheaderbox').appendChild(map)
    
    for (let i = 0; i < N; i++)
        state.walls[i][0] = state.walls[0][i] = state.walls[i][N - 1] = state.walls[N - 1][i] = 1

    state.ctx = ctx
    state.N = N
    state.S = S
    // e.children[4].children[0].innerHTML += "<br>",
    // window.map = a,
    // window.mp = d
}

AB.mind.endRun = function()                 
{
};


AB.mind.getAction = function(pos) { 
    const [meX, meY, enemyX, enemyY] = pos
    const {visited, ctx, N, S } = state
    visited[meY][meX]++
    ctx.fillStyle = 'blue'
    ctx.fillRect(S * meX, S * meY, S, S)
    state.fillStyle = 'red'
    ctx.fillRect(S * enemyX, S * enemyY, S, S)
    const action = [1,2,3,4][Math.floor(Math.random() * 4)]
    console.log('>>>>', action)
    return action
        // n(u) != n(x) && (l.fillStyle = "lightblue",
        // l.fillRect(10 * x.x, 10 * x.y, 10, 10),
        // a[x.x + "_" + x.y] = "Free",
        // a[u.x + "_" + u.y] = "Enemy"),
        // n(f) != n(c) && (l.fillStyle = "lightblue",
        // l.fillRect(10 * c.x, 10 * c.y, 10, 10),
        // a[c.x + "_" + c.y] = "Free",
        // a[f.x + "_" + f.y] = "Me"),
        // n(f) == n(c)) {
        //     let t = function(e) {
        //         let l = {};
        //         return m(e, function(e, t) {
        //             l.x = e,
        //             l.y = t
        //         }),
        //         l
        //     }(e);
        //     l.fillStyle = "yellow",
        //     l.fillRect(10 * t.x, 10 * t.y, 10, 10),
        //     a[t.x + "_" + t.y] = "Wall"
        // }
        // return e = function() {
        //     let e = a[_(i)]
        //       , l = a[_(y)]
        //       , n = a[_(o)]
        //       , f = a[_(r)]
        //       , c = !1
        //       , u = !1
        //       , x = !1
        //       , d = !1;
        //     return e ? l ? n ? f ? ("Wall" != e && "Enemy" != e && (c = !0),
        //     "Wall" != l && "Enemy" != l && (u = !0),
        //     "Wall" != n && "Enemy" != n && (x = !0),
        //     "Wall" != f && "Enemy" != f && (d = !0),
        //     !c || u || x || d ? c || !u || x || d ? c || u || !x || d ? c || u || x || !d ? c && u && !x && !d ? h[_(i)] <= h[_(y)] ? i : y : c && !u && x && !d ? h[_(i)] <= h[_(o)] ? i : o : c && !u && !x && d ? h[_(i)] <= h[_(r)] ? i : r : !c && u && x && !d ? h[_(y)] <= h[_(o)] ? y : o : !c && u && !x && d ? h[_(y)] <= h[_(r)] ? y : r : !c && !u && x && d ? h[_(o)] <= h[_(r)] ? o : r : c && !u && x && d ? h[_(i)] <= h[_(o)] ? h[_(i)] <= h[_(r)] ? i : r : h[_(o)] <= h[_(r)] ? o : r : c && u && !x && d ? h[_(i)] <= h[_(y)] ? h[_(i)] <= h[_(r)] ? i : r : h[_(y)] <= h[_(r)] ? y : r : c && u && x && !d ? h[_(i)] <= h[_(y)] ? h[_(i)] <= h[_(o)] ? i : o : h[_(y)] <= h[_(o)] ? y : o : !c && u && x && d ? h[_(y)] <= h[_(o)] ? h[_(y)] <= h[_(r)] ? y : r : h[_(o)] <= h[_(r)] ? o : r : c && u && x && d && h[_(i)] <= h[_(o)] && h[_(i)] <= h[_(r)] && h[_(i)] <= h[_(y)] ? i : c && u && x && d && h[_(y)] <= h[_(o)] && h[_(y)] <= h[_(r)] && h[_(y)] <= h[_(i)] ? y : c && u && x && d && h[_(o)] <= h[_(i)] && h[_(o)] <= h[_(r)] && h[_(o)] <= h[_(y)] ? o : c && u && x && d && h[_(r)] <= h[_(i)] && h[_(r)] <= h[_(o)] && h[_(r)] <= h[_(y)] ? r : (console.log("How can it possibly end up here hahahaha"),
        //     t(4)) : r : o : y : i) : r : o : y : i
        // }(),
        // x = u,
        // c = f,
        // e

};