johnbuffer / antsimulator Goto Github PK
View Code? Open in Web Editor NEWSimple Ants simulator
License: MIT License
Simple Ants simulator
License: MIT License
Hey! very cool simulation, have you considered building this as a shader for execution on a gpu? It would likely allow you to have millions of ants in a single simulation this way and could allow for more complex behaviors without slowing down the simulation!
I'm in a Ubuntu Windows Subsystem for Linux environment, I've installed the latest SFML and CMake libraries, and I ran ./install.sh...
When I went into the build folder to run AntSimulator I got the following error output
Configuration file couldn't be found.
Failed to open X11 display; make sure the DISPLAY environment variable is set correctly
Aborted
I'm familiar with C++ projects in a windows environment with visual studio, but I feel I may be a bit out of my depth on getting this project running.
Setting the max. ants per colony to under 1000, the default minimum number of ants, in the conf.txt file, as soon as you try to place a colony, the program crashes. Allowing us to change the minimum number of ants as well as the maximum would both fix this issue as well as allow for more flexibility with scenarios.
The README is too simple for newcomer.
I was interested in knowing the number of soldiers in the ant population. So I played with the following changes:
Added the following to the bottom of colony.hpp:
uint32_t soldiersCount()
{
return std::count_if(ants.begin(), ants.end(), [](Ant& a) { return a.type == Ant::Type::Soldier; });
}
Changes to colony_renderer.hpp:
Added a soldiersCount variable:
uint32_t ants_count = 0;
uint32_t soldiers_count = 0;
Changed updateData( ) to retrieve the soldiersCount:
ants_count = to<int32_t>(colony.ants.size());
soldiers_count = to<int32_t>(colony.soldiersCount());
And then changed the render( ) to show the soldiersCount and right-justify the pop_diff:
text.setCharacterSize(20);
text.setFillColor(sf::Color::White);
text.setPosition(position.x + padding, position.y);
text.setString("Population " + toStr(soldiers_count) + "/" + toStr(ants_count));
target.draw(text);
text.setCharacterSize(14);
text.setFillColor(pop_diff >= 0 ? sf::Color::Green : sf::Color::Red);
const std::string sign = (pop_diff >= 0 ? "+" : "");
text.setString("(" + sign + toStr(pop_diff) + " Ants over last 60s)");
// right justify
sf::FloatRect bounds = text.getLocalBounds();
text.setPosition((position.x + population.width + padding) - bounds.width, position.y + 0.5f * padding);
target.draw(text);
Kudos for writing this simulation - everybody who has seen it work has been fascinated.
Hello,
i just saw you're video on youtube and wanted to make my son play with you're animation.
Do you think it is hard if i ask you to make a more detailed instructions file ?
Or maybe a guide on how to put it online so i can share to others you're work.
Thank you.
Edit: Confirmed when using the callback that you wrote for removing a colony (hitting "remove" in GUI), it will sometimes crash if trying to remove a colony with a population of 0.
In the update() function in Simulation, I have a check to see if any colonies have a population of 0 ants. If there are 0 ants, removeColony() is called and the colony is removed from the world, as well as being removed under the hood, from the colonies
vectors in Simulation, world, and renderer.
Strangely, it also only appears to happen when using colonies with somewhat large starting populations (>50?). If you try testing with small colony sizes, it may not occur. Additionally, I believe I have only one instance of crashing when using the actual "remove" button in the GUI (compared to crashes happening every single time otherwise).
It seems like it is either a problem with the index_vector.hpp class, or maybe the target
field in Ant ...? I have been investigating this problem all day with no luck. I'll make a comment below that goes into greater detail.
I was trying to configure it and when i looked into the crashreport it sas that 2 files can't be coppied and those files doesn't exist i tried re downloading pls help
Hello, apologies for not building this on Linux but I currently don't have a proper setup for it. However when building in Windows, and after setting it up in CMake with SFML installed, I cannot build it fully in vs19. It says the "ALL_BUILD" folder does not exist and when trying to just run the application it crashes immediately. After debugging it, I come up with the error code 0xc0000005 which is an access violation even when ran as admin. I cant tell if it just isn't building the full game or if the directory might be messed up. If it were the former I would assume its known already but I just wanted to play around with some ants.
I executed ./install.sh
to build the project and got a long compilation error.
Stack trace:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kv/AntSimulator/build
[ 25%] Building CXX object CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o
In file included from /home/kv/AntSimulator/include/world_grid.hpp:6:0,
from /home/kv/AntSimulator/include/world.hpp:6,
from /home/kv/AntSimulator/include/display_manager.hpp:4,
from /home/kv/AntSimulator/src/display_manager.cpp:1:
/home/kv/AntSimulator/include/grid.hpp: In constructor ‘GridOfNumber<T>::GridOfNumber(int32_t, int32_t, uint32_t)’:
/home/kv/AntSimulator/include/grid.hpp:81:5: error: class ‘GridOfNumber<T>’ does not have any field named ‘Grid’
: Grid(width_, height_, cell_size_)
^~~~
/home/kv/AntSimulator/include/grid.hpp: In constructor ‘GridOfList<T>::GridOfList(int32_t, int32_t, uint32_t)’:
/home/kv/AntSimulator/include/grid.hpp:112:5: error: class ‘GridOfList<T>’ does not have any field named ‘Grid’
: Grid(width_, height_, cell_size_)
^~~~
/home/kv/AntSimulator/include/grid.hpp: In member function ‘T* GridOfList<T>::emplaceAtPosition(sf::Vector2i)’:
/home/kv/AntSimulator/include/grid.hpp:118:7: error: there are no arguments to ‘checkCell’ that depend on a template parameter, so a declaration of ‘checkCell’ must be available [-fpermissive]
if (checkCell(pos)) {
^~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:118:7: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/kv/AntSimulator/include/grid.hpp:119:25: error: there are no arguments to ‘get’ that depend on a template parameter, so a declaration of ‘get’ must be available [-fpermissive]
GridListCell<T>& c = get(pos);
^~~
/home/kv/AntSimulator/include/grid.hpp: In member function ‘T* GridOfList<T>::emplaceAtPosition(sf::Vector2f)’:
/home/kv/AntSimulator/include/grid.hpp:128:28: error: there are no arguments to ‘getCellCoords’ that depend on a template parameter, so a declaration of ‘getCellCoords’ must be available [-fpermissive]
return emplaceAtPosition(getCellCoords(pos));
^~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp: In member function ‘void GridOfList<T>::clearAt(sf::Vector2f)’:
/home/kv/AntSimulator/include/grid.hpp:138:22: error: there are no arguments to ‘getCellCoords’ that depend on a template parameter, so a declaration of ‘getCellCoords’ must be available [-fpermissive]
auto cell_coords = getCellCoords(position);
^~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:139:3: error: ‘cells’ was not declared in this scope
cells[getIndexFromCoords(cell_coords)].data.clear();
^~~~~
/home/kv/AntSimulator/include/grid.hpp:139:3: note: suggested alternative: ‘ceill’
cells[getIndexFromCoords(cell_coords)].data.clear();
^~~~~
ceill
/home/kv/AntSimulator/include/grid.hpp: In member function ‘T* GridOfList<T>::add(const Vector2i&, const T&)’:
/home/kv/AntSimulator/include/grid.hpp:144:7: error: there are no arguments to ‘checkCell’ that depend on a template parameter, so a declaration of ‘checkCell’ must be available [-fpermissive]
if (checkCell(cell_coords)) {
^~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:145:28: error: ‘cells’ was not declared in this scope
GridListCell<T>& cell = cells[getIndexFromCoords(cell_coords)];
^~~~~
/home/kv/AntSimulator/include/grid.hpp:145:28: note: suggested alternative: ‘cell’
GridListCell<T>& cell = cells[getIndexFromCoords(cell_coords)];
^~~~~
cell
/home/kv/AntSimulator/include/grid.hpp:145:34: error: there are no arguments to ‘getIndexFromCoords’ that depend on a template parameter, so a declaration of ‘getIndexFromCoords’ must be available [-fpermissive]
GridListCell<T>& cell = cells[getIndexFromCoords(cell_coords)];
^~~~~~~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp: In member function ‘std::__cxx11::list<T*> GridOfList<T>::getAllAt(const Vector2f&)’:
/home/kv/AntSimulator/include/grid.hpp:155:36: error: there are no arguments to ‘getCellCoords’ that depend on a template parameter, so a declaration of ‘getCellCoords’ must be available [-fpermissive]
const sf::Vector2i cell_coords = getCellCoords(position);
^~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:160:9: error: there are no arguments to ‘checkCell’ that depend on a template parameter, so a declaration of ‘checkCell’ must be available [-fpermissive]
if (checkCell(coords)) {
^~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:161:27: error: there are no arguments to ‘get’ that depend on a template parameter, so a declaration of ‘get’ must be available [-fpermissive]
GridListCell<T>& c = get(coords);
^~~
/home/kv/AntSimulator/include/grid.hpp: In member function ‘GridListCell<T>* GridOfList<T>::getAt(const Vector2f&)’:
/home/kv/AntSimulator/include/grid.hpp:174:36: error: there are no arguments to ‘getCellCoords’ that depend on a template parameter, so a declaration of ‘getCellCoords’ must be available [-fpermissive]
const sf::Vector2i cell_coords = getCellCoords(position);
^~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:176:7: error: there are no arguments to ‘checkCell’ that depend on a template parameter, so a declaration of ‘checkCell’ must be available [-fpermissive]
if (checkCell(cell_coords)) {
^~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:177:12: error: ‘cells’ was not declared in this scope
return &cells[getIndexFromCoords(cell_coords)];
^~~~~
/home/kv/AntSimulator/include/grid.hpp:177:12: note: suggested alternative: ‘ceill’
return &cells[getIndexFromCoords(cell_coords)];
^~~~~
ceill
/home/kv/AntSimulator/include/grid.hpp:177:18: error: there are no arguments to ‘getIndexFromCoords’ that depend on a template parameter, so a declaration of ‘getIndexFromCoords’ must be available [-fpermissive]
return &cells[getIndexFromCoords(cell_coords)];
^~~~~~~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp: In member function ‘bool GridOfList<T>::isEmpty(const Vector2f&) const’:
/home/kv/AntSimulator/include/grid.hpp:185:36: error: there are no arguments to ‘getCellCoords’ that depend on a template parameter, so a declaration of ‘getCellCoords’ must be available [-fpermissive]
const sf::Vector2i cell_coords = getCellCoords(position);
^~~~~~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:187:7: error: there are no arguments to ‘checkCell’ that depend on a template parameter, so a declaration of ‘checkCell’ must be available [-fpermissive]
if (checkCell(cell_coords)) {
^~~~~~~~~
/home/kv/AntSimulator/include/grid.hpp:188:11: error: there are no arguments to ‘getCst’ that depend on a template parameter, so a declaration of ‘getCst’ must be available [-fpermissive]
return getCst(cell_coords).data.empty();
^~~~~~
CMakeFiles/AntSimulator.dir/build.make:62: recipe for target 'CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o' failed
make[2]: *** [CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/AntSimulator.dir/all' failed
make[1]: *** [CMakeFiles/AntSimulator.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
As the title states, I want to propose the simulation of the following:
Danger: When ants sense a threat, they emit the so called 'danger' pheromone which let its colony know that there is a danger present; Could be an intruder, flood or similar.
Death: When ants die (Or sense that they are dying), they leave a pheromone that signals the colony one or more of its colony is dying/has died and may cause fellow ants to investigate and 'bury the fallen'.
Did follow the instructions (they're fairly simple) but CMake doesn't seem to recognize the files.
What the terminal says:
"Configuring incomplete, errors occurred!
See also "C:/Games/AntSimulator-master/build/CMakeFiles/CMakeOutput.log"."
What CMakeOutput.log says:
"The system is: Windows - 10.0.19042 - AMD64"
I can't even begin to guess what's happening. Not very familiar with this program.
Allows an option to allow ants to move walls and to get to their destination
Hi,
I'm having a few issues building on Linux.
[1/4] Building CXX object CMakeFiles/AntSimulator.dir/src/utils.cpp.o
FAILED: CMakeFiles/AntSimulator.dir/src/utils.cpp.o
/usr/bin/c++ -I../include -I../lib -MD -MT CMakeFiles/AntSimulator.dir/src/utils.cpp.o -MF CMakeFiles/AntSimulator.dir/src/utils.cpp.o.d -o CMakeFiles/AntSimulator.dir/src/utils.cpp.o -c ../src/utils.cpp
In file included from ../src/utils.cpp:1:
../include/utils.hpp: In instantiation of ‘float getLength(const sf::Vector2<T>&) [with T = float]’:
../src/utils.cpp:22:40: required from here
../include/utils.hpp:17:13: error: ‘sqrt’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
17 | return sqrt(v.x * v.x + v.y * v.y);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/features.h:473,
from /usr/include/c++/10.2.0/x86_64-pc-linux-gnu/bits/os_defines.h:39,
from /usr/include/c++/10.2.0/x86_64-pc-linux-gnu/bits/c++config.h:518,
from /usr/include/c++/10.2.0/iosfwd:38,
from /usr/include/c++/10.2.0/ios:38,
from /usr/include/c++/10.2.0/ostream:38,
from /usr/include/SFML/System/Err.hpp:32,
from /usr/include/SFML/System.hpp:34,
from /usr/include/SFML/Window.hpp:32,
from /usr/include/SFML/Graphics.hpp:32,
from ../include/utils.hpp:2,
from ../src/utils.cpp:1:
/usr/include/bits/mathcalls.h:143:1: note: ‘double sqrt(double)’ declared here, later in the translation unit
143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
| ^~~~~~~~~~
[2/4] Building CXX object CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o
FAILED: CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o
/usr/bin/c++ -I../include -I../lib -MD -MT CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o -MF CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o.d -o CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o -c ../src/display_manager.cpp
In file included from ../include/marker.hpp:2,
from ../include/world.hpp:6,
from ../include/display_manager.hpp:4,
from ../src/display_manager.cpp:1:
../include/config.hpp:44:17: error: specializing member ‘Conf<>::FOOD_COLOR’ requires ‘template<>’ syntax
44 | const sf::Color Conf<>::FOOD_COLOR = sf::Color(29, 129, 18);
| ^~~~~~
../include/config.hpp:45:17: error: specializing member ‘Conf<>::TO_FOOD_COLOR’ requires ‘template<>’ syntax
45 | const sf::Color Conf<>::TO_FOOD_COLOR = sf::Color(119, 211, 109);
| ^~~~~~
../include/config.hpp:46:17: error: specializing member ‘Conf<>::TO_HOME_COLOR’ requires ‘template<>’ syntax
46 | const sf::Color Conf<>::TO_HOME_COLOR = sf::Color(122, 105, 199);
| ^~~~~~
../include/config.hpp:47:17: error: specializing member ‘Conf<>::COLONY_COLOR’ requires ‘template<>’ syntax
47 | const sf::Color Conf<>::COLONY_COLOR = sf::Color(67, 46, 163);
| ^~~~~~
../include/config.hpp:49:30: error: specializing member ‘Conf<>::ANT_TEXTURE’ requires ‘template<>’ syntax
49 | std::shared_ptr<sf::Texture> Conf<>::ANT_TEXTURE;
| ^~~~~~
../include/config.hpp:50:30: error: specializing member ‘Conf<>::MARKER_TEXTURE’ requires ‘template<>’ syntax
50 | std::shared_ptr<sf::Texture> Conf<>::MARKER_TEXTURE;
| ^~~~~~
In file included from ../include/ant.hpp:9,
from ../include/colony.hpp:5,
from ../include/display_manager.hpp:5,
from ../src/display_manager.cpp:1:
../include/direction.hpp: In member function ‘void Direction::updateVec()’:
../include/direction.hpp:62:13: error: ‘cos’ was not declared in this scope
62 | m_vec.x = cos(m_angle);
| ^~~
../include/direction.hpp:63:13: error: ‘sin’ was not declared in this scope; did you mean ‘sign’?
63 | m_vec.y = sin(m_angle);
| ^~~
| sign
../include/direction.hpp: In member function ‘void Direction::updateTargetVec()’:
../include/direction.hpp:68:20: error: ‘cos’ was not declared in this scope
68 | m_target_vec.x = cos(m_target_angle);
| ^~~
../include/direction.hpp:69:20: error: ‘sin’ was not declared in this scope; did you mean ‘sign’?
69 | m_target_vec.y = sin(m_target_angle);
| ^~~
| sign
In file included from ../include/world.hpp:8,
from ../include/display_manager.hpp:4,
from ../src/display_manager.cpp:1:
../include/utils.hpp: In instantiation of ‘float getLength(const sf::Vector2<T>&) [with T = float]’:
../include/ant.hpp:65:41: required from here
../include/utils.hpp:17:13: error: ‘sqrt’ was not declared in this scope
17 | return sqrt(v.x * v.x + v.y * v.y);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~
[3/4] Building CXX object CMakeFiles/AntSimulator.dir/src/main.cpp.o
FAILED: CMakeFiles/AntSimulator.dir/src/main.cpp.o
/usr/bin/c++ -I../include -I../lib -MD -MT CMakeFiles/AntSimulator.dir/src/main.cpp.o -MF CMakeFiles/AntSimulator.dir/src/main.cpp.o.d -o CMakeFiles/AntSimulator.dir/src/main.cpp.o -c ../src/main.cpp
In file included from ../include/marker.hpp:2,
from ../include/ant.hpp:4,
from ../include/colony.hpp:5,
from ../src/main.cpp:4:
../include/config.hpp:44:17: error: specializing member ‘Conf<>::FOOD_COLOR’ requires ‘template<>’ syntax
44 | const sf::Color Conf<>::FOOD_COLOR = sf::Color(29, 129, 18);
| ^~~~~~
../include/config.hpp:45:17: error: specializing member ‘Conf<>::TO_FOOD_COLOR’ requires ‘template<>’ syntax
45 | const sf::Color Conf<>::TO_FOOD_COLOR = sf::Color(119, 211, 109);
| ^~~~~~
../include/config.hpp:46:17: error: specializing member ‘Conf<>::TO_HOME_COLOR’ requires ‘template<>’ syntax
46 | const sf::Color Conf<>::TO_HOME_COLOR = sf::Color(122, 105, 199);
| ^~~~~~
../include/config.hpp:47:17: error: specializing member ‘Conf<>::COLONY_COLOR’ requires ‘template<>’ syntax
47 | const sf::Color Conf<>::COLONY_COLOR = sf::Color(67, 46, 163);
| ^~~~~~
../include/config.hpp:49:30: error: specializing member ‘Conf<>::ANT_TEXTURE’ requires ‘template<>’ syntax
49 | std::shared_ptr<sf::Texture> Conf<>::ANT_TEXTURE;
| ^~~~~~
../include/config.hpp:50:30: error: specializing member ‘Conf<>::MARKER_TEXTURE’ requires ‘template<>’ syntax
50 | std::shared_ptr<sf::Texture> Conf<>::MARKER_TEXTURE;
| ^~~~~~
In file included from ../include/ant.hpp:9,
from ../include/colony.hpp:5,
from ../src/main.cpp:4:
../include/direction.hpp: In member function ‘void Direction::updateVec()’:
../include/direction.hpp:62:13: error: ‘cos’ was not declared in this scope
62 | m_vec.x = cos(m_angle);
| ^~~
../include/direction.hpp:63:13: error: ‘sin’ was not declared in this scope; did you mean ‘sign’?
63 | m_vec.y = sin(m_angle);
| ^~~
| sign
../include/direction.hpp: In member function ‘void Direction::updateTargetVec()’:
../include/direction.hpp:68:20: error: ‘cos’ was not declared in this scope
68 | m_target_vec.x = cos(m_target_angle);
| ^~~
../include/direction.hpp:69:20: error: ‘sin’ was not declared in this scope; did you mean ‘sign’?
69 | m_target_vec.y = sin(m_target_angle);
| ^~~
| sign
In file included from ../include/world.hpp:8,
from ../include/ant.hpp:6,
from ../include/colony.hpp:5,
from ../src/main.cpp:4:
../include/utils.hpp: In instantiation of ‘float getLength(const sf::Vector2<T>&) [with T = float]’:
../include/ant.hpp:65:41: required from here
../include/utils.hpp:17:13: error: ‘sqrt’ was not declared in this scope
17 | return sqrt(v.x * v.x + v.y * v.y);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~
Missing include <cmath>
was added to include/utils.hpp
which fixed the sqrt/cos/sin errors. I've also added the missing template<>
syntax to include/config.hpp
but now I get a linker error:
[3/3] Linking CXX executable AntSimulator
FAILED: AntSimulator
: && /usr/bin/c++ CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o CMakeFiles/AntSimulator.dir/src/main.cpp.o CMakeFiles/AntSimulator.dir/src/utils.cpp.o -o AntSimulator /usr/lib/libsfml-graphics.so.2.5.1 -lpthread /usr/lib/libsfml-window.so.2.5.1 /usr/lib/libsfml-system.so.2.5.1 && :
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o:(.bss+0x0): multiple definition of `Conf<int>::ANT_COLOR'; CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o:(.bss+0x4): multiple definition of `Conf<int>::FOOD_COLOR'; CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o:(.bss+0x4): first defined here
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o:(.bss+0x8): multiple definition of `Conf<int>::TO_FOOD_COLOR'; CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o:(.bss+0x8): first defined here
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o:(.bss+0xc): multiple definition of `Conf<int>::TO_HOME_COLOR'; CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o:(.bss+0xc): first defined here
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o:(.bss+0x10): multiple definition of `Conf<int>::COLONY_COLOR'; CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o:(.bss+0x10): first defined here
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o: warning: relocation against `_ZN4ConfIiE11ANT_TEXTUREE' in read-only section `.text._ZN4ConfIiE12freeTexturesEv[_ZN4ConfIiE12freeTexturesEv]'
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o: in function `World::render(sf::RenderTarget&, sf::RenderStates const&, bool) const':
display_manager.cpp:(.text._ZNK5World6renderERN2sf12RenderTargetERKNS0_12RenderStatesEb[_ZNK5World6renderERN2sf12RenderTargetERKNS0_12RenderStatesEb]+0xfb): undefined reference to `Conf<int>::MARKER_TEXTURE'
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o: in function `Colony::render(sf::RenderTarget&, sf::RenderStates const&) const':
display_manager.cpp:(.text._ZNK6Colony6renderERN2sf12RenderTargetERKNS0_12RenderStatesE[_ZNK6Colony6renderERN2sf12RenderTargetERKNS0_12RenderStatesE]+0x229): undefined reference to `Conf<int>::ANT_TEXTURE'
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o: in function `Conf<int>::loadTextures()':
main.cpp:(.text._ZN4ConfIiE12loadTexturesEv[_ZN4ConfIiE12loadTexturesEv]+0x2e): undefined reference to `Conf<int>::ANT_TEXTURE'
/usr/bin/ld: main.cpp:(.text._ZN4ConfIiE12loadTexturesEv[_ZN4ConfIiE12loadTexturesEv]+0x46): undefined reference to `Conf<int>::ANT_TEXTURE'
/usr/bin/ld: main.cpp:(.text._ZN4ConfIiE12loadTexturesEv[_ZN4ConfIiE12loadTexturesEv]+0xaf): undefined reference to `Conf<int>::ANT_TEXTURE'
/usr/bin/ld: main.cpp:(.text._ZN4ConfIiE12loadTexturesEv[_ZN4ConfIiE12loadTexturesEv]+0xdb): undefined reference to `Conf<int>::MARKER_TEXTURE'
/usr/bin/ld: main.cpp:(.text._ZN4ConfIiE12loadTexturesEv[_ZN4ConfIiE12loadTexturesEv]+0xf3): undefined reference to `Conf<int>::MARKER_TEXTURE'
/usr/bin/ld: main.cpp:(.text._ZN4ConfIiE12loadTexturesEv[_ZN4ConfIiE12loadTexturesEv]+0x15c): undefined reference to `Conf<int>::MARKER_TEXTURE'
/usr/bin/ld: CMakeFiles/AntSimulator.dir/src/main.cpp.o: in function `Conf<int>::freeTextures()':
main.cpp:(.text._ZN4ConfIiE12freeTexturesEv[_ZN4ConfIiE12freeTexturesEv]+0x32): undefined reference to `Conf<int>::ANT_TEXTURE'
/usr/bin/ld: main.cpp:(.text._ZN4ConfIiE12freeTexturesEv[_ZN4ConfIiE12freeTexturesEv]+0x62): undefined reference to `Conf<int>::MARKER_TEXTURE'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Any ideas?
Hi
It seems like RNG<> does not generate random numbers in succession. Even after restarting my instance, I still get the same number.
How do i change the position of the colonies and how do I create more colonies?
Is there a way to speed up the simulation? Nothing happens when I press the "Full Speed" button in the Time control box.
When I try to place something such as a wall, it only moves the black space. If I click and drag, it moves the black space, and if I only click, nothing happens. Running on Windows (ASUS laptop) and using the touchpad.
I've included the following file to the repo:
vcpkg.json
{
"name": "antsimulator",
"version": "1.0",
"dependencies": [
"sfml"
]
}
If the toolchain file is set for CMake (e.g. in VSCode) there is no need to install sfml independently. If the toolchain file is not set, then the manifest file is ignored.
I've tested this and worked. I would like to create a pull request for this, but don't see how to include in the readme file. Does anyone have an idea?
Running latest release, conf.txt file attached, using release map.png
Cells vector subscript is out of range in this function:
const T& getCst(sf::Vector2i cell_coord) const
{
return cells[getIndexFromCoords(cell_coord)];
}
cell_coord.x = 207, cell_coord.y = 270, cells.size = 129600
In the called function, width = 480:
uint64_t getIndexFromCoords(const sf::Vector2i& cell_coords) const
{
return cell_coords.x + cell_coords.y * width;
}
So this returns 207 + (270 * 480) = 129807 which is out of range.
when running the install_from_docker.sh
file (using sudo) I get this output and the build fails.
note: i had to use patebin because github screws with the formatting
https://pastebin.com/REEd4yMC
system info:
OS: Ubuntu 23.10 x86_64
Kernel: 6.5.0-27-generic
cmake version 3.27.4
Docker version 24.0.5, build ced0996
I have 2 ant colonies and i add one but the game stops for a second and then the game crashes, I don't know what just happen it just crashes.
So I'm on a laptop, and the application has the menus go off my screen...is there a way you guys can make it so that we can click and drag the menus onto the screen please? Thanks!
Hey I'm kinda new to c++ stuff and I've been trying to use multi-threading, because I just have watched a video about it :)..
I want to ask you, why this approach doesn't work?
it seems to have no effect on the CPU usage.
this is the original code for one of the most time-consuming tasks:
for (Colony& colony : colonies)
{
colony.update(dt, world);
}
and this is what I done:
for_each(std::execution::par,colonies.begin(), colonies.end(),
[&dt, this](Colony& colony){
colony.update(dt, world);
});
May I have your opinion?
Hey! Is it possible to put food and walls in blocks at once (like some templates), instead of 1 point? Maybe it can be done programmatically?
Hello, I am getting the error
`By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SFML", but
CMake did not find one.
Could not find a package configuration file provided by "SFML" (requested
version 2) with any of the following names:
SFMLConfig.cmake
sfml-config.cmake
Add the installation prefix of "SFML" to CMAKE_PREFIX_PATH or set
"SFML_DIR" to a directory containing one of the above files. If "SFML"
provides a separate development package or SDK, be sure it has been
installed.`
How would I fix this?
I have:
pacman -S sfml
(cmake was already there)./install.sh
in the repo folderAnd got the following:
[victor@vicm AntSimulator]$ ./install.sh
-- The CXX compiler identification is GNU 11.1.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5.1 in /usr/lib64/cmake/SFML
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/victor/Desktop/AntSimulator/build
[ 25%] Building CXX object CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o
In file included from /home/victor/Desktop/AntSimulator/include/world_renderer.hpp:4,
from /home/victor/Desktop/AntSimulator/include/world.hpp:11,
from /home/victor/Desktop/AntSimulator/include/display_manager.hpp:4,
from /home/victor/Desktop/AntSimulator/src/display_manager.cpp:1:
/home/victor/Desktop/AntSimulator/include/config.hpp:71:69: error: 'Conf' was not declared in this scope
71 | sf::Vector2f DefaultConf<T>::COLONY_POSITION = sf::Vector2f(500.0f, Conf::WIN_HEIGHT * 0.5f);
| ^~~~
In file included from /home/victor/Desktop/AntSimulator/include/colony_base.hpp:3,
from /home/victor/Desktop/AntSimulator/include/ant.hpp:10,
from /home/victor/Desktop/AntSimulator/include/colony.hpp:5,
from /home/victor/Desktop/AntSimulator/include/display_manager.hpp:5,
from /home/victor/Desktop/AntSimulator/src/display_manager.cpp:1:
/home/victor/Desktop/AntSimulator/include/racc.hpp: In member function 'T RDiff<T>::get() const':
/home/victor/Desktop/AntSimulator/include/racc.hpp:90:16: error: 'values' was not declared in this scope
90 | return values[getIndex(-1)] - values[getIndex()];
| ^~~~~~
/home/victor/Desktop/AntSimulator/include/racc.hpp:90:23: error: there are no arguments to 'getIndex' that depend on a template parameter, so a declaration of 'getIndex' must be available [-fpermissive]
90 | return values[getIndex(-1)] - values[getIndex()];
| ^~~~~~~~
/home/victor/Desktop/AntSimulator/include/racc.hpp:90:23: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/victor/Desktop/AntSimulator/include/racc.hpp:90:46: error: there are no arguments to 'getIndex' that depend on a template parameter, so a declaration of 'getIndex' must be available [-fpermissive]
90 | return values[getIndex(-1)] - values[getIndex()];
| ^~~~~~~~
make[2]: *** [CMakeFiles/AntSimulator.dir/build.make:76: CMakeFiles/AntSimulator.dir/src/display_manager.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/AntSimulator.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Am I missing something? Last commit the branch master has at time of cloning: 245f8c4
the commands dont work or im doing something wrong or what?
Sorry, I'm not a c++ person!
Anyway, the instructions for setting up SFML do not work for this project. If I git clone this project into a folder and open that folder in Visual Studio 2019, there is no project settings option in the project menu. The SFML set up instructions rely upon changing these settings. There is a cmake setting menu option but the install instructions in this project do not explain how to apply SFML to this project.
Without this set up, trying to run a build gives this:
I have located SFMLConfig.cmake and set SFML_DIR to hold that file's parent directory. However the same error continues to occur.
Also, the SFML_DIR variable keeps reseting. Am I not saving it properly? I'm using ctrl-s. But say I click on'edit JSON' and then come back then SFML-DIR reverts to SFML_DIR-NOTFOUND
I have also redone the cmake instructions in the readme and added SFML-DIR directly there. It's kind of strange that the isntructions show an error.
Also, what does the last step mean:
"You can now open the generated project and build it."
There is no play button, and f5 does not do anything.
Title says it all! If I try to drag out go make shapes, sometimes it misses a couple blocks or 2.
Pretty much what the title says :)
Idk why i had so much fun dropping some food and building some obstacles and seeing these little virtual ants building an ameisenstraße (looks to me like there is no term for this phenomenon in english).
Nice work 👍
I had played this on early versions where there was like an explosion from the center and ants scattered, was around march or april so whatever that version was current at the time. And I was able to play with the controls on readme, put food, place walls, etc.
Version 3.1, simulation plays red vs blue, but I am not able to interact at all other than pause, is this a bug or is the game now entirely automated?
I know it is not really useful to place a colony outside of the map, but I just accidentally right-clicked and it crashed.
every time I try to run it it says "VCRUNTIME140_1.dll not found" and the program wont run. I've tried reinstalling it and it still happens.
i can´t press barely any button because its like zoomed out the screen
![image](https://github.com/johnBuffer/AntSimulator/assets/133556182/2edc7821-61f9-4164-b40b-24d9e2a8b
Any thing in res folder fails to load. Here is the terminal:
Configuration file couldn't be found.
Failed to load image "res/ant.png". Reason: Unable to open file
Failed to load image "res/marker.png". Reason: Unable to open file
Failed to load font "res/font.ttf" (failed to create the font face)
It works fine in minimized mode but after maximizing the gui controls don't work just the camera controls
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.