Skip to content

Commit

Permalink
Changed a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa-br34 committed May 13, 2024
1 parent f6afb74 commit cdcf6b8
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Defines when a canvas snapshot should be taken. Can be chained using `;`
#### `-o`:
Defines how to output images.
- `f:<format>:<name>`: Write image files. `%d` can be used for the image index and `%i` for the current iteration.
- `s:<format>:<stdout|stderr|stream>:<stream_name?>`: Write images to a pipe/stream.
- `s:<format>:<stdout|stream>:<stream_name?>`: Write images to a pipe/stream.
Supported formats:
- `idx`: Outputs the raw buffer.
- `rgb24`: Outputs the raw buffer as RGB24.
Expand Down
12 changes: 8 additions & 4 deletions SOURCE/ConfigParser.h → SOURCE/Configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "Types/Ant.h"

// @todo A ParserState class could be a good idea
namespace ConfigParser {
namespace Configs {
union EvaluationTime

enum class ParserStatus : uint8_t {
OK = 0,
NO_MATCHES,
Expand Down Expand Up @@ -38,7 +40,8 @@ namespace ConfigParser {
}

// If skip is 0 then we didn't find anything, so presume R90/L90
if (Skip == 0) Result.push_back(DirectionEnum(2 * ParseDirection));
if (Skip == 0)
Result.push_back(DirectionEnum(2 * ParseDirection));

ParseDirection = 0; // Stop parsing direction
}
Expand All @@ -60,8 +63,9 @@ namespace ConfigParser {
}
}

if (ParseDirection != 0) Result.push_back(DirectionEnum(2 * ParseDirection));

if (ParseDirection != 0)
Result.push_back(DirectionEnum(2 * ParseDirection));

return Result;
}

Expand Down
43 changes: 26 additions & 17 deletions SOURCE/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@

#include <argparse/argparse.hpp>

#include "ConfigParser.h"
#include "Encoding.h"
#include "Configs.h"
#include "Common.h"


#include "Types/SimulationState.h"
#include "Types/Vector.h"
#include "Types/Ant.h"


/* @todo argument parser yay
//* @todo argument parser yay
template<typename Type, typename SizeType=size_t>
void BuildPossibilityList(std::vector<std::vector<Type>>& List, SizeType Size, Type* Dictionary, SizeType DictionarySize) {
Type* Current = new Type[Size];
Expand All @@ -50,7 +49,8 @@ void BuildPossibilityList(std::vector<std::vector<Type>>& List, SizeType Size, T
}


void ParseArguments(int Count, const char* Values[], State<>& GlobalState) {
template<typename CellType, typename SizeType>
void ParseArguments(int Count, const char* Values[], SimulationState<CellType, SizeType>& Simulation) {
argparse::ArgumentParser Program("Langton's ant");

Program.add_description("Efficient modular implementation of Langton's ant universal Turing machine which supports R45/L45, R90/L90, R135/L135, U(U turn), and C(Continue)");
Expand All @@ -76,7 +76,6 @@ void ParseArguments(int Count, const char* Values[], State<>& GlobalState) {
.default_value("i5000")
.help("Defines how many iterations should be evaluated, i50b runs for 50b iterations, t50 runs for 50 seconds.");

try {
Program.parse_args(Count, Values);
}
Expand All @@ -86,26 +85,35 @@ void ParseArguments(int Count, const char* Values[], State<>& GlobalState) {
std::exit(1);
}

GlobalState.CanvasSize.X = Program.get<int>("-x");
GlobalState.CanvasSize.Y = Program.get<int>("-y");
Simulation.Resize(
Program.get<SizeType>("-x"),
Program.get<SizeType>("-y")
);

std::vector<std::vector<DirectionEnum>> StateMachines = {};

ConfigParser::ParseStateMachines(Program.get<std::string>("-m"), StateMachines);
ConfigParser::ParseAnts(Program.get<std::string>("-a"), StateMachines, GlobalState.TemplateAnts);
ConfigParser::ParseStateMachines(
Program.get<std::string>("-m"),
StateMachines
);
ConfigParser::ParseAnts(
Program.get<std::string>("-a"),
StateMachines,
Simulation.TemplateAnts
);

GlobalState.Reset();
Simulation.Reset();
}

int main(int ArgCount, const char* ArgValues[]) {
State GlobalState;
ParseArguments(ArgCount, ArgValues, GlobalState);
SimulationState<uint8_t, int> Simulation = {};

ParseArguments(ArgCount, ArgValues, Simulation);

}
*/

//*/

/*
int main(int ArgCount, const char* ArgValues[]) {
using enum DirectionEnum;
std::vector<DirectionEnum> StateMachine = {
Expand Down Expand Up @@ -151,7 +159,7 @@ int main(int ArgCount, const char* ArgValues[]) {
Ants.push_back(Ant<uint8_t>(Center + Vector2(10, 0), Vector2<int8_t>(-1, 0), StateMachine, StateMachineSize));
Ants.push_back(Ant<uint8_t>(Center - Vector2(10, 0), Vector2<int8_t>( 1, 0), StateMachine, StateMachineSize));
//*/
///
auto Center = CanvasSize / Vector2(2, 2);
//Simulation.AddAnt(Ant<uint8_t>(Center, Vector2<int8_t>(0, -1), {R,L}, true));
Expand Down Expand Up @@ -231,10 +239,11 @@ int main(int ArgCount, const char* ArgValues[]) {
Threads.ReleaseThread();
}).detach();
*/
/
Encoder.EncodeAsync(Simulation, [&, i](const std::vector<uint8_t>& ImageData, const Vector2<int>&, unsigned int) {
lodepng::save_file(ImageData, "Frames/" + std::to_string(i) + ".png");
});
}
}
*/
6 changes: 3 additions & 3 deletions WEBSITE/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@

<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="Styles/Main.css">
<link rel="canonical" href="https://rafa-br34.github.io/LangtonsAnt"/>
<link rel="stylesheet" href="Styles/Main.css"/>

<script src="https://code.jquery.com/jquery-3.7.1.min.js"/></script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://unpkg.com/[email protected]"></script>

<script src="Scripts/Debug.js"></script>
Expand All @@ -53,7 +54,6 @@
<script src="Scripts/Ant.js"></script>
</head>
<body>
<!-- @todo UI improvements -->
<canvas id="MainCanvas"></canvas>
<div id="ManagerContainer">
<!-- Simulation settings -->
Expand Down
2 changes: 2 additions & 0 deletions WEBSITE/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow:

0 comments on commit cdcf6b8

Please sign in to comment.