1. mcc
  2. universe

Commits

mcc  committed a31b291

MarkovModel practically usable from lua

  • Participants
  • Parent commits 155f690
  • Branches default

Comments (0)

Files changed (3)

File PolycodeTemplate/PolycodeTemplateApp.mm

View file
 	terminal->inject_global("line_height",	  terminal->line_height);
 #endif
 	
-	(new room_auto("media/title.svg"))->insert();
+	(new room_auto("media/starfield.svg"))->insert();
 }
 
 PolycodeTemplateApp::~PolycodeTemplateApp() {

File source/markov.cpp

View file
 
 MarkovModel::MarkovModel(int _cap) : cap(_cap) {}
 
-void MarkovModel::hit(const string &found) {
-	if (!record.count(found)) {
-		record[found] = 1;
-	} else {
-		record[found]++;
-	}
-}
-
 int MarkovModel::hits(const string &found) {
 	if (!record.count(found)) {
 		return 0;

File source/markov.h

View file
 
 #include "program.h"
 
+// Notice: lua friendly function first, c++ friendly function second.
 struct MarkovModel {
-	void hit(const string &found);
+	int hits(String found) { return hits(found.getSTLString()); }
 	int hits(const string &found);
+	void loadTraining(String inp) { loadTraining(inp.getSTLString()); }
 	void loadTraining(const string &inp);
+	void loadTrainingFile(String &inp) { loadTrainingFile(inp.getSTLString()); }
 	void loadTrainingFile(const string &inp);
+	Number probability(String of, String history) { return probability(of[0], history.getSTLString()); }
 	double probability(char of, const string &history);
 	MarkovModel(int _cap);
 protected: