-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a08dd5
commit ad37d35
Showing
4 changed files
with
50 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import numpy as np | ||
|
||
def create_room_pgm(filename, width, height): | ||
# Create an empty grid with 255 (white space) | ||
grid = np.full((height, width), 255, dtype=int) | ||
|
||
# Create walls (0 value) | ||
grid[0, :] = 0 # Top wall | ||
grid[-1, :] = 0 # Bottom wall | ||
grid[:, 0] = 0 # Left wall | ||
grid[:, -1] = 0 # Right wall | ||
|
||
# Create a door (255 value in the wall) | ||
door_position = width // 2 | ||
grid[0, door_position-1:door_position+2] = 255 # Door in the top wall | ||
|
||
# Write to PGM file | ||
with open(filename, 'w') as f: | ||
f.write('P2\n') | ||
f.write(f'{width} {height}\n') | ||
f.write('255\n') | ||
for row in grid: | ||
f.write(' '.join(map(str, row)) + '\n') | ||
|
||
# Generate the PGM file | ||
create_room_pgm('output/map.pgm', 20, 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,23 @@ | ||
P2 | ||
# Simple 10x10 map | ||
10 50 | ||
20 20 | ||
255 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
150 150 150 150 150 150 150 150 150 150 | ||
0 0 0 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0 0 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 | ||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters