Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Bio2hazard committed May 27, 2013
0 parents commit f46f19c
Show file tree
Hide file tree
Showing 17 changed files with 1,390 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
163 changes: 163 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#################
## Eclipse
#################

*.pydevproject
.project
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath


#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.vspscc
.builds
*.dotCover

## TODO: If you have NuGet Package Restore enabled, uncomment this
#packages/

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf

# Visual Studio profiler
*.psess
*.vsp

# ReSharper is a .NET coding add-in
_ReSharper*

# Installshield output folder
[Ee]xpress

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish

# Others
[Bb]in
[Oo]bj
sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML



############
## Windows
############

# Windows image file caches
Thumbs.db

# Folder config file
Desktop.ini


#############
## Python
#############

*.py[co]

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox

#Translations
*.mo

#Mr Developer
.mr.developer.cfg

# Mac crap
.DS_Store
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#C Jump Point Search Implementation
==================

This is a C implementation of the Jump Point Search pathfinding algorithm. The code is based on qiao's excellent JavaScript JPS implementation, which can be found at https://github.com/qiao/PathFinding.js

I'm by no means a expert at C, but I needed a C implementation of the JPS algorithm, none existed at the time and so I decided to take matters in my own hands.

When executed, this program reads in a file called map_in.txt where a - represents a walkable tile, # represents the start, * represents the end and X represents a unwalkable tile. It will then calculate the path, smoothen it and output each coordinate. It will then print a visual representation of the path in the console window.

It really is meant to be implemented and used in other prjects and as such mostly serves to debug and benchmark the algorithm.

For more information on the JPS algorithm check out http://harablog.wordpress.com/2011/09/07/jump-point-search/

Author: Felix Kastner ([email protected])

Creation date: 2012

License: MIT
70 changes: 70 additions & 0 deletions display.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include <iostream>

#include "neighbors.h"
#include "jps_grid.h"
#include "heap.h"

void displaySolution(struct grid *gd,struct neighbor_xy_list * path) {
int i,j;
bool found = false;
struct neighbor_xy_list *path_pos = path;
for(i = 0; i < gd->height; i++) {
for(j = 0; j < gd->width; ++j) {
if(gd->nodes[i][j].walkable) {
while(path != (path_pos = path_pos->left)) {
if(path_pos->y == i && path_pos->x == j) {
printf("o");
found = true;
}
}
if(!found)
printf(".");
}
else
printf("#");

found = false;
}
printf("\n");
}
}

void displayGrid(struct grid *gd) {
int i,j;
for(i = 0; i < gd->height; i++) {
for(j = 0; j < gd->width; ++j) {
if(gd->nodes[i][j].walkable)
printf(".");
else
printf("#");
}
printf("\n");
}
}

void displayNodeInfo(struct node *n)
{
printf("x: %i ", n->x);
printf("\ny: %i ", n->y);
printf("\nf: %i ", n->f);
if(n->walkable)
printf("\nwalkable: yes\n\n");
else
printf("\nwalkable: no\n\n");
}

void listNeighbors(struct neighbor_list* list) {
struct neighbor_list *head = list;
struct neighbor_list *current = list;
while (head != (current = current->right)){
displayNodeInfo(current->neighbor_node);
}
}

void listOpenList(struct open_list* list) {
struct open_list *head = list;
struct open_list *current = list;
while (head != (current = current->right)){
displayNodeInfo(current->list_node);
}
}
14 changes: 14 additions & 0 deletions display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Draws the grid / map
void displayGrid(struct grid *gd);

// Displays rudimentary information about a given node
void displayNodeInfo(struct node *n);

// Draws the grid / map with the computed path
void displaySolution(struct grid *gd, struct neighbor_xy_list * path);

// Lists information about all walkable nodes adjecent to a node
void listNeighbors(struct neighbor_list* list);

// Lists all entry in the open list ( contains eligible nodes for inspection )
void listOpenList(struct open_list* list);
Loading

0 comments on commit f46f19c

Please sign in to comment.