sokosol.c
author viric@llimona
Sun, 07 May 2006 01:33:40 +0200
changeset 13 c2b272938a1f
parent 6 bfbca2c0fc70
child 26 95fccfcbd04c
permissions -rw-r--r--
actual_map is initialized at first, so almost never a SIGSEGV can happen. Even though it should be initialized at init_so, and protecting against SIGSEGV there.

#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "general.h"

#define NBOX(n) ((n)<<2)

/* SOKOBAN Solution Finder
 *
 * Input File Format: XSB
 *
 * XSB Format definition:
 * 	Character matrix of:
 * 		@	MAN
 * 		#	WALL
 * 		$	BOX
 * 		*	BOX over PLATFORM
 * 		+	PLATFORM
 * 		-	CORNER (optional) Where a BOX should not be put
 * 	Everything that cannot be reached by the man or boxes (WALLS) must be
 * 	marked as is: WALLS.
 * 	All lines must be of the same length.
 */







int main(int argn, char **argv)
{
	struct Map Morigin;

	if (argn != 2)
	{
		printf("Usage: %s <mapfile>\n", argv[0]);
		exit(3);
	}
	ReadMap(&Morigin, argv[1]);
	assert(Morigin.NumPlatforms > Morigin.NumBoxesInPlatform);

	init_os();

	return solve_map(Morigin);
}