Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 06-09-2008, 02:08 AM   #1 (permalink)
 
Newb Techie

Join Date: Jun 2008

Posts: 9

PHPisl33t is on a distinguished road

Send a message via AIM to PHPisl33t Send a message via MSN to PHPisl33t Send a message via Yahoo to PHPisl33t Send a message via Skype™ to PHPisl33t
Default Virtual Government

Hey,
I'm kind of stuck here, my boss asked me to make a Virtual Goverment "game" or should I say "nightmare" in PHP. Okay so there is a virtual congress and a president and vice president, I get how to take votes etc... but what messes me up is trying to figure out how to equationate/program elections and the randomness in government... anyway, yeah. I'm getting paid a pretty good amount of money for this and I'm getting a dedicated server paid for for free. So if someone is willing to help me out, I can give them a share of the server or possibly some money?

~Tyler
PHPisl33t is offline  
Old 07-13-2008, 08:32 PM   #2 (permalink)
 
Junior Techie

Join Date: Dec 2007

Posts: 45

jairic is on a distinguished road

Default Re: Virtual Government

I don't have anything helpful to offer, but I gotta say that is really cool! Where do you work where you get those type of work orders?!
jairic is offline  
Old 07-14-2008, 02:59 AM   #3 (permalink)
zedman3d's Avatar
 
I am of the highest lvl..

Join Date: Oct 2007

Location: Sydney, Australia

Posts: 2,455

zedman3d will become famous soon enoughzedman3d will become famous soon enough

Default Re: Virtual Government

Whats a specific problem your having?

If you need to simulate each person voting, then maybe loop through each person and do a random sort of thing. I took the time to create a presidential election simulator. The votes are in a way random but it is also built to take into account small things such as: Older people are 5% more likely to vote for McCain etc etc.

Btw, im in Australia so the fact that i know anything about your elections is amazing.

The below will take how ever many people you want, and echo exactly who they voted for, person by person.
PHP Code:
<?php

// Assume its a two party system, with one party being 0, the other
// being 1.

// Lets assume that 20% of the population (mass) is ethnic, and studies 
// show this makes them 10% more likely to vote for Obama.

// Lets assume that 30% of the population (mass) is above 60, and studies 
// show this makes them 5% more likely to vote for McCain.

// Lets assume there are 10000 people in the USA, there are actually <br />
// 300,000,000 but i didnt want to destroy any servers.

// Lets assume 80% of people vote.

// Mass = Voting Population.

$countrypop 10000;
$votingpop $countrypop*0.80;

$mass $votingpop;
$ethnic $mass*0.20;
$old $mass*0.30;
$remaining $mass - ($ethnic+$old);
$count 0;
$count1 0;
$count2 0;
$largecount 0;
$person 0;
$VotesA 0;
$VotesB 0;
$Person1 "Obama";
$Person2 "McCain";

echo(
"Person 1 is: ".$Person1."<br>Person 2 is: ".$Person2."<br><br>");
 
///
 
 
while($count<$remaining)
 {
    
$person rand(0,1);
    
$count+=1;
    if (
$person == 0)
    {echo(
$count.". Voted for Obama <br>"); 
    
$VotesA+=1; }
    if (
$person == 1)
    {echo(
$count.". Voted for McCain <br>"); 
    
$VotesB+=1; }
 }
 
 
  while(
$count1<$ethnic)
 {
    
$person rand(0,100); 
    
$count1+=1;
    if ( 
$person >59 )
    {echo(
$count+$count1+$count2.". Voted for Obama <br>"); 
    
$VotesA+=1; }
    if ( 
$person <61 )
    {echo(
$count+$count1+$count2.". Voted for McCain <br>"); 
    
$VotesB+=1; }
 }
 

 
   while(
$count2<$old)
 {
    
$person rand(0,100); 
    
$count2+=1;
    if ( 
$person <56 )
    {echo(
$count+$count1+$count2.". Voted for Obama <br>"); 
    
$VotesA+=1; }
    if ( 
$person >54 )
    {echo(
$count+$count1+$count2.". Voted for McCain <br>"); 
    
$VotesB+=1; }
 }
 
 
///
 
echo("<br>"."Votes for ".$Person1.": ".$VotesA."<br>");
echo(
"<br>"."Votes for ".$Person2.": ".$VotesB."<br>");

?>
Its far from perfect and there's a bug or two, but in general, it works.
__________________



My pick up line is: I know Vernong.

Trotter: "Ask all the questions you want... whatever we don't know, we'll make
up something that sounds pretty good."

Antec-User: "I have a display now, but the darn system is crash-bandicoot on stock"

Last edited by zedman3d; 07-14-2008 at 05:49 AM.
zedman3d is online now  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual memory KathyD Building, Buying, Upgrading for General PCs 7 02-26-2008 04:55 PM
On the lookout for the perfect Avatar Virtual Assistant creating Software onauc Web Graphics, Design, Digital Images 1 11-20-2007 07:48 AM
Virtual Console Calculator dbzlotrfan Nintendo & Wii 4 09-16-2007 10:15 PM
Accessing internet with Virtual PC sayaprayer Computer Networking & Internet Access 1 09-09-2007 09:27 PM
virtual memmory ramana Other Computer HW Topics 4 04-18-2007 11:25 PM