Skip to content

Commit

Permalink
Readme improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa-br34 committed Oct 12, 2024
1 parent ed611ca commit 2264562
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

add_executable(${PROJECT_NAME}-CLI SOURCE/Entry.cpp ${COMMON_SOURCES})
add_executable(${PROJECT_NAME}-CPP SOURCE/Direct.cpp ${COMMON_SOURCES})
add_executable(Interface SOURCE/Interface.cpp ${COMMON_SOURCES})
add_executable(Direct SOURCE/Direct.cpp ${COMMON_SOURCES})
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ The web version can be found [here](https://rafa-br34.github.io/LangtonsAnt)
- [Implementation notes](#implementation-notes)
- [Usage](#usage)
- [Web version](#web-version)
- [C++ version](#c-version)
- [C++ versions](#c-versions)
- [`Direct.cpp` VS `Interface.cpp`](#directcpp-vs-interfacecpp)
- [Building](#building)
- [Arguments](#arguments)
- [`-x` \& `-y`](#-x---y)
Expand All @@ -25,7 +26,7 @@ The web version can be found [here](https://rafa-br34.github.io/LangtonsAnt)

# Implementation notes

Both the C++ ([Ant.h](https://github.com/rafa-br34/LangtonsAnt/blob/master/SOURCE/Types/Ant.h)) and JavaScript ([Ant.js](https://github.com/rafa-br34/LangtonsAnt/blob/master/WEBSITE/Scripts/Ant.js)) version share the same implementation concept.
The JavaScript ([Ant.js](https://github.com/rafa-br34/LangtonsAnt/blob/master/WEBSITE/Scripts/Ant.js)) version is basically a line by line rewrite of the C++ ([Ant.h](https://github.com/rafa-br34/LangtonsAnt/blob/master/SOURCE/Types/Ant.h)) version (in the future this may change).
There's support for 8 possible operations, which are:

- R45/L45
Expand All @@ -40,10 +41,17 @@ There's support for 8 possible operations, which are:

Placeholder

## C++ version
## C++ versions

### `Direct.cpp` VS `Interface.cpp`

The `Direct.cpp` file is an example implementation of how you can use this repo to implement your own Langton's ant simulation.
The `Interface.cpp` file on the other hand is a simple CLI that allows you to mess around without prior C/C++ knowledge.

### Building

The following works for both Linux and Windows.

```bash
git clone --recursive https://github.com/rafa-br34/LangtonsAnt.git
cd LangtonsAnt
Expand Down
10 changes: 7 additions & 3 deletions SOURCE/Direct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ int main() {

for (size_t i = 0; i < Frames; i++) {
size_t Result = Simulation.Simulate(CaptureDelta);

printf("Frame: %lu Iters: %lu/%lu Threads: %lu\n", i, Result, CaptureDelta, Encoder.Threads.ActiveThreads());

Encoder.EncodeAsync(Simulation, [&, i](const std::vector<uint8_t>& ImageData, const Vector2<int>&, unsigned int) {
std::cout
<< "Frame: " << i
<< " Iters: " << Result << '/' << CaptureDelta
<< " Active threads: " << Encoder.Threads.ActiveThreads()
<< '\n';

Encoder.EncodeAsync(Simulation, [&, i](const std::vector<uint8_t>& ImageData, const Vector2<SizeType>&, unsigned int) {
lodepng::save_file(ImageData, "frames/" + std::to_string(i) + ".png");
});
}
Expand Down
10 changes: 5 additions & 5 deletions SOURCE/Encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ namespace Encoding {
m_Palette.push_back(ColoringProcedure(s));
}

INLINE size_t GetSize() const {
inline size_t GetSize() const {
return m_Palette.size();
}

INLINE RGBA32 GetColor(size_t Index) {
inline RGBA32 GetColor(size_t Index) {
if (Index + 1 > m_Palette.size())
ResizePalette(Index + 1);

return m_Palette[Index];
}

INLINE RGBA32* GetData() {
inline RGBA32* GetData() {
return m_Palette.data();
}

INLINE RGBA32 operator[](size_t Index) {
inline RGBA32 operator[](size_t Index) {
return m_Palette[Index];
}
};
Expand Down Expand Up @@ -177,7 +177,7 @@ namespace Encoding {

ASSERT_MSG(Result == 0, "lodepng::encode -> %d\n", Result);

Callback(ImageData, Vector2<int>(Size.X, Size.Y), Result);
Callback(ImageData, Vector2<SizeType>(Size.X, Size.Y), Result);
}

public:
Expand Down
File renamed without changes.

0 comments on commit 2264562

Please sign in to comment.