summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-10-25 00:22:16 +0200
committerjonsykkel <jonrevold@gmail.com>2020-10-25 00:22:16 +0200
commitbb981c40fb31f4ccf9de57671230a603adf41b4b (patch)
tree2c439c1c241447f9c3ad6721aa2b9477ceb867cc
parentec2b6550fa7dea483acdfc932dab4edbaf0d2ece (diff)
downloadmindustry_solver-bb981c40fb31f4ccf9de57671230a603adf41b4b.tar.gz
fix
-rw-r--r--src/main.c51
1 files changed, 3 insertions, 48 deletions
diff --git a/src/main.c b/src/main.c
index 7b6e77a..203a04b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,8 +3,6 @@
#include <string.h>
#include <stdint.h>
-//#define FASTIK
-
#define DRILL_DIM_MIN 2
#define DRILL_DIM_MAX 3
#define DRILL_INDEX_NONE 0xFFFF
@@ -189,33 +187,6 @@ static void map_flood_clear(map_t *map){
}
}
-/*
-static int map_flood_tmp(map_t *map,size_t x,size_t y){
- cell_t *c = MAP_CELL(map,x,y);
- if(c->type == CELL_TYPE_DRILL) return 3;
- if(MAP_CELL_IS_BORDER(map,x,y)) return 1;
-
- if(c->flags & CELL_FLAG_FILL) return 2;
- c->flags |= CELL_FLAG_FILL;
- int r;
- r = map_flood_tmp(map,x-1,y ); if(r <= 1) return r;
- r = map_flood_tmp(map,x+1,y ); if(r <= 1) return r;
- r = map_flood_tmp(map,x, y-1); if(r <= 1) return r;
- r = map_flood_tmp(map,x, y+1); if(r <= 1) return r;
- return 0;
-}
-
-//0 = floding done, no connection to border
-//1 = floding done, conection to border
-//2 = cell is filled
-//3 = cell is solid (dril)
-static int map_flood(map_t *map,size_t x,size_t y){
- int r = map_flood_tmp(map,x,y);
- map_flood_clear(map);
- return r;
-}
-*/
-
//returns number of new drills determined reachable
static size_t map_flood(map_t *map,size_t x,size_t y){
cell_t *c = MAP_CELL(map,x,y);
@@ -275,7 +246,6 @@ static int map_drill_auto(map_t *map,size_t dim){
map_backup(map,x,y,dim,&backup);
map_drill_add(map,x,y,dim,ore);
reachable = map_reachable_drills(map);
- //printf("rech %zu dril total %zu\n",reachable,map->drill_cnt);
if(reachable >= map->drill_cnt) return 1;
map_restore(map,x,y,dim,&backup);
}
@@ -284,25 +254,11 @@ static int map_drill_auto(map_t *map,size_t dim){
return 0;
}
-/*
-static int map_drill_connected(map_t *map,size_t x,size_t y){
- cell_t *c = MAP_CELL(map,x,y);
-#ifndef FASTIK
- //if(!CELL_IS_DRILL_ORIGIN(c)) fail();
-#endif
- size_t dim = c-'0';
- for(size_t z = 0;z < dim;z++) if(map_flood(map,x+z ,y-1 ) == 1) return 1;
- for(size_t z = 0;z < dim;z++) if(map_flood(map,x+z ,y+dim) == 1) return 1;
- for(size_t z = 0;z < dim;z++) if(map_flood(map,x-1 ,y+z ) == 1) return 1;
- for(size_t z = 0;z < dim;z++) if(map_flood(map,x+dim,y+z ) == 1) return 1;
- return 0;
-}
-*/
-
int main(int argc,char **argv){
map_t map;
- map_alloc(&map,16,10, " o "
+ map_alloc(&map,16,11, " "
+ " o "
" oo oo oooo"
" oo oo ooooo"
" oooooo"
@@ -313,12 +269,11 @@ int main(int argc,char **argv){
" oooooooooo "
" ooooo ");
- //map_drill_add(&map,4,1,2);
-
while(map_drill_auto(&map,2));
map_print(&map);
printf("drils total %zu\n",map.drill_cnt);
printf("ore total %zu\n",map.ore_cnt);
+ fflush(stdout);
return 0;
}