When n==0, it
reads a map from "map000.TXT", and draw it on your screen using the
ncurses library.
The digits "000" may be replaced by other sequence number between 1 and 150.
When n==1, read the map file "map001.txt", and so on.
To obtain all map files from map001.txt to map150.txt, run
"/home/solomon/CPP/Sokoban/get_maps.sh". Then "ls map*.txt" will show
that you have those map files in our current working directory.
The format of the map is a plain-text file.
A character 'H' indicates a solid wall.
A character '0' or ' ' indicates an empty location.
A character 'B' indicates a box.
A character 'D' indicates the destination where you should move a box to.
A character 'C' indicates this location is a destination of
some box, but it is also occupied by a box at the beginning.
AT first you may think this case is redundant, because
a box is already at its destination. However, there are
some levels (e.g. Level 97) which require you to move the
box to another destination if you want to solve the puzzle.
A character 'W' indicates the initial position of the worker.
The following is a sample input, and the map you are expected
to display-->.
HHHHHH
H BD H
HWC HH
H BD H
HHHHHH
You may want to define the following global
variables
to control the profile when you draw the map. For example, you may easily
change your program to display the destination as a space with background color
green:
wall_character='H'; wall_color=COLOR_CYAN
box_character='B'; box_color=COLOR_RED
dest_character=' '; dest_color=BACKGROUND_GREEN
worker_character='W'; worker_color=COLOR_MAGENTA
Bonus: Can you detect if the format of a map file is invalid?
Please describe what you can detect in the comments at the beginning of
your program.
The number of 'B' must be the same as 'D'.
There should be exactly one 'W'.
The only valid characters in the map matrix are 'H', '0', ' ',
'B', 'C', 'D', 'W'.