aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAiden Woodruff <woodra@rpi.edu>2025-11-22 13:43:57 -0500
committerAiden Woodruff <woodra@rpi.edu>2025-11-22 13:43:57 -0500
commitdbc0fea0bdedbcca83e6d42b3d4f3363a2f0fba8 (patch)
tree34cab2589eb53dcd702d03146a9412d02930e193 /src
parent9a2e9932e79287a4bc54d383ea78e2a2468a8703 (diff)
downloadtipping-points-dbc0fea0bdedbcca83e6d42b3d4f3363a2f0fba8.tar.gz
tipping-points-dbc0fea0bdedbcca83e6d42b3d4f3363a2f0fba8.tar.bz2
tipping-points-dbc0fea0bdedbcca83e6d42b3d4f3363a2f0fba8.zip
split main executable into many and one
- src/main.cc: remove file. - src/one.cc: add executable to do a single game run and write the strategy record. - src/many.cc: add executable to run many trials at each minority size. - write adoption amount. Signed-off-by: Aiden Woodruff <woodra@rpi.edu>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt11
-rw-r--r--src/main.cc15
-rw-r--r--src/many.cc31
-rw-r--r--src/one.cc18
4 files changed, 57 insertions, 18 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 536e475..7e0e575 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,10 @@
1add_executable(main 1add_executable(one
2 main.cc 2 one.cc
3 NameGame.cc 3 NameGame.cc
4) 4)
5target_link_libraries(main PRIVATE SNAP::SNAP) 5target_link_libraries(one PRIVATE SNAP::SNAP)
6add_executable(many
7 many.cc
8 NameGame.cc
9)
10target_link_libraries(many PRIVATE SNAP::SNAP)
diff --git a/src/main.cc b/src/main.cc
deleted file mode 100644
index f8776eb..0000000
--- a/src/main.cc
+++ /dev/null
@@ -1,15 +0,0 @@
1#include <iostream>
2
3#include "NameGame.h"
4
5int main(int argc, char* argv[]) {
6 int group_size = 1000, cmsize = 292;
7 tp::NameGame namegame(group_size, cmsize, 12);
8 std::cout << "CM " << cmsize << " / " << group_size << std::endl;
9 int a = namegame.run(group_size * 1000);
10 std::cout << "Non-committed new strategy plays in the last N runs: " << a << std::endl;
11 namegame.writeRecord("strategy_record.csv");
12 return 0;
13}
14
15
diff --git a/src/many.cc b/src/many.cc
new file mode 100644
index 0000000..8844d04
--- /dev/null
+++ b/src/many.cc
@@ -0,0 +1,31 @@
1#include <iostream>
2#include <fstream>
3
4#include "NameGame.h"
5
6constexpr int group_size = 1000, T = 1000;
7constexpr int cmsize_min = 250, cmsize_max = 255;
8constexpr int trials = 10;
9
10int main(int argc, char* argv[]) {
11 tp::NameGame namegame(group_size, 0, 12);
12 std::vector<std::pair<int, int>> runs;
13 for (int i = cmsize_min; i <= cmsize_max; ++i) {
14 for (int j = 0; j < trials; ++j) {
15 namegame.setCMsize(i);
16 namegame.initMemory();
17 namegame.clearRecord();
18 int a = namegame.run(group_size * T);
19 runs.push_back({i, a});
20 }
21 std::cout << "finished cmsize " << i << std::endl;
22 }
23 std::ofstream f("many.csv");
24 f << "cmsize,adopters\n";
25 for (const auto& p : runs) {
26 f << p.first << ',' << p.second << '\n';
27 }
28 return 0;
29}
30
31
diff --git a/src/one.cc b/src/one.cc
new file mode 100644
index 0000000..42eb4a8
--- /dev/null
+++ b/src/one.cc
@@ -0,0 +1,18 @@
1#include <iostream>
2
3#include "NameGame.h"
4
5constexpr int group_size = 1000, cmsize = 292, memlen = 12;
6constexpr int T = 1000;
7constexpr const char* outfile = "strategy_record.csv";
8
9int main(int argc, char* argv[]) {
10 tp::NameGame namegame(group_size, cmsize);
11 std::cout << "CM " << cmsize << " / " << group_size << std::endl;
12 int a = namegame.run(group_size * T);
13 std::cout << "New strategy adoption in the last N runs: " << a << std::endl;
14 namegame.writeRecord(outfile);
15 return 0;
16}
17
18