Skip to content

Commit 6a750e9

Browse files
committed
deploy: 57ec02f
0 parents  commit 6a750e9

File tree

546 files changed

+64011
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

546 files changed

+64011
-0
lines changed

.nojekyll

Whitespace-only changes.

404.html

+1
Large diffs are not rendered by default.

CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
courses.tolstenko.net
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
subdirlist(activity_dir ${CMAKE_CURRENT_SOURCE_DIR})
2+
3+
foreach(subdir ${activity_dir})
4+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt")
5+
add_subdirectory(${subdir})
6+
endif()
7+
endforeach()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
file(GLOB adv_intro_src CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
2+
3+
enable_testing()
4+
5+
add_executable(adv-01-intro ${adv_intro_src})
6+
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
7+
target_include_directories(adv-01-intro PUBLIC ${DOCTEST_INCLUDE_DIR})
8+
target_link_libraries(adv-01-intro doctest::doctest)
9+
doctest_discover_tests(adv-01-intro)
10+
11+
if(ENABLE_TEST_COVERAGE)
12+
target_compile_options(adv-01-intro PUBLIC -O0 -g -fprofile-arcs -ftest-coverage)
13+
target_link_options(adv-01-intro PUBLIC -fprofile-arcs -ftest-coverage)
14+
endif()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
2+
#include <doctest/doctest.h>
3+
using namespace std;
4+
5+
// create a function that allocates memory on the heap and returns a raw pointer to it
6+
char* allocateMemoryAndClear(int numBytes, char value) {
7+
// implement this function
8+
}
9+
10+
// create a function that deallocates memory on the heap
11+
void deallocateMemory(char*& ptr) {
12+
// implement this function
13+
}
14+
15+
16+
// DO NOT CHANGE THE CODE BELOW THIS LINE
17+
TEST_CASE("allocateMemory") {
18+
char* ptr = allocateMemoryAndClear(3, 'u');
19+
CHECK(ptr != nullptr);
20+
CHECK(ptr[0] == 'u');
21+
CHECK(ptr[1] == 'u');
22+
CHECK(ptr[2] == 'u');
23+
deallocateMemory(ptr);
24+
CHECK(ptr == nullptr);
25+
}

advanced/01-introduction/index.html

+74
Large diffs are not rendered by default.

advanced/01-introduction/setup/index.html

+12
Large diffs are not rendered by default.

advanced/02-oop/img.png

386 KB

advanced/02-oop/img_1.png

79.5 KB

advanced/02-oop/img_2.png

399 KB

advanced/02-oop/index.html

+190
Large diffs are not rendered by default.

advanced/03-pointers/index.html

+251
Large diffs are not rendered by default.

advanced/04-operators/img.png

675 KB

advanced/04-operators/index.html

+164
Large diffs are not rendered by default.

advanced/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
subdirlist(advcpp_chapters ${CMAKE_CURRENT_SOURCE_DIR})
2+
3+
foreach(subdir ${advcpp_chapters})
4+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/CMakeLists.txt")
5+
add_subdirectory(${subdir})
6+
endif()
7+
endforeach()

advanced/index.html

+12
Large diffs are not rendered by default.

algorithms/01-introduction/index.html

+12
Large diffs are not rendered by default.

algorithms/02-analysis/img.png

71.1 KB

algorithms/02-analysis/img_1.png

14.2 KB

algorithms/02-analysis/img_2.png

220 KB

algorithms/02-analysis/img_3.png

125 KB

algorithms/02-analysis/index.html

+58
Large diffs are not rendered by default.

algorithms/03-dynamic-data/index.html

+107
Large diffs are not rendered by default.

algorithms/04-sorting/index.html

+48
Large diffs are not rendered by default.
1.14 MB
334 KB
322 KB
580 KB
143 KB

algorithms/05-divide-and-conquer/index.html

+233
Large diffs are not rendered by default.

algorithms/06-hashtables/img.png

259 KB

algorithms/06-hashtables/img_1.png

9.28 KB

algorithms/06-hashtables/img_2.png

148 KB

algorithms/06-hashtables/img_3.png

697 KB

algorithms/06-hashtables/img_4.png

18.2 KB

algorithms/06-hashtables/img_5.png

952 KB

algorithms/06-hashtables/index.html

+419
Large diffs are not rendered by default.
106 KB

algorithms/07-midterm/index.html

+12
Large diffs are not rendered by default.
510 KB
280 KB

algorithms/08-stack-and-queue/index.html

+120
Large diffs are not rendered by default.
1.39 MB

algorithms/09-break/index.html

+12
Large diffs are not rendered by default.

algorithms/10-graphs/img.png

288 KB

algorithms/10-graphs/img_1.png

612 KB

algorithms/10-graphs/img_2.png

41.3 KB

algorithms/10-graphs/img_3.png

291 KB

algorithms/10-graphs/index.html

+185
Large diffs are not rendered by default.

algorithms/11-dijkstra/img.png

2.23 MB

algorithms/11-dijkstra/img_1.png

678 KB

algorithms/11-dijkstra/img_2.png

182 KB

algorithms/11-dijkstra/index.html

+130
Large diffs are not rendered by default.

algorithms/12-mst/index.html

+465
Large diffs are not rendered by default.

algorithms/13-bst/img.png

210 KB

algorithms/13-bst/index.html

+12
Large diffs are not rendered by default.

algorithms/14-heap/index.html

+12
Large diffs are not rendered by default.

algorithms/15-project/index.html

+12
Large diffs are not rendered by default.

algorithms/16-finals/index.html

+12
Large diffs are not rendered by default.

algorithms/index.html

+12
Large diffs are not rendered by default.

artificialintelligence/00-introduction/index.html

+12
Large diffs are not rendered by default.

artificialintelligence/01-pcg/HydraulicErosion/index.html

+39
Large diffs are not rendered by default.

artificialintelligence/01-pcg/WaveFunctionCollapse/index.html

+153
Large diffs are not rendered by default.

artificialintelligence/01-pcg/index.html

+48
Large diffs are not rendered by default.

artificialintelligence/02-sm/index.html

+12
Large diffs are not rendered by default.

artificialintelligence/03-boardgames/index.html

+12
Large diffs are not rendered by default.

artificialintelligence/04-spatialhashing/index.html

+257
Large diffs are not rendered by default.

artificialintelligence/05-kdtree/index.html

+198
Large diffs are not rendered by default.

artificialintelligence/06-pathfinding/index.html

+301
Large diffs are not rendered by default.

artificialintelligence/07-automatedtesting/index.html

+12
Large diffs are not rendered by default.

artificialintelligence/09-minmax/index.html

+12
Large diffs are not rendered by default.

artificialintelligence/CMakeLists.txt

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function(add_custom_test TEST_NAME TEST_EXECUTABLE TEST_INPUT_LIST TEST_EXPECTED_OUTPUT_LIST)
2+
list(LENGTH TEST_INPUT_LIST num_tests)
3+
4+
MATH(EXPR num_tests "${num_tests} - 1")
5+
message(STATUS "Adding ${num_tests} tests for ${TEST_NAME}.")
6+
7+
set(TEST_COMMANDS "")
8+
foreach(index RANGE 0 ${num_tests})
9+
list(GET TEST_INPUT_LIST ${index} TEST_INPUT)
10+
list(GET TEST_EXPECTED_OUTPUT_LIST ${index} TEST_EXPECTED_OUTPUT)
11+
12+
list(APPEND TEST_COMMANDS
13+
COMMAND ${CMAKE_COMMAND} -E echo "Running test: ${TEST_NAME}_${index}. Using input file: ${TEST_INPUT}"
14+
COMMAND ${CMAKE_COMMAND} -E cat ${TEST_INPUT}
15+
COMMAND ${CMAKE_COMMAND} -E echo "=================================="
16+
COMMAND ${CMAKE_COMMAND} -E echo "Expected Output from ${TEST_NAME}_${index}:"
17+
COMMAND ${CMAKE_COMMAND} -E cat ${TEST_EXPECTED_OUTPUT}
18+
COMMAND ${CMAKE_COMMAND} -E echo "=================================="
19+
COMMAND ${TEST_EXECUTABLE} < ${TEST_INPUT} > test_output_${index}.txt
20+
COMMAND ${CMAKE_COMMAND} -E echo "Actual Output from ${TEST_NAME}_${index}:"
21+
COMMAND ${CMAKE_COMMAND} -E cat test_output_${index}.txt
22+
COMMAND ${CMAKE_COMMAND} -E echo "=================================="
23+
COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_EXPECTED_OUTPUT} test_output_${index}.txt
24+
COMMAND ${CMAKE_COMMAND} -E echo "Test ${TEST_NAME}_${index} passed."
25+
)
26+
endforeach()
27+
28+
add_custom_target(${TEST_NAME}
29+
${TEST_COMMANDS}
30+
DEPENDS ${TEST_EXECUTABLE}
31+
)
32+
endfunction()
33+
34+
add_subdirectory(assignments/flocking)
35+
add_subdirectory(assignments/maze)
36+
add_subdirectory(assignments/life)
37+
add_subdirectory(assignments/rng)
38+
add_subdirectory(assignments/catchthecat)

artificialintelligence/animation/index.html

+12
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
add_executable(ai-catchthecat simulator.cpp)
2+
3+
file(GLOB TEST_INPUT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.in)
4+
file(GLOB TEST_OUTPUT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.out)
5+
6+
add_custom_test(ai-catchthecat-test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ai-catchthecat "${TEST_INPUT_FILES}" "${TEST_OUTPUT_FILES}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef CAT_h
2+
#define CAT_h
3+
#include "IAgent.h"
4+
5+
struct Cat : public IAgent {
6+
std::pair<int,int> move(const std::vector<bool>& world, std::pair<int,int> catPos, int sideSize ) override{
7+
return {0,0}; // todo: change this
8+
}
9+
};
10+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef CATCHER_H
2+
#define CATCHER_H
3+
#include "IAgent.h"
4+
5+
struct Catcher : public IAgent {
6+
std::pair<int,int> move(const std::vector<bool>& world, std::pair<int,int> catPos, int sideSize ) override{
7+
return {0,0}; // todo: change this
8+
}
9+
};
10+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef IAgent_h
2+
#define IAgent_h
3+
#include <vector>
4+
#include <utility>
5+
#include <string>
6+
7+
// NO NOT CHANGE THIS FILE
8+
struct IAgent {
9+
public:
10+
/**
11+
* @brief the agent implementation. the center of the world is {0,0}, top left is {-sideSize/2, -sideSize/2} and the bottom right is {sideSize/2, sideSize/2}.
12+
*
13+
* @param world the world as a vector of booleans. true means there is a wall, false means there is no wall. The vector is the linearization of the matrix of the world.
14+
* @param catPos the position of the cat in the world {x,y} relative to the center of the world.
15+
* @param sideSize the side size of the world. it will be always a square that follows the sequence of 4*i+1: 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, ...
16+
*
17+
* @return the position to move to {x,y}. relative to the center of the world.
18+
*/
19+
virtual std::pair<int,int> move(const std::vector<bool>& world, std::pair<int,int> catPos, int sideSize ) = 0;
20+
};
21+
#endif

artificialintelligence/assignments/catchthecat/index.html

+59
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// DO NOT SUBMIT THIS FILE
2+
// IMPROVE THIS SIMULATOR FOR YOUR OWN USE
3+
// this code is not well tested, use as entry point for your own simulator
4+
#include <iostream>
5+
#include <vector>
6+
#include "Cat.h"
7+
#include "Catcher.h"
8+
9+
void print(const std::vector<bool>& state, int sideSize, std::pair<int,int> catPos, const std::string& turn){
10+
std::cout << turn << " " << sideSize << " " << catPos.first << " " << catPos.second << std::endl;
11+
catPos.first += sideSize/2;
12+
catPos.second += sideSize/2;
13+
auto catPosIndex = catPos.second * sideSize + catPos.first;
14+
for(int y=0; y<sideSize; y++) {
15+
if (y % 2 == 1) std::cout << ' ';
16+
for (int x = 0; x < sideSize; x++) {
17+
if(y * sideSize + x == catPosIndex) {
18+
std::cout << 'C';
19+
} else
20+
std::cout << (state[y * sideSize + x] ? '#' : '.');
21+
if (x < sideSize - 1) std::cout << ' ';
22+
}
23+
std::cout << std::endl;
24+
}
25+
}
26+
27+
std::vector<bool> readBoard(int sideSize) {
28+
std::vector<bool> board;
29+
board.reserve(sideSize*sideSize);
30+
for(int i=0; i<sideSize*sideSize; i++) {
31+
char c;
32+
std::cin >> c;
33+
switch (c) {
34+
case '#':
35+
board.push_back(true);
36+
break;
37+
case '.':
38+
case 'C':
39+
board.push_back(false);
40+
break;
41+
default:
42+
i--;
43+
break;
44+
}
45+
}
46+
return board;
47+
}
48+
49+
int main() {
50+
std::string turn;
51+
int sideSize;
52+
int catX, catY;
53+
std::vector<bool> blocked;
54+
std::cin >> turn >> sideSize >> catX >> catY;
55+
blocked = readBoard(sideSize);
56+
// while(not win){ simulate; } // todo: create your own logic to test and simulate, check for win conditions etc.
57+
if(turn == "CAT"){
58+
Cat cat;
59+
auto catMove = cat.move(blocked, {catX, catY}, sideSize);
60+
print(blocked, sideSize, {catMove.first, catMove.second}, "CATCHER");
61+
} else if (turn == "CATCHER") {
62+
Catcher catcher;
63+
auto catcherMove = catcher.move(blocked, {catX, catY}, sideSize);
64+
blocked[(catcherMove.second + sideSize/2) * sideSize + catcherMove.first+sideSize/2] = true;
65+
print(blocked, sideSize, {catX, catY}, "CATCHER");
66+
}
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAT 5 0 0
2+
. . . . .
3+
. # # . .
4+
. # C . .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CATCHER 5 1 0
2+
. . . . .
3+
. # # . .
4+
. # . C .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAT 5 0 0
2+
. . . . .
3+
. # # . .
4+
. # C # .
5+
. # . . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CATCHER 5 0 1
2+
. . . . .
3+
. # # . .
4+
. # . # .
5+
. # C . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAT 5 0 0
2+
. . . . .
3+
. # # . .
4+
. # C # .
5+
. . # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CATCHER 5 -1 1
2+
. . . . .
3+
. # # . .
4+
. # . # .
5+
. C # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAT 5 0 0
2+
. . . . .
3+
. # # . .
4+
. . C # .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CATCHER 5 -1 0
2+
. . . . .
3+
. # # . .
4+
. C . # .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAT 5 0 0
2+
. . . . .
3+
. # # . .
4+
. . C # .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CATCHER 5 -1 0
2+
. . . . .
3+
. # # . .
4+
. C . # .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CAT 5 0 0
2+
. . . . .
3+
. . # . .
4+
. # C # .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CATCHER 5 -1 -1
2+
. . . . .
3+
. C # . .
4+
. # . # .
5+
. # # . .
6+
. . . . .
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
add_executable(ai-flocking flocking.cpp)
2+
3+
file(GLOB TEST_INPUT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.in)
4+
file(GLOB TEST_OUTPUT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.out)
5+
6+
add_custom_test(ai-flocking-test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/flocking "${TEST_INPUT_FILES}" "${TEST_OUTPUT_FILES}")
7+

0 commit comments

Comments
 (0)