commit 1b29e4ac5f9cbf7d0cb074b2d44a17f2fac36227
parent 753c136018bfb1946eab42bed3257a3b12e9e8bd
Author: Christos Margiolis <christos@margiolis.net>
Date: Mon, 31 May 2021 01:41:10 +0300
fixed stupid multithreading mistakes
Diffstat:
15 files changed, 254 insertions(+), 149 deletions(-)
diff --git a/c_os2/ex1/ex3.c b/c_os2/ex1/ex3.c
@@ -55,7 +55,11 @@ calc(void *foo)
int tid, n, i;
f = (struct foo *)foo;
- tid = f->tid;
+ if (pthread_mutex_lock(&f->mutex) != 0)
+ err(1, "pthread_mutex_lock");
+ tid = f->tid++;
+ if (pthread_mutex_unlock(&f->mutex) != 0)
+ err(1, "pthread_mutex_unlock");
n = f->n / f->ntd;
f->sums[tid] = 0;
localsum = 0;
@@ -93,7 +97,6 @@ main(int argc, char *argv[])
{
struct foo *f; /* Each callback will receive this */
pthread_t *tds; /* Threads */
- pthread_t fin; /* Will calculate the total sum */
int totalsum; /* What its name says */
int i; /* Counter */
@@ -134,13 +137,12 @@ main(int argc, char *argv[])
* and we pass it the `foo` struct as an argument to avoid
* declaring globals.
*/
- for (i = 0; i < f->ntd; i++) {
- f->tid = i;
+ for (i = 0; i < f->ntd; i++)
if (pthread_create(&tds[i], NULL, calc, (void *)f) != 0)
err(1, "pthread_create");
+ for (i = 0; i < f->ntd; i++)
if (pthread_join(tds[i], NULL) != 0)
err(1, "pthread_join");
- }
totalsum = 0;
while (f->ntd--)
totalsum += *f->sums++;
diff --git a/c_os2/ex2/Makefile b/c_os2/ex2/Makefile
@@ -1,5 +1,5 @@
all:
- cc ex1_1.c -lpthread -o ex1_1
+ cc ex1_1.c -lpthread -lrt -o ex1_1
cc ex1_2.c -lpthread -o ex1_2
cc ex2.c -lpthread -DLLIM=10 -DULIM=100 -o ex2
cc ex3_server.c -lpthread -o ex3_server
diff --git a/c_os2/ex2/ex1_1.c b/c_os2/ex2/ex1_1.c
@@ -12,16 +12,17 @@
* Εργαστήριο ΛΣ2 (Δ6) / Εργασία 2: Άσκηση 1.1 / 2020-2021
* Ονοματεπώνυμο: Χρήστος Μαργιώλης
* ΑΜ: 19390133
- * Τρόπος μεταγλώττισης: `cc ex1_1.c -lpthread -o ex1_1`
+ * Τρόπος μεταγλώττισης: `cc ex1_1.c -lpthread -lrt -o ex1_1`
*/
struct foo {
char *str;
+ int tid;
sem_t sem;
};
/* Function declarations */
-static void *tdprint(void *);
+static void *thread_callback(void *);
static void *emalloc(size_t);
static void usage(void);
@@ -38,15 +39,16 @@ static const char *nums[] = {
};
static void *
-tdprint(void *foo)
+thread_callback(void *foo)
{
struct foo *f;
f = (struct foo *)foo;
if (sem_wait(&f->sem) < 0)
err(1, "sem_wait");
- printf("%s", f->str);
- /* Prevent memory leak from strdup(2). */
+ if ((f->str = strdup(nums[f->tid++])) == NULL)
+ err(1, "strdup");
+ fputs(f->str, stdout);
free(f->str);
if (sem_post(&f->sem) < 0)
err(1, "sem_post");
@@ -85,7 +87,7 @@ main(int argc, char *argv[])
switch (ch) {
case 'n':
if ((n = atoi(optarg)) < 1)
- usage();
+ errx(1, "value must be greater than 1");
break;
case '?':
default:
@@ -105,17 +107,24 @@ main(int argc, char *argv[])
tds = emalloc(len * sizeof(pthread_t));
f = emalloc(sizeof(struct foo));
+ /*
+ * sem_init(3)'s second argument defines whether the semaphore
+ * should be shared by multiple processes or not. This is done
+ * by passing a non-zero value, but in this case we want the
+ * semaphore to be shared only by this process.
+ */
if (sem_init(&f->sem, 0, 1) < 0)
err(1, "sem_init");
+
while (n--) {
- for (i = 0; i < len; i++) {
- if ((f->str = strdup(nums[i])) == NULL)
- err(1, "strdup");
- if (pthread_create(&tds[i], NULL, tdprint, (void *)f) != 0)
+ f->tid = 0;
+ for (i = 0; i < len; i++)
+ if (pthread_create(&tds[i], NULL,
+ thread_callback, (void *)f) != 0)
err(1, "pthread_create");
+ for (i = 0; i < len; i++)
if (pthread_join(tds[i], NULL) != 0)
err(1, "pthread_join");
- }
}
printf("\n");
diff --git a/c_os2/ex2/ex1_2.c b/c_os2/ex2/ex1_2.c
@@ -16,13 +16,14 @@
struct foo {
char *str;
+ int done;
+ int tid;
pthread_mutex_t mtx;
pthread_cond_t cv;
- int done;
};
/* Function declarations */
-static void *tdprint(void *);
+static void *thread_callback(void *);
static void *emalloc(size_t);
static void usage(void);
@@ -35,7 +36,7 @@ static const char *nums[] = {
};
static void *
-tdprint(void *foo)
+thread_callback(void *foo)
{
struct foo *f;
@@ -47,14 +48,17 @@ tdprint(void *foo)
* with `pthread_cond_wait`.
*/
f->done = 0;
+ if ((f->str = strdup(nums[f->tid++])) == NULL)
+ err(1, "strdup");
printf("%s", f->str);
free(f->str);
f->done = 1;
+
/* If a thread is not done executing the statements above, wait. */
if (!f->done) {
if (pthread_cond_wait(&f->cv, &f->mtx) != 0)
err(1, "pthread_cond_wait");
- /* We're done, the next thread can do its job now. */
+ /* We're done, the next threads can do their job now. */
} else {
if (pthread_cond_signal(&f->cv) != 0)
err(1, "pthread_cond_signal");
@@ -96,7 +100,7 @@ main(int argc, char *argv[])
switch (ch) {
case 'n':
if ((n = atoi(optarg)) < 1)
- usage();
+ errx(1, "value must be greater than 1");
break;
case '?':
default:
@@ -110,20 +114,20 @@ main(int argc, char *argv[])
tds = emalloc(len * sizeof(pthread_t));
f = emalloc(sizeof(struct foo));
- f->done = 0;
if (pthread_mutex_init(&f->mtx, NULL) != 0)
err(1, "pthread_mutex_init");
if (pthread_cond_init(&f->cv, NULL) != 0)
err(1, "pthread_cond_init");
+
while (n--) {
- for (i = 0; i < len; i++) {
- if ((f->str = strdup(nums[i])) == NULL)
- err(1, "strdup");
- if (pthread_create(&tds[i], NULL, tdprint, (void *)f) != 0)
+ f->done = f->tid = 0;
+ for (i = 0; i < len; i++)
+ if (pthread_create(&tds[i], NULL,
+ thread_callback, (void *)f) != 0)
err(1, "pthread_create");
+ for (i = 0; i < len; i++)
if (pthread_join(tds[i], NULL) != 0)
err(1, "pthread_join");
- }
}
printf("\n");
diff --git a/c_os2/ex2/ex2.c b/c_os2/ex2/ex2.c
@@ -18,7 +18,7 @@ struct foo {
int **d; /* `d[i][j] = g_max - g_arr[i][j]` */
int *l_max; /* Local maximums. */
int g_max; /* Global maximum. */
- int l_n; /* Number of elements for each thread. */
+ int l_n; /* Number of elements each thread will work with. */
int n; /* Dimensions. */
int ntd; /* Number of threads. */
int tid; /* Thread ID. */
@@ -26,19 +26,17 @@ struct foo {
pthread_barrier_t bar;
};
-/* Function declarations */
static void *threaded_stuff(void *);
static void *emalloc(size_t);
static void usage(void);
-/* Global variables */
static char *argv0;
static void *
-threaded_stuff(void *foo)
+thread_callback(void *foo)
{
struct foo *f;
- int i, j, start, end, max;
+ int i, j, start, end, max, rc;
f = (struct foo *)foo;
/*
@@ -82,25 +80,46 @@ threaded_stuff(void *foo)
max = f->g_arr[i][j];
f->l_max[f->tid] = max;
- /* Calculate the global max, no need for more functions. */
+ /* Calculate the global max right away, no need for more functions. */
if (pthread_mutex_lock(&f->mtx) != 0)
err(1, "pthread_mutex_lock");
if (f->tid == 0)
f->g_max = *f->l_max;
else if (f->l_max[f->tid] > f->g_max)
f->g_max = f->l_max[f->tid];
+
+ /*
+ * We need to know each thread's ID in order to calculate `start`
+ * and `end` properly. Since we don't touch `f->tid` inside `main`
+ * (apart from initializing it), we need to change its value here.
+ */
+ f->tid++;
if (pthread_mutex_unlock(&f->mtx) != 0)
err(1, "pthread_mutex_unlock");
+
/*
* Wait for all threads to finish executing the statements above,
* then continue.
- * FIXME
*/
- (void)pthread_barrier_wait(&f->bar);
- if (errno == EINVAL)
+ rc = pthread_barrier_wait(&f->bar);
+ if ((rc != 0 && rc != PTHREAD_BARRIER_SERIAL_THREAD) || errno == EINVAL)
err(1, "pthread_barrier_wait");
+ /*
+ * We'll get here once all threads have passed the barrier, which
+ * means that `f->tid` will be equal to the total number of threads.
+ * In order for `start` and `end` to be offset properly again, we now
+ * need to go backwards.
+ */
+ if (pthread_mutex_lock(&f->mtx) != 0)
+ err(1, "pthread_mutex_lock");
+ f->tid--;
+ if (pthread_mutex_unlock(&f->mtx) != 0)
+ err(1, "pthread_mutex_unlock");
+
/* Calculate the D array. */
+ start = f->tid * f->l_n;
+ end = start + f->l_n;
for (i = start; i < end; i++)
for (j = 0; j < f->n; j++)
f->d[i][j] = f->g_max - f->g_arr[i][j];
@@ -139,11 +158,16 @@ main(int argc, char *argv[])
do {
printf("p: ");
scanf("%d", &f->ntd);
- } while (f->ntd < 0);
+ /* Cannot have less than 1 threads. */
+ } while (f->ntd < 1);
do {
printf("n: ");
scanf("%d", &f->n);
+ /*
+ * The number of elements must be greater than 0 (obviously) and
+ * a multiple of the number of threads.
+ */
} while (f->n < 0 || f->n % f->ntd != 0);
tds = emalloc(f->ntd * sizeof(pthread_t));
@@ -165,13 +189,12 @@ main(int argc, char *argv[])
if (pthread_barrier_init(&f->bar, NULL, f->ntd) != 0)
err(1, "pthread_barrier_init");
- for (i = 0; i < f->ntd; i++) {
- f->tid = i;
- if (pthread_create(&tds[i], NULL, threaded_stuff, (void *)f) != 0)
+ for (i = 0, f->tid = 0; i < f->ntd; i++)
+ if (pthread_create(&tds[i], NULL, thread_callback, (void *)f) != 0)
err(1, "pthread_create");
+ for (i = 0; i < f->ntd; i++)
if (pthread_join(tds[i], NULL) != 0)
err(1, "pthread_join");
- }
/* Print results. */
for (i = 0; i < f->n; i++)
diff --git a/c_os2/ex2/ex3_client.c b/c_os2/ex2/ex3_client.c
@@ -42,8 +42,8 @@ static void
usage(void)
{
fprintf(stderr, "usage: %1$s [-s sockfile]\n"
- " %1$s [-i [-p port]] [-s sockfile] hostname\n"
- " %1$s [-i [-p port]] [-s sockfile] ipv4_addr\n", argv0);
+ " %1$s -i [-p port] [-s sockfile] hostname\n"
+ " %1$s -i [-p port] [-s sockfile] ipv4_addr\n", argv0);
exit(1);
}
@@ -62,19 +62,16 @@ main(int argc, char *argv[])
char ch;
argv0 = *argv;
- /* Run on the UNIX domain by default. */
uflag = 1;
iflag = 0;
while ((ch = getopt(argc, argv, "ip:s:")) != -1) {
switch (ch) {
case 'i':
- /* Run the server on the internet domain. */
iflag = 1;
uflag = 0;
break;
case 'p':
- /* Choose custom port but don't use a well-known port. */
if ((port = atoi(optarg)) < 1024)
errx(1, "can't use port number < 1024");
break;
@@ -89,7 +86,6 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- /* If we're on the internet domain, we also need a hostname. */
if (iflag && argc < 1)
usage();
diff --git a/c_os2/ex2/ex3_server.c b/c_os2/ex2/ex3_server.c
@@ -131,8 +131,8 @@ static void
usage(void)
{
fprintf(stderr, "usage: %1$s [-b backlog] [-s sockfile]\n"
- " %1$s [-i [-p port]] [-b backlog] [-s sockfile] hostname\n"
- " %1$s [-i [-p port]] [-b backlog] [-s sockfile] ipv4_addr\n", argv0);
+ " %1$s -i [-p port] [-b backlog] [-s sockfile] hostname\n"
+ " %1$s -i [-p port] [-b backlog] [-s sockfile] ipv4_addr\n", argv0);
exit(1);
}
@@ -152,7 +152,7 @@ main(int argc, char *argv[])
char ch;
argv0 = *argv;
- /* Run on the UNIX domain by default. */
+ /* Run in the UNIX domain by default. */
uflag = 1;
iflag = 0;
@@ -168,7 +168,7 @@ main(int argc, char *argv[])
* sense, so we don't allow it either.
*/
if ((backlog = atoi(optarg)) < 1)
- usage();
+ errx(1, "backlog value must be greater than 1");
break;
case 'i':
/* Run the server on the internet domain. */
@@ -217,6 +217,7 @@ main(int argc, char *argv[])
sin.sin_family = AF_INET;
/* Convert the port number to network bytes. */
sin.sin_port = htons(port);
+
/*
* We'll try and see if the input is an IPv4 address. If
* inet_aton(3) does not fail, the user passed an IPv4 address.
@@ -225,10 +226,12 @@ main(int argc, char *argv[])
* addresses as arguments.
*/
if (!inet_aton(*argv, &sin.sin_addr)) {
- /* Get host info */
+ /*
+ * Get host info by hostname. The host's IPv4 address
+ * will be written to `hp->h_addr`.
+ */
if ((hp = gethostbyname(*argv)) == NULL)
errx(1, "gethostbyname(%s) failed", *argv);
- /* `hp->h_addr` has the host's IPv4 address. */
(void)memcpy(&sin.sin_addr, hp->h_addr, hp->h_length);
}
if (bind(sfd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
diff --git a/cpp_oop/game/Engine.cc b/cpp_oop/game/Engine.cc
@@ -12,10 +12,20 @@ enum Color {
/* TODO: intro message and stuff? */
Engine::Engine(const char *mapfile, const char *scorefile)
{
- if (!load_map(mapfile))
- throw "load_map failed: " + std::string(mapfile);
if (!init_curses())
throw "init_curses failed";
+ /*
+ * We'll use exceptions here because we want to display a useful
+ * error message since `load_map` has many points of failure.
+ * If we do catch an exception, we'll just "forward" it to `main`.
+ */
+ try {
+ load_map(mapfile);
+ } catch (std::runtime_error& e) {
+ throw "load_map failed: " + std::string(mapfile) + ": " + e.what();
+ }
+ if (!init_gamewin())
+ throw "init_gamewin failed";
if (!init_entities())
throw "init_entities failed";
if (!init_score(scorefile))
@@ -38,41 +48,10 @@ Engine::~Engine()
/* Private methods */
-/* XXX: getline? */
-bool
-Engine::load_map(const char *mapfile)
-{
- std::ifstream f;
- std::vector<char> row;
- char c;
-
- f.exceptions(std::ifstream::badbit);
- f.open(mapfile);
- if (!f.is_open())
- return false;
- while (f.get(c)) {
- if (f.eof())
- break;
- row.push_back(c);
- if (c == '\n') {
- /* XXX: h != hprev */
- w = row.size();
- map.push_back(row);
- row.clear();
- }
- }
- f.close();
- h = map.size();
-
- return true;
-}
-
/* Initialize curses(3) environment */
bool
Engine::init_curses()
{
- int wr, wc, wy, wx;
-
if (!initscr())
return false;
noecho();
@@ -84,19 +63,7 @@ Engine::init_curses()
set_escdelay(0);
/* Don't wait for a keypress, just continue if there's nothing. */
timeout(1000);
-
- xmax = getmaxx(stdscr);
- ymax = getmaxy(stdscr);
-
- wr = h;
- wc = w;
- wy = CENTER(ymax, wr);
- wx = CENTER(xmax, wc);
- if ((gw = newwin(wr, wc, wy, wx)) == NULL)
- return false;
- box(gw, 0, 0);
- wxmax = getmaxx(gw);
- wymax = getmaxy(gw);
+ (void)getmaxyx(stdscr, ymax, xmax);
colors.push_back(COLOR_BLUE); /* Wall */
colors.push_back(COLOR_RED); /* Path */
@@ -113,6 +80,69 @@ Engine::init_curses()
}
bool
+Engine::init_gamewin()
+{
+ int wr, wc, wy, wx;
+
+ wr = h;
+ wc = w;
+ wy = CENTER(ymax, wr);
+ wx = CENTER(xmax, wc);
+ if ((gw = newwin(wr, wc, wy, wx)) == NULL)
+ return false;
+ box(gw, 0, 0);
+ (void)getmaxyx(gw, wymax, wxmax);
+
+ return true;
+}
+
+void
+Engine::load_map(const char *mapfile)
+{
+ std::ifstream f;
+ std::string str;
+ std::size_t l;
+ int curline = 1;
+
+ f.exceptions(std::ifstream::badbit);
+ f.open(mapfile);
+ if (!f.is_open())
+ throw std::runtime_error("cannot open file");
+ /*
+ * Read first row outside the loop so we can get an initial
+ * row length.
+ */
+ if (!std::getline(f, str))
+ throw "cannot read first row";
+ map.push_back(str);
+ l = str.length();
+ while (std::getline(f, str)) {
+ /*
+ * If a row happens to have a different length, the map hasn't
+ * been written properly, so we exit. All rows have be
+ * have the same length.
+ */
+ if (l != str.length())
+ throw std::runtime_error("rows must have an equal "
+ "length: line " + std::to_string(curline));
+ map.push_back(str);
+ curline++;
+ }
+ f.close();
+ /*
+ * Since we got here, we know that number of columns is the same for
+ * every row, so we can now just take a random string and calculate its
+ * size in order to get the map's width.
+ */
+ w = map[0].length();
+ h = map.size();
+
+ /* The map has to fit in the screen. */
+ if (w > xmax || h > ymax - 2)
+ throw std::runtime_error("the map doesn't fit to screen");
+}
+
+bool
Engine::collides_with_wall(int x, int y)
{
if (x < w && y < h)
@@ -337,7 +367,7 @@ Engine::redraw()
if (c == '*')
color = COLOR_PAIR(Color::WALL);
else if (c == ' ')
- color = COLOR_PAIR(Color::PATH);
+ color = COLOR_PAIR(Color::PATH);
wattron(gw, color);
waddch(gw, c);
wattroff(gw, color);
diff --git a/cpp_oop/game/Engine.hpp b/cpp_oop/game/Engine.hpp
@@ -8,6 +8,7 @@
#include <iostream>
#include <fstream>
#include <map>
+#include <stdexcept>
#include <string>
#include <vector>
@@ -28,7 +29,7 @@ class Engine {
private:
std::vector<Movable *> entities;
- std::vector<std::vector<char>> map;
+ std::vector<std::string> map;
std::vector<int> colors;
Potter *player;
Score *score;
@@ -54,8 +55,9 @@ public:
bool is_running();
private:
- bool load_map(const char *mapfile);
bool init_curses();
+ bool init_gamewin();
+ void load_map(const char *mapfile);
void calc_pos(int *x, int *y);
bool init_entities();
bool init_score(const char *scorefile);
diff --git a/cpp_oop/game/main.cc b/cpp_oop/game/main.cc
@@ -43,7 +43,7 @@ main(int argc, char *argv[])
try {
eng = new Engine(mapfile, scorefile);
- } catch (std::string e) {
+ } catch (const std::string& e) {
die(e);
}
while (eng->is_running()) {
diff --git a/cpp_oop/game/map b/cpp_oop/game/map
@@ -1,45 +0,0 @@
-**********************************************************************************************************************************************
-********************** ******************************************************************************************************
-*************************************** ************************ **************************************************************************
-*************************************** ****************** *****************************************************************************
-*************************************** ************ ***********************************************************************************
-* **************** ****** ****************************************************************************************
-********************* **************** ** ************************ **********************
-********************* **************** ***************************** ********************************** *********** **********************
-********** **************** ******************************** ********************************** *********** **********************
-********************** **************** ******************************** ********************************** *********** **********************
-********************** **************** ******************************* ********************************** *********** **********************
-********************** ***************** ********************************** *********** **********************
-********************** ************************************************* ********************************** *********** **********************
-********************** ************************************************* ********************************** *********** **********************
-********************** ************************************************* ********************************** *********** **********************
-********************** ************************************************* ********************************** *********** **********************
-********************** ************************************************* ********* *********** **********************
-********************** ********* ************************ ***********
-*********************** ********** *********************************************** ************************ **********************************
-*********************** ********** *********************************************** ************************ **********************************
-*********************** ********** *********************************************** ************************ **********************************
-************ ********** ******************** **********************************
-************ ********************* ******************** **************************************************************************************
-************ ********************* ******************* **************************************************************************************
-************ ********************* **************************************************************************************
-************ ****************************************** **************************************************************************************
-************ ****************************************** **************************************************************************************
-************ ****************************************** **************************************************************************************
-************ *************************** *** **************************************************************************************
-************ *************************** * ******* **************************************************************************************
-************ *************************** ************** *********************************
-************ *************************** ******************************************************************* *********************************
-************ *************************** ******************************************************************* *********************************
-************ *************************** ******************************************************************* *********************************
-************ *************************** ******************************************************************* *********************************
-************ ******************************************************************* *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
-************************************************************************************************************ *********************************
diff --git a/cpp_oop/game/res/map1 b/cpp_oop/game/res/map1
@@ -0,0 +1,41 @@
+**********************************************************************************************************************************************
+********************** ******************************************************************************************************
+*************************************** ************************ **************************************************************************
+*************************************** ****************** *****************************************************************************
+*************************************** ************ ***********************************************************************************
+* **************** ****** ****************************************************************************************
+********************* **************** ** ************************ **********************
+********************* **************** ***************************** ********************************** *********** **********************
+********** **************** ******************************** ********************************** *********** **********************
+********************** **************** ******************************** ********************************** *********** **********************
+********************** **************** ******************************* ********************************** *********** **********************
+********************** ***************** ********************************** *********** **********************
+********************** ************************************************* ********************************** *********** **********************
+********************** ************************************************* ********************************** *********** **********************
+********************** ************************************************* ********************************** *********** **********************
+********************** ************************************************* ********************************** *********** **********************
+********************** ************************************************* ********* *********** **********************
+********************** ********* ************************ ***********
+*********************** ********** *********************************************** ************************ **********************************
+*********************** ********** *********************************************** ************************ **********************************
+*********************** ********** *********************************************** ************************ **********************************
+************ ********** ******************** **********************************
+************ ********************* ******************** **************************************************************************************
+************ ********************* ******************* **************************************************************************************
+************ ********************* **************************************************************************************
+************ ****************************************** **************************************************************************************
+************ ****************************************** **************************************************************************************
+************ ****************************************** **************************************************************************************
+************ *************************** *** **************************************************************************************
+************ *************************** * ******* **************************************************************************************
+************ *************************** ************** *********************************
+************ *************************** ******************************************************************* *********************************
+************ *************************** ******************************************************************* *********************************
+************ *************************** ******************************************************************* *********************************
+************ *************************** ******************************************************************* *********************************
+************ ******************************************************************* *********************************
+************************************************************************************************************ *********************************
+************************************************************************************************************ *********************************
+************************************************************************************************************ *********************************
+************************************************************************************************************ *********************************
+************************************************************************************************************ *********************************
diff --git a/cpp_oop/game/res/map2 b/cpp_oop/game/res/map2
@@ -0,0 +1,20 @@
+*********************************************************************
+* *
+* *
+********* ******* *** ******* ***** ********
+* * * * ************ *
+* * * * * * * *
+* *
+* * * * ***** *
+************************ * * * * *
+* * ************** * * *
+* ********************* * * * *
+* * * * * *
+* **** *** * * * * *
+* * * * * * * * *
+* * * * * * * *
+* * * * * * ********
+* * * *** ****** * * *
+* ********** ***** ******** * *
+* * *
+*********************************************************************
diff --git a/cpp_oop/game/res/map3 b/cpp_oop/game/res/map3
@@ -0,0 +1,20 @@
+*********************************************************************
+* *
+* ***************** *
+**************************** * * *
+* * * * ***** ***** ***** **
+* * * * * * *
+* ******* ****** ******* * * * * *
+* * * * * * *
+************************ * * * * * *
+* * ****** * * *
+* * ************************ * * * * *
+* * * * * *
+* * ****** *** ************* *** * *
+* * * * * * * *
+* * * * * * * *
+* * * * * * * *
+* * * * * * * *
+* ********** ********** ************* * * *
+* * *
+*********************************************************************
diff --git a/cpp_oop/game/score b/cpp_oop/game/res/score