diff options
| author | Aiden Woodruff <woodra@rpi.edu> | 2025-11-16 23:38:16 -0500 |
|---|---|---|
| committer | Aiden Woodruff <woodra@rpi.edu> | 2025-11-16 23:38:16 -0500 |
| commit | f7d2e7c8a70e4d96c5cbc4e8774599f351e59216 (patch) | |
| tree | 214525435c077203944fdaa0a273801f5b381aea /src/NameGame.h | |
| parent | e3b2c19dae58430823913c5b6dc0e45617ca6116 (diff) | |
| download | tipping-points-f7d2e7c8a70e4d96c5cbc4e8774599f351e59216.tar.gz tipping-points-f7d2e7c8a70e4d96c5cbc4e8774599f351e59216.tar.bz2 tipping-points-f7d2e7c8a70e4d96c5cbc4e8774599f351e59216.zip | |
add strategy_record
- src/NameGame.h: add strategy record as vector of tuples.
- src/NameGame.cc (runRound): remove each round printout but update the
strategy record.
- fix speaker memory update.
- (clearRecord): add function.
- (writeRecord): add function to output CSV file with record info.
- (NameGame::run): print average strategy.
- src/main.cc: clear memory and run 1000 rounds.
- TASKS.md: update tasks
Signed-off-by: Aiden Woodruff <woodra@rpi.edu>
Diffstat (limited to 'src/NameGame.h')
| -rw-r--r-- | src/NameGame.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/NameGame.h b/src/NameGame.h index 8a817ce..73f5630 100644 --- a/src/NameGame.h +++ b/src/NameGame.h | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | #define TIPPING_POINTS_NAMEGAME_H | 2 | #define TIPPING_POINTS_NAMEGAME_H |
| 3 | 3 | ||
| 4 | #include <random> | 4 | #include <random> |
| 5 | #include <tuple> | ||
| 6 | #include <vector> | ||
| 5 | 7 | ||
| 6 | #include <Snap.h> | 8 | #include <Snap.h> |
| 7 | 9 | ||
| @@ -15,7 +17,9 @@ public: | |||
| 15 | 17 | ||
| 16 | void initGraph(); | 18 | void initGraph(); |
| 17 | void initMemory(); | 19 | void initMemory(); |
| 20 | void clearRecord(); | ||
| 18 | void run(int rounds); | 21 | void run(int rounds); |
| 22 | void writeRecord(const char* fname); | ||
| 19 | 23 | ||
| 20 | protected: | 24 | protected: |
| 21 | int best_move(int nId) const; | 25 | int best_move(int nId) const; |
| @@ -27,6 +31,7 @@ private: | |||
| 27 | std::mt19937 rng; | 31 | std::mt19937 rng; |
| 28 | std::uniform_int_distribution<> dist; | 32 | std::uniform_int_distribution<> dist; |
| 29 | TNodeNet<TPair<TBool, TIntV>> graph; | 33 | TNodeNet<TPair<TBool, TIntV>> graph; |
| 34 | std::vector<std::tuple<int, int, int, int> > strategy_record; | ||
| 30 | }; // class NameGame | 35 | }; // class NameGame |
| 31 | 36 | ||
| 32 | } // namespace tp | 37 | } // namespace tp |
