netzen

Long-term probabilities in Monopoly™. An example

About the data This example uses netzen to visualize the long term probabilities of landing at each square of the Monopoly board.

To this end, I have created a data sets consisting on 41 squares, where an edge is created between two squares if there is a chance of moving from one square to another, based on dice rolls and the effects of the Chance and Community Chest cards. To simplify the model, I assume that a player always stays for three turns when he/she lands in jail.

This data set can be downloaded here: monopoly.txt.

To start with the monopoly example, load the table using the menu:
File/Import Table
and select the file monopolyUncertainty.txt The data for each square

About the analysis To obtain long term propabilities, I ran the eigenvector centrality
AnalysisTools/Centrality/EigenCentrality
using the field Probability as edge weight.

The result can then be mapped to color or size to reveal the squares with highest probability of landing.
About the view The view is a specific class tailored to the monopoly visualization. Its layout resembles the board game layout to retain the familiarity people have with the game.

The code can be downloaded here: src/extra/monopoly.cpp

A new view can be coded by adding a class that inherits from View:
   class MonopolyView: public View {
    public:
        MonopolyView(const char *title):View("MonopolyView", title) {
           // The constructor initializes the class and creates properties
        }
        virtual void setGraph(Graph *g) {
           // This is called when the controller creates the view. 
           // We overload this method here to compute derived properties based on
           // the original data.
        }
        virtual void render() {
          // this is the main rendering method. 
          //Use OpenGL to render primitives and render the data.
        }
        // The following can be overloaded to provide specific mouse interaction.
        virtual void click(float x, float y, int modifiers) {
        }
        virtual void release(float px, float py, int modifiers) {
        }
        virtual void drag(float px, float py, float dx, float dy, int modifiers) {
        }
    };
   

Once the class has been created, it is necessary to register it in netzen so that it will appear in the View menu. To do this, we must provide a View Creator function:
   View *createMonopolyView(string name) {
       MonopolyView* view = new MonopolyView(name.c_str());
       view->setLocation(0.0,0.0);
       view->setSize(1.0,1.0);
       view->setVisible(true);
       view->setVisualMapping(vm);
       view->addCloseButton();
       return view; 
   }
	   
And we register it, during initialization of the application, as follows:
     controller->addViewCreator("MonopolyView", createMonopolyView);
Using the view Now that a view creator has been added, we can create multiple Monopoly views and visualize different aspects of the data set.

In the View class, we can add a property of the View that specifies which variable should be visualized. This is done in the constructor, as follows:
    setPropertyStringList("Size", "Default", "node");
    setPropertyStringList("Color", "Default", "node");
These two lines state that the View contains two properties, Size and Color, whose values are obtained from the string list "node", which contains the names of all the node properties (as specified in the node table). These appear in the Inspector tab of the netzen GUI.
Questions? Send us an email. Bugs? Requests? Here's an idea: Help us grow netzen with your contributions.