-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated benchmarks and added Makefile and demo files
- Loading branch information
Showing
10 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Makefile for sista.cpp | ||
IMPLEMENTATIONS = include/sista/ANSI-Settings.cpp include/sista/border.cpp include/sista/coordinates.cpp include/sista/cursor.cpp include/sista/field.cpp include/sista/pawn.cpp | ||
|
||
all: | ||
g++ -std=c++17 -Wall -g -c $(IMPLEMENTATIONS) | ||
g++ -std=c++17 -Wall -g -c sista.cpp | ||
g++ -std=c++17 -Wall -g -o sista sista.o ANSI-Settings.o border.o coordinates.o cursor.o pawn.o field.o | ||
rm -f *.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
IMPLEMENTATIONS = ../include/sista/ANSI-Settings.cpp ../include/sista/border.cpp ../include/sista/coordinates.cpp ../include/sista/cursor.cpp ../include/sista/field.cpp ../include/sista/pawn.cpp | ||
|
||
all: | ||
g++ -std=c++17 -Wall -g -c $(IMPLEMENTATIONS) | ||
g++ -std=c++17 -Wall -g -c header-test.cpp | ||
g++ -std=c++17 -Wall -g -o header-test header-test.o ANSI-Settings.o border.o coordinates.o cursor.o pawn.o field.o | ||
rm -f *.o |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// make | ||
#include "../include/sista/sista.hpp" | ||
#include <chrono> | ||
#include <thread> | ||
|
||
|
||
ANSI::Settings default_settings( | ||
ANSI::ForegroundColor::F_WHITE, | ||
ANSI::BackgroundColor::B_BLACK, | ||
ANSI::Attribute::RESET | ||
); | ||
sista::Border border( | ||
'#', ANSI::Settings( | ||
ANSI::ForegroundColor::F_WHITE, | ||
ANSI::BackgroundColor::B_BLACK, | ||
ANSI::Attribute::BLINK | ||
) | ||
); | ||
|
||
|
||
int main() { | ||
sista::SwappableField field(50, 50); | ||
std::vector<sista::Pawn*> pawns; | ||
for (int i = 0; i < 50; i++) { | ||
pawns.push_back( | ||
new sista::Pawn( | ||
'X', { | ||
rand() % 50, | ||
rand() % 50 | ||
}, default_settings | ||
) | ||
); | ||
field.addPawn(pawns[i]); | ||
} | ||
field.print(border); | ||
|
||
std::vector<sista::Coordinates> coords(pawns.size()); | ||
for (int i = 0; i < 1000; i++) { | ||
for (int k = 0; k < pawns.size(); k++) { | ||
coords[k] = field.movingByCoordinates( | ||
pawns[k], rand() % 3 - 1, rand() % 3 - 1, PACMAN_EFFECT | ||
); | ||
} | ||
try { | ||
for (int k = 0; k < pawns.size(); k++) { | ||
field.movePawn(pawns[k], coords[k]); | ||
} | ||
} catch (std::invalid_argument& e) { | ||
for (int k = 0; k < pawns.size(); k++) { | ||
field.addPawnToSwap(pawns[k], coords[k]); | ||
} | ||
field.applySwaps(); | ||
} | ||
std::this_thread::sleep_for(std::chrono::milliseconds(10)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters