How to Create a High Score List

This feature is available in Broadcast Pro and Broadcast Enterprise only.

Forio Broadcast Pro and Broadcast Enterprise allow you to store a Score model variable (which must be named Score) and up to four other model variables (named Metric1, Metric2, Metric3, and Metric4).  

Example of a Simple High Score List

For example, you might have the four metrics be based on revenue, customer satisfaction, employee satisfaction, and production, while Score is an amalgamate of those items.

In addition to saving high scores, you can also store text information using the Message Fields and display them with the reference $Score.Run.Messages.  For example, you might save answers to the questions "What is your planned strategy?", "Describe your strategy", and "How did your strategy work out?"

If the simulation player is a logged-in user you can access their account information with $Score.EndUser.  For public simulations (no usernames or passwords), store the name with a message field.

Broadcast Pro and Enterprise allow you to store 5 pieces of numeric information related to high scores:

Variable Name

Example

Score

V Score = Cumulative Profit

Metric1

V Metric1 = Market Share

Metric2

V Metric2 = Product Quality

Metric3

V Metric3 = Employee Morale

Metric4

V Metric4 = Customer Satisfaction

 

Example text information you might want to store

Message Key

Field Name

Example

Name

M_Name

"Sam Jones"

Email

M_Email

"sjones@sjones.com"

Strategy

M_Strategy

"My strategy was successful at increasing market share, but my company lost a lot of money."

 

Every game played by the user allows you to store some or all of this information, which can then be displayed in a "High Score List".

Posting High Scores

You need to provide a mechanism to capture high score information. This can either be done automatically or controlled by the simulation user.

Example of a Simple High Score Input Form

To post high scores, follow these four steps:

Step 1: Create a Form

Set the form method to "post". Set the action to the web page you would like the user to link to after the submit button is pressed.

<FORM method="POST" ACTION="displayscorelist.htm">

ACTION="displayscorelist.htm" takes the user to the high score page after the user's high score has been posted to the database.  

Step 2: Create a Text Box or Text Area

Name the fields M_Email, M_Name, or M_Strategy.

<input type="text" name="M_Name">

<input type="text" name="M_Email">

<textarea name="M_Strategy" cols="56" rows="4" wrap=virtual></textarea>

 

Setting the text box name to a field name that starts with "M_" tells Broadcast to save that info for this run.

Step 3: Create a Hidden FD_action Field.

Name it FD_action and set its value to post_score.

<input type="hidden" name="FD_action" value="post_score">

This tells Broadcast to save the score and the metrics when the submit button is pressed.

Step 4: Create a Submit Button

Create a submit button with the value Submit Decisions

<input type="submit" value="Submit Strategy">

This lets your users press 'Submit Strategy after they have described their strategy.

 

Retrieving High Scores

After high scores are posted, you can retrieve them and list the high scores. You can name your high score web page anything you like.  For example, to create a high score link, you could use:

<A HREF="#Link('displayscorelist.htm')">View High Scores</A>

Scores are retrieved from the $ScoreList collection, which contains all the high score information for all simulation users. A simple web page that retrieves high scores looks like this:

 

#foreach ($Score in $ScoreList)
<B>High Score: $!Score.FormattedScore</B><BR>
Date of High Score: $!Formatter.fullDate($Score.Run.LastModified)<BR>
Total Revenue: $!Score.FormattedMetric1<BR>
Name: $!Score.Run.Messages.get("Name")<BR>    
Email: $!Score.Run.Messages.get("Email")<BR>    
Strategy: $!Score.Run.Messages.get("Strategy")<BR><BR>
#end
 

 

Moving from Page to Page

The reference $ScoreList is a paged list, which means that by default, only 10 rows are shown at a time.  You can use the URL page parameters FD_row_offset to set the index of the first row to display, and FD_row_display to determine how many rows to display a time.  For example, the following URL will display rows 11 to 20.

<A HREF="#Link('displayscorelist.htm?FD_row_offset=10')">Next</A>

To make it easier to create links that will move back and forth among the pages, use the special paged list properties HasPrevious, HasNext, PreviousOffset, and NextOffset.  The following example shows how to create links to move to the previous page or next page.

 

#if($ScoreList.HasPrevious)
<a href="displayscorelist.htm?FD_row_offset=$ScoreList.PreviousOffset">&lt;&lt; Prev</a>
#end

#if($ScoreList.HasNext)
<a href="displayscorelist.htm?FD_row_offset=$ScoreList.NextOffset">Next&gt;&gt;</a>
#end
 

 

Setting the URL page parameter FD_row_display determines how many rows to display at a time.  Setting this to a value of -1 will list all rows.

<A HREF="#Link('displayscorelist.htm?FD_row_display=-1')">Show all scores</A>

 

Clearing Your High Score List

To clear the high score list, do the following:

Log-in to your Broadcast manager account.

Select User Access » Clear Scores from the menubar.

Click the Clear List button.

All user simulation scores will be removed from the database.

 

High Score Information Available Through Broadcast

Broadcast stores several fields that can be retreived through the $ScoreList object. Extra data about users is stored if the user has logged-in to a password-protected simulation.

To access high score information, use a #foreach loop on the $ScoreList collection. For example:

#foreach ($Score in $ScoreList)

   [insert $Score references here]

#end

Public High Score References

Reference

Description

$Score.Score

Score as an unformatted number.

$Score.Metric1

Metric 1 as an unformatted number.

$Score.Metric2

Metric 2 as an unformatted number.

$Score.Metric3

Metric 3 as an unformatted number.

$Score.Metric4

Metric 4 as an unformatted number.

$Score.FormattedScore

Formatted Score. The format for score is determined in the model equations. Example:

P Score.NumberFormat = "$#,##0"

$Score.FormattedMetric1

