Skip to content

Commit 91df9f4

Browse files
committed
Merge branch 'master' into Greenzie-btdubs/closed-set
2 parents 05aeae6 + 26b33ed commit 91df9f4

File tree

4 files changed

+44
-31
lines changed

4 files changed

+44
-31
lines changed

.github/workflows/c-cpp.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: C/C++ CI
2+
3+
on:
4+
push:
5+
branches: [ "master", "stage" ]
6+
pull_request:
7+
branches: [ "master", "stage" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: make test
17+
working-directory: ./cpp
18+
run: make test

README.md

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## astar-algorithm
22

3-
[![Build Status](https://travis-ci.org/justinhj/astar-algorithm-cpp.svg?branch=master)](https://travis-ci.org/justinhj/astar-algorithm-cpp) [![Join the chat at https://gitter.im/astar-algorithm-cpp/community](https://badges.gitter.im/astar-algorithm-cpp/community.svg)](https://gitter.im/astar-algorithm-cpp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3+
![Build Status](https://github.com/justinhj/astar-algorithm-cpp/workflows/C/C++%20CI/badge.svg)
44

55
### Summary
66

@@ -11,31 +11,32 @@ https://www.heyes-jones.com/astar.php
1111

1212
The A* algorithm was described in the paper https://ieeexplore.ieee.org/document/4082128 by Hart, Nillson and Raphael.
1313

14-
Sadly Nils Nillson passed away in 2019, his work is much appreciated.
14+
This repository is dedicated to the memory of Nils Nillson who passed away in 2019.
1515

16-
Contributions:
16+
### Release notes
1717

18-
* @justinhj Original code and tutorial
19-
* @ScaryG C# port
20-
* @Rasoul for submitting the path to Bucharest. Sample from Artificial Intelligence: A Modern Approach
21-
* @sergiosota For fixing a number of issues related to memory management
18+
[v1.1](https://github.com/justinhj/astar-algorithm-cpp/releases/tag/v1.1)
19+
Code cleanup and final version that does not require C++11
20+
21+
[v1.0](https://github.com/justinhj/astar-algorithm-cpp/releases/tag/v1.0)
22+
Initial release once API stable.
2223

2324
### License
2425

2526
This software is released under the MIT License, see license.txt
2627

2728
### Commercial Use
2829

29-
This software has been used in AAA video games and is well tested in the wild. Please let me know if you use this code in your games, studies or hobby projects.
30+
This software has been used in a number of AAA video games, which is an area of software that relies on efficiency and reliability. In addition it has been used in a number of academic and personal projects that require efficient search. Please
3031

31-
If you feel the need to pay money for this code, it is not required by the license, but you could contribute to Unicef, a charity which helps children worldwide, http://www.unicef.org/ that would be awesome.
32+
Commercial users of the code are encouraged to make a donation to http://www.unicef.org/ if they find this project useful.
3233

3334
### Projects using this code
3435

3536
If you wish to be added to the list of known products/educational projects using the code please contact me.
3637

3738
* Gun, Activision
38-
* Company of Heroes and Company of Heroes Online, Relic Entertainment
39+
* Company of Heroes (various versions), Relic Entertainment
3940
* Angel Engine, a game prototyping engine http://code.google.com/p/angel-engine/
4041
* War of Sonria, a strategy war game on PSP and Playstation 3 by Playground Squad
4142
* Lighthouses AI contest https://github.com/marcan/lighthouses_aicontest
@@ -74,24 +75,16 @@ For path finder
7475
pathfind has no arguments. You can edit the simple map in pathfind.cpp and the start
7576
and goal co-ordinates to experiement with the pathfinder.
7677

77-
Fixed size allocator notes: As mentioned briefly in the tutorial you can enable and disable the
78-
faster memory allocation. This allocates a fixed size block of memory, so you have to specify this size
79-
with the astar constructor. You need to enlarge it if you hit an out of memory assert during the
80-
search.
81-
82-
Compilation notes:
83-
84-
Microsoft Visual C++ : Confirmed working with version 8.0.50727 with some deprecation warnings
85-
I'm going to leave the deprecation warnings in so that it still works cleanly with GCC.
86-
TODO Make a non-deprecated compliant version using compiler checking
87-
88-
Compiled with:
78+
#### Fixed size allocator
8979

90-
Apple clang version 12.0.0 (clang-1200.0.32.28)
91-
Target: x86_64-apple-darwin19.6.0
80+
FSA is just a simple memory pool that uses a doubly linked list of available nodes in an array. This is
81+
a very efficient way to manage memory. It has no automatic resizing, so you must account for the fact it
82+
will use a fixed block of memory per instance and will report an error when memory is exhausted.
9283

93-
Please let me know if it does not compile on a particular platform by opening an issue.
84+
As mentioned briefly in the tutorial you can enable and disable the faster memory allocation. This allocates
85+
a fixed size block of memory, so you have to specify this size with the astar constructor. You need to enlarge
86+
it if you hit an out of memory assert during the search.
9487

95-
Cheers!
88+
Compatibility notes:
9689

97-
Justin
90+
This version of the code requires any standards compliant C++98/03

cpp/8puzzle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ size_t PuzzleState::Hash()
350350

351351
void PuzzleState::PrintNodeInfo()
352352
{
353-
char str[100];
354-
sprintf( str, "%c %c %c\n%c %c %c\n%c %c %c\n",
353+
const int strSize = 100;
354+
char str[strSize];
355+
snprintf( str, strSize, "%c %c %c\n%c %c %c\n%c %c %c\n",
355356
tiles[0] + '0',
356357
tiles[1] + '0',
357358
tiles[2] + '0',

cpp/tests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ bool MapSearchNode::IsSameState( MapSearchNode &rhs )
9898

9999
void MapSearchNode::PrintNodeInfo()
100100
{
101-
char str[100];
102-
sprintf( str, "Node position : (%d,%d)\n", x,y );
101+
const int strSize = 100;
102+
char str[strSize];
103+
snprintf( str, strSize, "Node position : (%d,%d)\n", x,y );
103104

104105
cout << str;
105106
}

0 commit comments

Comments
 (0)