mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 16:43:29 +00:00
john is running even better
This commit is contained in:
@@ -98,7 +98,7 @@ end
|
||||
|
||||
function not_in(set, node)
|
||||
for _,value in pairs(set) do
|
||||
if value == node then
|
||||
if value.x == node.x and value.y == node.y then
|
||||
return false
|
||||
end
|
||||
end
|
||||
@@ -119,6 +119,19 @@ function getNeighbors(node)
|
||||
end
|
||||
end
|
||||
end
|
||||
if #neighbors == 0 then
|
||||
for _, dir in ipairs(Dirs) do
|
||||
local neighborX = node.x + dir.x
|
||||
local neighborY = node.y + dir.y
|
||||
if neighborY <= MaxY and neighborX <= MaxX then
|
||||
if neighborY >= 0 and neighborX >= 0 then
|
||||
if Map[neighborX][neighborY] == 0 then
|
||||
table.insert(neighbors, {x = neighborX, y = neighborY})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return neighbors
|
||||
end
|
||||
|
||||
@@ -157,7 +170,10 @@ function pathfind(root, target)
|
||||
f_score[root] = dist(root, target)
|
||||
|
||||
while #open > 0 do
|
||||
log(#open)
|
||||
local curr = getLowestFromSet(open, f_score) --get lowest node of openset
|
||||
log(curr.x)
|
||||
log(curr.y)
|
||||
log("f")
|
||||
if curr.x == target.x and curr.y == target.y then
|
||||
local path = fill_path({}, came_from, target) -- fill the path with came from
|
||||
@@ -167,6 +183,12 @@ function pathfind(root, target)
|
||||
end
|
||||
setRemove(open, curr) -- remove curr from open
|
||||
setAdd(closed, curr)-- add node to closed
|
||||
log("closed set")
|
||||
for i, c in ipairs(closed) do
|
||||
log("member")
|
||||
log(c.x)
|
||||
log(c.y)
|
||||
end
|
||||
log("g")
|
||||
local neighbors = getNeighbors(curr) -- get neighbors of current
|
||||
log("h")
|
||||
@@ -187,6 +209,7 @@ function pathfind(root, target)
|
||||
end
|
||||
end
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
function dist(nodeA, nodeB)
|
||||
@@ -272,6 +295,9 @@ function Update(mapinfo)
|
||||
log(p.x)
|
||||
log(p.y)
|
||||
end
|
||||
if #pathToSafeSpace == 0 then
|
||||
return 0, 0, false, false
|
||||
end
|
||||
local f = pathToSafeSpace[1]
|
||||
log("first way of the path")
|
||||
log(f.x)
|
||||
|
||||
@@ -80,6 +80,21 @@ namespace BBM
|
||||
state.setTable();
|
||||
state.setTable();
|
||||
}
|
||||
for (auto &bomb : _bombs) {
|
||||
Vector3f bombPos = std::get<0>(bomb);
|
||||
state.push(index++);
|
||||
state.newTable();
|
||||
state.push("x");
|
||||
state.push(bombPos.x);
|
||||
state.setTable();
|
||||
state.push("y");
|
||||
state.push(bombPos.z);
|
||||
state.setTable();
|
||||
state.push("type");
|
||||
state.push(10);
|
||||
state.setTable();
|
||||
state.setTable();
|
||||
}
|
||||
state.setTable();
|
||||
}
|
||||
|
||||
@@ -111,7 +126,6 @@ namespace BBM
|
||||
int dangerLevel = std::chrono::duration_cast<std::chrono::seconds>(timeleft).count();
|
||||
if (dangerLevel == 0)
|
||||
dangerLevel = 1;
|
||||
std::cout << "bombpos: " << bombPos.x << ", " << bombPos.z << std::endl;
|
||||
pushInfoDangerPos(state, index, bombPos.x, bombPos.z, dangerLevel);
|
||||
pushInfoDangerPos(state, index, bombPos.x, bombPos.z, dangerLevel);
|
||||
for (int i = 1; i < bombRadius; i++) {
|
||||
|
||||
Reference in New Issue
Block a user