Formatted Metric1. The format for Metric1 is determined in the model equations. Example:

P Metric1.NumberFormat = "#,##0"

$Score.FormattedMetric2

Formatted Metric2. The format for Metric2 is determined in the model equations. Example:

P Metric2.NumberFormat = "#,##0"

$Score.FormattedMetric3

Formatted Metric3. The format for Metric3 is determined in the model equations. Example:

P Metric3.NumberFormat = "#,##0"

Useful $Run Properties

You can also use all $Run references in a high score list.  Here's a couple of commonly used references.

Reference

Description

$Score.Run.LastModified

The date the run was last simulated

$Score.Run.SimTime

The final time of the simulation run

$Score.Run.Messages

A keyed list of saved simulation text

$Score.Run.MultiLineMessages

 

A keyed list of saved simulation text, with carriage returns converted to <BR> tags

 

Additional References for Password-Protected Simulations

Reference

Description

$!Score.Run.EndUser.LoginId

The simulation user's log-in name or account name.

$!Score.Run.EndUser.FirstName

The first name of the simulation user The first name, last name, and email address are set by the facilitator from the Broadcast menu bar at User Access >> Manage Users

$!Score.Run.EndUser.LastName

The last name of the simulation user The first name, last name, and email address are set by the facilitator from the Broadcast menu bar at User Access >> Manage Users

$!Score.Run.EndUser.Email

The last name of the simulation user The first name, last name, and email address are set by the facilitator from the Broadcast menu bar at User Access >> Manage Users

 

Example High Score List

Download and unzip the following three files to create a sample high score list.

http://www.forio.com/broadcastdocs/downloads/highscore.zip

To try the high score list sample, first upload the Forio model located in model.txt.

Contents of model.txt file:
 

## Simple High Score Model Example

M StartTime = 2005
M EndTime = 2008

D Price = 10

V Sales = 10000
V Costs = 40000
V Revenue = Price * Sales
V Profit = Revenue - Costs
V Cumulative Profit = ACCUM(Profit)

V Score = Cumulative Profit
V Metric1 = Price
 

 

Next, upload the web pages index.htm and displayscorelist.htm to your Broadcast interface directory.

Simulating the model and posting the high scores is controlled by index.htm.

Contents of index.htm:
 

<html>
<head>
<title>Run Simulation</title>
<script type="text/javascript" src="/tools/forio.js"></script>
</head>

<body>

Year: $Run.SimTime<BR><BR>

<FORM NAME="Decisions" METHOD="POST" ACTION="index.htm">
<INPUT NAME="D_Price" TYPE="TEXT" VALUE="$Values.get('Price').DecisionFormatted">
<INPUT NAME="FD_action" TYPE="HIDDEN" VALUE="reset_and_step_toend">
<INPUT TYPE="SUBMIT" VALUE="Run Simulation">
</FORM>

Cumulative Profit = $Values.get('Cumulative Profit')
<BR><BR>
#if($Run.EndStep == $Run.SimStep)

<H1>Post Your Score</h1>
<FORM method="POST" action="displayscorelist.htm">

Name<BR>
<input type="text" name="M_Name"><BR><BR>

Email<BR>
<input type="text" name="M_Email"><BR><BR>

Describe Your Strategy<BR>
<textarea name="M_Strategy" cols="56" rows="4" wrap=virtual></textarea><BR>
<input type="hidden" name="FD_action" value="post_score">

<input type="submit" name="submit" value="Save Score Information">

</FORM>

#end

<A HREF="displayscorelist.htm">Show High Scores</A>

</body>
</html>
 

 

Displaying high scores is done by displayscorelist.htm.

Contents of displayscorelist.htm:
 

<HTML>
<HEAD>
<TITLE>List High Scores</TITLE>
<script type="text/javascript" src="/tools/forio.js"></script>
</HEAD>

<BODY>
<H1>High Score List</H1>
<P><A HREF="#Link('index.htm?FD_action=reset')">Return to Simulation</A></P>
<P>Displaying $ScoreList.FirstRowIndex to $ScoreList.LastRowIndex of $ScoreList.TotalRows<BR>
<A href="#Link('displayscorelist.htm?FD_row_display=-1')">display all rows</A>

<P>
<TABLE  width="100%" cellspacing="0" cellpadding="5" border="1">
<TR>
<TH>&nbsp;</TH>
<TH>Date</TH>
<TH>Price</TH>
<TH>Score</TH>
<TH>Name</TH>
<TH>Email</TH>
<TH>Strategy</TH>
</TR>

#foreach ($Score in $ScoreList)
#set($RowIndex = $ScoreList.RowOffset + $foreachCount)
<TR>
<TD>$RowIndex</TD>
<TD nowrap>$!Formatter.fullDate($Score.Run.LastModified) &nbsp;</TD>
<TD nowrap>$!Score.FormattedMetric1 &nbsp;</TD>
<TD nowrap>$!Score.FormattedScore &nbsp;</TD>
<TD nowrap>$!Score.Run.Messages.get("Name") &nbsp;</TD>
<TD nowrap><A HREF="mailto:$!Score.Run.Messages.get("Email"))">
$!Score.Run.Messages.get("Email")</A> &nbsp;</TD>
<TD>$!Score.Run.MultiLineMessages.get("Strategy") &nbsp;</TD>
</TR>
#end

</TABLE>

<P>
#if($ScoreList.HasPrevious)
  <a href="displayscorelist.htm?FD_row_offset=$ScoreList.PreviousOffset">&lt;&lt; Prev</a>
#end
#if($ScoreList.HasNext)
<a href="displayscorelist.htm?FD_row_offset=$ScoreList.NextOffset">Next&gt;&gt;</a>
#end

</BODY>
</HTML>