aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAiden Woodruff <woodra@rpi.edu>2025-10-23 17:39:32 -0400
committerAiden Woodruff <woodra@rpi.edu>2025-10-23 17:39:32 -0400
commitb334559cd0f76d3cf2b7d500c5c052c59e24da66 (patch)
tree7e605cb450dd3aa55b7aa6ba3909803cefd8be8a /src
parent95e330a784ffa85fa97ffcd5554f388af57c50b2 (diff)
downloadtipping-points-b334559cd0f76d3cf2b7d500c5c052c59e24da66.tar.gz
tipping-points-b334559cd0f76d3cf2b7d500c5c052c59e24da66.tar.bz2
tipping-points-b334559cd0f76d3cf2b7d500c5c052c59e24da66.zip
experiment starter and skeleton
- main.cc (main): add experimental group size variable. - (name_game): construct complete graph with some commited minority. - add comments for other steps. Signed-off-by: Aiden Woodruff <woodra@rpi.edu>
Diffstat (limited to 'src')
-rw-r--r--src/main.cc50
1 files changed, 48 insertions, 2 deletions
diff --git a/src/main.cc b/src/main.cc
index 0c1177d..467c1ad 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -1,9 +1,55 @@
1#include <cassert>
1#include <iostream> 2#include <iostream>
3#include <random>
2 4
3#include <Snap.h> 5#include <Snap.h>
4 6
7void name_game(int group_size, int cmsize);
8
5int main(int argc, char* argv[]) { 9int main(int argc, char* argv[]) {
6 PNGraph g = TNGraph::New(); 10 int group_size = 100;
7 g = TNGraph::New(); 11 for (int cmperc = 18; cmperc < 28; cmperc += 2) {
12 int cmsize = group_size * cmperc / 100;
13 std::cout << "CM " << cmsize << " / " << group_size << std::endl;
14 name_game(group_size, cmsize);
15 }
8 return 0; 16 return 0;
9} 17}
18
19// SNAP random chooses node, r is used to select one edge
20template <typename TD>
21typename TNodeNet<TD>::TEdgeI random_edge(const TNodeNet<TD>& g, int r) {
22 auto ni = g.GetRndNI();
23 return g.GetEI(ni.GetId(), ni.GetNbrNId(r % ni.GetDeg()));
24}
25
26void name_game(int group_size, int cmsize) {
27 assert(cmsize > 0 && group_size > 0);
28 assert(cmsize < group_size);
29 TNodeNet<TPair<TBool, TIntV>> graph;
30 // Generate complete graph.
31 for (int i = 0; i < group_size; ++i) graph.AddNode(i, {false, {}});
32 for (int i = 0; i < group_size; ++i)
33 for (int j = 0; j < group_size; ++j)
34 if (i != j) graph.AddEdge(i, j);
35 // Set committed minority.
36 std::mt19937 rnd(std::random_device{}());
37 std::uniform_int_distribution dist(0, group_size - 1);
38 for (int i = 0; i < cmsize;) {
39 int r = dist(rnd);
40 if (!graph.GetNDat(r).Val1) {
41 graph.GetNDat(r).Val1 = true;
42 ++i;
43 }
44 }
45 std::cout << "Nodes: " << graph.GetNodes()
46 << " Edges: " << graph.GetEdges() << std::endl;
47
48 // Select random edge.
49 // Speaker chooses best strategy.
50 // Listener updates memory.
51 // Listener chooses best strategy.
52 // Speaker updates memory.
53 // Track all plays and plays by non-CM.
54 // Report average plays.
55}