Location: PHPKode > scripts > Odds algorithm > odds-algorithm/example.php
```<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="xhtml, css, html, printing, template" />
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<title>Oods Algorithm</title>

<body>

<div style="width: 80%; position:absolute; left:10%; top:0%; z-index:1">
<br />
<div class="tabArea" align="center">
<a class="tab" href="example.php">Example</a>
<a class="tab" href="source.php">Class</a>
<a class="tab" href="http://www.math.ucla.edu/~tom/Stopping/sr2.pdf" target="_blank">Theory</a>
</div>

<div class="Paragraph">

<h2> The good reasoned choice...</h2><br />

<img src="images/thumb.png" alt="Khaled Al-Sham'aa" border="0" width="200" height="150" />
</div>
<p>
<span class="FirstChar">H</span>ow to make the good decision? A mathematical method of simple
formulation and easy application allows us to optimize our choices, in the everyday life as at
the time of serious conflicts.
</p>
<p>
The problem is defined as a dynamic process that includes two decision makers (DMs) in the selection
of the same offer. A sequence of a prefixed number of (n) offers is observed, one at a time, randomly.
The arrival of offers does not follow any probability distribution. Hence, each DM should rank the
currently observed offers among those already observed. Two kinds of ranks follow: relative and absolute ranks.
</p>
<p>
At each stage of the dynamic process, an offer can be accepted or discarded.
Each discarded offer cannot be re-examined in later stages. We assume that each DM
has his individual utility and ranking for the selected offer. Since the rankings of
the DMs are different, a conflict can arise when an offer is accepted by either DM and
refused by his opponent. In this case, a stopping rule should be defined in order to avoid such situations.
</p>

<h2>Example Game Rules</h2>
<p>
Numbers are generated by sequences of random produced by independent draws from a given
range (between 1 and 6 in this example). The law of drawing different numbers or expressions
may be time-invariant (stationary) or else depend on time. For a fixed n (in this case n=12 available events)
and a given pattern (here we are looking for appearance of number 6) our goal is to maximize the probability
of stopping on the k(th) last appearance of number 6 (if any) in such events of total n, given that we must
not return on a previous appearance of 6.
</p>

<ul>
<?php
include('oods.class.php');

\$x = new Oods(12, '1/6');

for(\$i=1; \$i<=12; \$i++){
if(ceil(rand(0, 6)) == 6){ \$good=true; }else{ \$good=false; }
\$x->event(\$good);

list(\$accept, \$w) = \$x->doYouAccept();

if(\$accept == true && !\$select){
\$select = true;
\$chance = round(\$w*100, 0);
echo "<li><b><font color='blue'>Accept in turn k=\$i where chance to be the last appearance of number 6 is %\$chance</font></b></li>";
}else{
if(\$good && !\$select) echo "<li><font color='green'>Number 6 has been appeared at turn k=\$i, but we may get better!!</font></li>";
if(\$good && \$select)  echo "<li><font color='red'>Number 6 has been appeared again at turn k=\$i ... we miss it :(</font></li>";
}
}

if(!\$select) echo "<font color='red'>I am sorry, we loss all our chances!!</font><br />";

?>
</ul>
<center><a href="example.php">Try Again :o)</a></center>
</div><br /></div></body></html>```