hedgewars/uLandGenMaze.pas
changeset 11051 3996500fd1e5
parent 10501 89e8d6d05dfa
child 15929 128ace913837
equal deleted inserted replaced
11049:db948d8bc9a2 11051:3996500fd1e5
   313 procedure GenMaze;
   313 procedure GenMaze;
   314 var i: Longword;
   314 var i: Longword;
   315 begin
   315 begin
   316 case cTemplateFilter of
   316 case cTemplateFilter of
   317     0: begin
   317     0: begin
   318         cellsize := small_cell_size;
   318        cellsize := small_cell_size;
   319         maze_inverted := false;
   319        maze_inverted := false;
   320         minDistance:= max(cFeatureSize*8,32);
   320        minDistance:= max(cFeatureSize*8,32);
   321 	dabDiv:= 150;
   321        dabDiv:= 150;
   322     end;
   322        end;
   323     1: begin
   323     1: begin
   324         cellsize := medium_cell_size;
   324        cellsize := medium_cell_size;
   325         minDistance:= max(cFeatureSize*6,20);
   325        minDistance:= max(cFeatureSize*6,20);
   326         maze_inverted := false;
   326        maze_inverted := false;
   327 	dabDiv:= 100;
   327        dabDiv:= 100;
   328     end;
   328        end;
   329     2: begin
   329     2: begin
   330         cellsize := large_cell_size;
   330        cellsize := large_cell_size;
   331         minDistance:= max(cFeatureSize*5,12);
   331        minDistance:= max(cFeatureSize*5,12);
   332         maze_inverted := false;
   332        maze_inverted := false;
   333 	dabDiv:= 90;
   333        dabDiv:= 90;
   334     end;
   334        end;
   335     3: begin
   335     3: begin
   336         cellsize := small_cell_size;
   336        cellsize := small_cell_size;
   337         minDistance:= max(cFeatureSize*8,32);
   337        minDistance:= max(cFeatureSize*8,32);
   338         maze_inverted := true;
   338        maze_inverted := true;
   339 	dabDiv:= 130;
   339        dabDiv:= 130;
   340     end;
   340        end;
   341     4: begin
   341     4: begin
   342         cellsize := medium_cell_size;
   342        cellsize := medium_cell_size;
   343         minDistance:= max(cFeatureSize*6,20);
   343        minDistance:= max(cFeatureSize*6,20);
   344         maze_inverted := true;
   344        maze_inverted := true;
   345 	dabDiv:= 100;
   345        dabDiv:= 100;
   346     end;
   346        end;
   347     5: begin
   347     5: begin
   348         cellsize := large_cell_size;
   348        cellsize := large_cell_size;
   349         minDistance:= max(cFeatureSize*5,12);
   349        minDistance:= max(cFeatureSize*5,12);
   350         maze_inverted := true;
   350        maze_inverted := true;
   351 	dabDiv:= 85;
   351        dabDiv:= 85;
   352     end;
   352        end;
   353 end;
   353     end;
   354 
   354 
   355 num_cells_x := LAND_WIDTH div cellsize;
   355 num_cells_x := LAND_WIDTH div cellsize;
   356 if not odd(num_cells_x) then
   356 if not odd(num_cells_x) then
   357     num_cells_x := num_cells_x - 1; //needs to be odd
   357     num_cells_x := num_cells_x - 1; //needs to be odd
   358 
   358 
   377 SetLength(came_from, num_steps, num_cells_x*num_cells_y);
   377 SetLength(came_from, num_steps, num_cells_x*num_cells_y);
   378 
   378 
   379 done := false;
   379 done := false;
   380 
   380 
   381 for current_step := 0 to num_steps - 1 do
   381 for current_step := 0 to num_steps - 1 do
   382 begin
   382     begin
   383     step_done[current_step] := false;
   383     step_done[current_step] := false;
   384     came_from_pos[current_step] := 0;
   384     came_from_pos[current_step] := 0;
   385 end;
   385     end;
   386 
   386 
   387 current_step := 0;
   387 current_step := 0;
   388 
   388 
   389 
   389 
   390 SetLength(seen_list, seen_cells_x, seen_cells_y);
   390 SetLength(seen_list, seen_cells_x, seen_cells_y);
   442 
   442 
   443 while not done do
   443 while not done do
   444     begin
   444     begin
   445     done := true;
   445     done := true;
   446     for current_step := 0 to num_steps-1 do
   446     for current_step := 0 to num_steps-1 do
   447     begin
   447         begin
   448         if not step_done[current_step] then
   448         if not step_done[current_step] then
   449         begin
   449             begin
   450             see_cell;
   450             see_cell;
   451             done := false;
   451             done := false;
   452         end;
   452             end;
   453     end;
   453         end;
   454 end;
   454     end;
   455 
   455 
   456 for x := 0 to seen_cells_x - 1 do
   456 for x := 0 to seen_cells_x - 1 do
   457     for y := 0 to seen_cells_y - 1 do
   457     for y := 0 to seen_cells_y - 1 do
   458         if seen_list[x, y] > -1 then
   458         if seen_list[x, y] > -1 then
   459             maze[(x+1)*2-1, (y+1)*2-1] := true;
   459             maze[(x+1)*2-1, (y+1)*2-1] := true;