Fixing queue length checking

This commit is contained in:
kyberszittya
2019-06-03 08:29:24 +02:00
parent a5aad31271
commit ce1fa0fbf5
2 changed files with 15 additions and 16 deletions

View File

@@ -126,7 +126,7 @@ def flood_fill(cpoint, pmap):
sx, sy = pmap.shape
fringe = deque()
fringe.appendleft(cpoint)
while len(fringe)>0:
while fringe:
n = fringe.pop()
nx, ny = n
# West

View File

@@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -133,7 +133,7 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -170,7 +170,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -184,7 +184,7 @@
" sx, sy = pmap.shape\n",
" fringe = deque()\n",
" fringe.appendleft(cpoint)\n",
" while len(fringe)>0:\n",
" while fringe:\n",
" n = fringe.pop()\n",
" nx, ny = n\n",
" # West\n",
@@ -218,7 +218,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -243,23 +243,22 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": []
"source": [
"Let's use this flood fill on real data:"
]
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The grid map is 150 x 100 .\n",
"150 100\n"
"The grid map is 150 x 100 .\n"
]
},
{