Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
ZERDICORP committed Nov 3, 2022
1 parent 309ae81 commit 6edaaec
Show file tree
Hide file tree
Showing 10 changed files with 693 additions and 37 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
*.dll
*.exe
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@

<kbd><img src="https://github.com/ZERDICORP/maze_path_finder/blob/master/screenshots/s1.png?row=true" alt="screenshot" width="250" height="250"></kbd>

### Just 3 steps to get started:
1) **Install [C++ SFML Library](https://www.sfml-dev.org/download.php).**
2) **In the "build.bat" file, specify your path to SFML.**
3) **Run "run.bat".**

### Author's libraries used by this project:
- [athm-lib](https://github.com/ZERDICORP/athm-lib/tree/v1) (v1)
- [file-lib](https://github.com/ZERDICORP/file-lib/tree/v1) (v1)
## Launch guide

```console
$ git clone https://github.com/ZERDICORP/ants_simulation.git
$ cd ants_simulation
$ ./run
```

## Dependencies
```
$ g++ --version
g++ (GCC) 12.2.0
```
```
$ wget --version
GNU Wget 1.21.3 built on linux-gnu.
```
```
$ tar --version
tar (GNU tar) 1.34
```
15 changes: 0 additions & 15 deletions build.bat

This file was deleted.

15 changes: 15 additions & 0 deletions run
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sfmlPath="SFML-2.5.1"

if [[ ! -d $sfmlPath ]]
then
wget -qO- https://www.sfml-dev.org/files/SFML-2.5.1-linux-gcc-64-bit.tar.gz | tar xvz
fi

includePath="${sfmlPath}/include"
libPath="${sfmlPath}/lib"

g++ src/implementation/*.cpp -o build/main -O3 -O2 -O1 -DSFML_STATIC -I $includePath -I "./src/headers" -L $libPath -lsfml-graphics -lsfml-window -lsfml-system -fconcepts

cd build
LD_LIBRARY_PATH="../${libPath}" ./main
cd ..
3 changes: 0 additions & 3 deletions run.bat

This file was deleted.

74 changes: 74 additions & 0 deletions src/headers/athm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// athm.h

#ifdef _WIN32
#include <ws2tcpip.h>
#endif
#include <cstring>
#include <dirent.h>
#include <ctime>
#include <random>
#include <map>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <sys/types.h>
#include <sys/stat.h>

#define mPi 3.14159265359
#define mDoublePi mPi * 2
#define mG 6.674184 * pow(10, -11)

#ifndef ZER__ATHM_MODEL
#define ZER__ATHM_MODEL
namespace zer
{
namespace athm
{
inline void rand_init();
inline void sort(auto start, auto end, auto callback);

template<typename TKey, typename TValue>
inline std::vector<TKey> keys(std::map<TKey, TValue> const& map);
template<typename TKey, typename TValue>
inline std::vector<TValue> values(std::map<TKey, TValue> const& map);
inline std::vector<std::string> listDir(std::string sDir);
inline std::vector<std::string> listFolders(std::string sDir);
inline std::vector<std::string> listFiles(std::string sDir);
inline std::vector<std::string> split(std::string sString, std::string sSeparator);

inline char controlCharToChar(char cControlChar);

inline std::string getCurrentDateTime(std::string format);
inline std::string collapseReps(std::string s);
inline std::string expandReps(std::string s);
inline std::string replace(std::string sString, std::string sSubstring, std::string sReplacement);

template <typename T>
inline T rand_choice(std::initializer_list<T> list, int iLen);

inline int rand_int(int iTo);
inline int rand_int(int iFrom, int iTo);
inline int index(std::string sString, std::string sSubstring);

inline float rand_float() {return (float)rand_int(10000) / (float)10000;}
inline float toRadians(float fDegree) {return fDegree * (mPi / 180);}
inline float toDegrees(float fRadians) {return fRadians / (mPi / 180);}
inline float getAngleBetweenPoints(float fY1, float fX1, float fY2, float fX2) {return toRadians(180 / mPi * atan2f(fX1 - fX2, fY1 - fY2)) + toRadians(90);}
inline float getDistance2D(float fY1, float fX1, float fY2, float fX2) {return sqrt(pow(fabs(fY1 - fY2), 2) + pow(fabs(fX1 - fX2), 2));}
inline float sign(float f) {return f / fabs(f);}

inline double gravityForce(double dM1, double dM2, double dR) {return mG * ((dM1 * dM2) / pow(dR, 2));}

template <typename T>
inline bool vectorHas(std::vector<T>& vec, const T& item) {return std::find(vec.begin(), vec.end(), item) != vec.end();}
inline bool exists(std::string sPath);
inline bool isFolder(std::string sPath);
inline bool isFile(std::string sPath) {return !isFolder(sPath);}
inline bool isInt(char chr);
inline bool isNumber(std::string str);
inline bool inRange2D(int fMatrixHeight, int fMatrixWidth, float fY, float fX) {return ((fY >= 0 && fY < fMatrixHeight) && (fX >= 0 && fX < fMatrixWidth));}

#include "athm.inl"
};
};
#endif
Loading

0 comments on commit 6edaaec

Please sign in to comment.