Minesweeper Master Google Code Jam Lua

时间:2016-03-28 13:07:33

标签: lua

我在这个问题上已经稳步前进了,但是我在验证一个地点是否清晰时遇到了问题...也许我的解释不好所以我只是把它留在代码中:< / p>

func.CheckNear = function(field, pos)
    local x, y = pos[1], pos[2];
    local coordinates = {{x + 1, y}, {x - 1, y}, {x, y + 1}, {x, y - 1}}
    for key, array in next, coordinates do
        local field = field[array[2]];
        if field then
            if (field[coordinates[1]]) then
                if field[coordinates[1]] == "*" then
                    coordinates[key] = nil;
                end;
            else
                coordinates[key] = nil;
            end;
        else
            coordinates[key] = nil
        end;
    end;
    return coordinates;
end;

0 个答案:

没有答案
相关问题