扫雷大师 Google Code Jam Lua

我在这个问题上稳步前进,但在验证某个点是否清晰时遇到了问题...也许我的解释不好,所以我会用代码来解释:

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;
点赞