<commit_before># javascript-astar

## An implementation of the A* Search Algorithm in JavaScript

See a demo at http://www.briangrinstead.com/files/astar/

## Sample Usage

If you want just the A* search code (not the demo visualization), use code like this http://gist.github.com/581352

	<script type='text/javascript' src='astar.js'></script>
	<script type='text/javascript'>
		var graph = new Graph([
			[1,1,1,1],
			[0,1,1,0],
			[0,0,1,1]
		]);
		var start = graph.grid[0][0];
		var end = graph.grid[1][2];
		var result = astar.search(graph, start, end);
		// result is an array containing the shortest path

		var graphDiagonal = new Graph([
			[1,1,1,1],
			[0,1,1,0],
			[0,0,1,1]
		], { diagonal: true });
		var start = graphDiagonal.grid[0][0];
		var end = graphDiagonal.grid[1][2];
		var resultWithDiagonals = astar.search(graphDiagonal, start, end);

		// Weight can easily be added by increasing the values within the graph, and where 0 is infinite (a wall)
		var graphWithWeight = new Graph([
			[1,1,2,30],
			[0,4,1.3,0],
			[0,0,5,1]
		]);
		var startWithWeight = graphWithWeight.grid[0][0];
		var endWithWeight = graphWithWeight.grid[1][2];
		var resultWithWeight = astar.search(graphWithWeight, startWithWeight, endWithWeight);
<commit_msg>add note about diagonal heuristic - issue #32<commit_after># javascript-astar

## An implementation of the A* Search Algorithm in JavaScript

See a demo at http://www.briangrinstead.com/files/astar/

## Sample Usage

If you want just the A* search code (not the demo visualization), use code like this http://gist.github.com/581352

	<script type='text/javascript' src='astar.js'></script>
	<script type='text/javascript'>
		var graph = new Graph([
			[1,1,1,1],
			[0,1,1,0],
			[0,0,1,1]
		]);
		var start = graph.grid[0][0];
		var end = graph.grid[1][2];
		var result = astar.search(graph, start, end);
		// result is an array containing the shortest path

		var graphDiagonal = new Graph([
			[1,1,1,1],
			[0,1,1,0],
			[0,0,1,1]
		], { diagonal: true });
		var start = graphDiagonal.grid[0][0];
		var end = graphDiagonal.grid[1][2];
		var resultWithDiagonals = astar.search(graphDiagonal, start, end, { heuristic: astar.heuristics.diagonal });

		// Weight can easily be added by increasing the values within the graph, and where 0 is infinite (a wall)
		var graphWithWeight = new Graph([
			[1,1,2,30],
			[0,4,1.3,0],
			[0,0,5,1]
		]);
		var startWithWeight = graphWithWeight.grid[0][0];
		var endWithWeight = graphWithWeight.grid[1][2];
		var resultWithWeight = astar.search(graphWithWeight, startWithWeight, endWithWeight);

{'fraction_non_alphanumeric': 0.150231124807396, 'fraction_numerical': 0.04468412942989214, 'mean_word_length': 4.142574257425743, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6010487', 'n_tokens_mistral': 1025, 'n_tokens_neox': 918, 'n_words': 254}