Let's do it. Too much talk already. We should try different approaches and see which one is best, imho. But obviously nothing will satisfy all people. So let's go with something workable for the majority.
What I have so far for the learning algorithm.
$optionOne = $_POST['option1']
$optionTwo= $_POST['option2']
$TotalIssuesVotedOn = file_get_contents("MasterVoteCount.txt");
$DataOne = unserialize(file_get_contents($optionOne . ".txt"));
$VotesOne = array_sum($DataOne['weight']) ;
$DataTwo = unserialize(file_get_contents($optionTwo . ".txt"));
$VotesTwo = array_sum($DataTwo['weight'])
if($VotesTwo < $VotesOne)
{
echo "Option One Wins";
$split = 1 - $VotesOne ($VotesTwo + $VotesOne);
$BankA = $DataOne['account'];
$newData = serialize($BankA);
file_put_contents("BankA" . $TotalIssuesVotedOn . ".txt", $newData);
}
else
{
$split = 1 - $VotesTwo ($VotesTwo + $VotesOne);
echo "Option Two Wins";
$BankA = $DataTwo['account'];
$newData = serialize($BankA);
file_put_contents("BankA" . $TotalIssuesVotedOn . ".txt", $newData);
}
$splitfilename = "Issue" . "$TotalIssuesVotedOn" . "/split.txt";
file_put_contents($splitfilename, $split);
file_put_contents("MasterVoteCount.txt", $TotalIssuesVotedOn);
if($TotalIssuesVotedOn < 4)
{
echo "completed";
}
else
{
$var_a = $TotalIssuesVotedOn - 1
$var_b = $TotalIssuesVotedOn - 2
$var_c = $TotalIssuesVotedOn - 3
$splitA = file_get_contents("Issue" . "$TotalIssuesVotedOn" . "/split.txt");
$splitB = file_get_contents("Issue" . "$var_a" . "/split.txt");
$splitC = file_get_contents("Issue" . "$var_b" . "/split.txt");
$splitD = file_get_contents("Issue" . "$var_c" . "/split.txt");
$Bank1 = file_get_contents("BankA" . $TotalIssuesVotedOn . ".txt");
$Bank2 = file_get_contents("BankA" . $var_a . ".txt");
$Bank3 = file_get_contents("BankA" . $var_b . ".txt");
$Bank4 = file_get_contents("BankA" . $var_c . ".txt");
$AllBanks = array( $Bank1,
$Bank2,
$Bank3,
$Bank4
);
$SimilarAccounts = call_user_func_array('array_intersect',$AllBanks);
$var_d = array_sum($SimilarAccounts);
$similarityAdded = .1 ($splitA * $splitB * $splitC * $splitD);
$var_e = 0;
while ($var_e < ($var_d - 1))
{
$similarityModifier = file_get_contents($SimilarAccounts[$var_e] . "/similarity.txt");
$similarityModifier = $similarityModifier + $similarityAdded;
file_put_contents($SimilarAccounts[$var_e] . "/similarity.txt", $similarityModifier);
$var_e = $var_e + 1;
}
}
$TotalIssuesVotedOn = $TotalIssuesVotedOn + 1;
And for the addition of votes...
$accountNumber = $_POST['account']
$option = $_POST['option']
$TotalIssuesVotedOn = file_get_contents("MasterVoteCount.txt");
$similarityModifier = file_get_contents($accountNumber . "/similarity.txt");
$accountBalance = file_get_contents($accountNumber . "/balance.txt");
$accountAge = file_get_contents($accountNumber . "/age.txt");
$nxtAge = something goes here;
<!-- Times voted is retrieved and updated ---!>
$filename = "$accountNumber" . "/timesvoted.txt";
if (file_exists($filename))
{
$oldData = file_get_contents($filename);
$newData = $oldData + 1;
file_put_contents($filename, $newData);
}
else
{
$newData = 1;
file_put_contents($filename, $newData);
}
<!-- Times voted is retrieved and updated ---!>
$TimesVoted = file_get_contents("$accountNumber" . "/timesvoted.txt");
$TotalIssuesVotedOn = file_get_contents("MasterVoteCount.txt");
<!-- Account is added to vote ---!>
$votes = '';
$filename = $TotalIssuesVotedOn . "/" . $option . "votes.txt";
if (file_exists($filename))
{
$oldData = unserialize(file_get_contents($filename));
$oldData = array();
$oldData['account'] = $accountNumber;
$oldData['weight'] = ( 1 ( $similarityModifier + 1 ) ) ^ (5/4) * ( $accountAge ) ^ 2 ( $accountBalance ) ^ (1/3)
$newData = serialize($oldData);
file_put_contents($filename, $newData);
}
else
{
$oldData = array();
$oldData['account'] = $accountNumber;
$oldData['weight'] = ( 1 ( $similarityModifier + 1 ) ) ^ (5/4) * ( $accountAge ) ^ 2 ( $accountBalance ) ^ (1/3)
$newData = serialize($oldData);
file_put_contents($filename, $newData);
}
<!-- Account is added to vote ---!>