server monitoring


+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2006
    Location
    Eat
    Posts
    1,657

    Rock Paper Scissors in C++

    It's basically Rock Paper Scissors

    Code:
    //Rock Paper Scissors game by Moonbat
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    int main()
    {
        srand((unsigned)time(0));
        int choice;
        int compchoice = (rand()%2)+1;
        cout << "Welcome to ~ Rock Paper Scissors ~!! I assume you know how to play,";
        cout << " so lets begin. You are playing against the computer. Type 0 for";
        cout << " rock, 1 for paper, and 2 for scissors\n";
        cin >> choice;
        
        if (choice == 0) 
        {
                  if (compchoice == 0)
                  cout << "It's a tie!\n\n\n\n";
                  else if (compchoice == 1)
                  cout << "Paper beats rock! Sorry, you lose!\n\n\n\n";
                  else if (compchoice == 2)
                  cout << "Rock beats scissors! You win!\n\n\n\n";
        }
        
        if (choice == 1)
        {
                   if (compchoice == 0)
                   cout << "It's a tie!\n\n\n\n";
                   else if (compchoice == 1)
                   cout << "Paper beats rock! You win!\n\n\n\n";
                   else if (compchoice == 2)
                   cout << "Scissors beat paper! Sorry, you lose!\n\n\n\n";
       }
       
       if (choice == 2)
       {
                  if (compchoice == 0)
                  cout << "It's a tie!\n\n\n\n";
                  else if (compchoice == 1)
                  cout << "Scissors beat paper! You win!\n\n\n\n";
                  else if (compchoice == 2)
                  cout << "Rock beats scissors! Sorry, you lose!\n\n\n\n";
       }
        return main();
    }

  2. #2
    Join Date
    Jan 2005
    Location
    <(o)><(o)>
    Posts
    623
    I rewrote your program in 6 lines of code:
    Code:
    $class = array("0"=>'rock', "1"=> 'paper', "2"=> 'scissors');
    $stats = array("00"=>'0', "01"=>'1', "02"=>'2', "10"=>'2', "11"=>'0', "12"=>'1', "20"=>'1', "21"=>'2', "22"=>'0');
    $message=array("It's a tie!","You loose!","You Win!");
    
    $player1=rand(0,2);
    $player2=rand(0,2);
    
    echo $class[$player1] . " VS " . $class[$player2] . "<br>" . $message[$stats[$player1 . $player2]];
    [url=http://boninroad.com/syntaxmaster/rockpaperscissors.php]My Program[/url] - Hope its not to intense!
    Last edited by SyntaXmasteR; 09-27-2006 at 07:06 PM.
    [url=http://www.syntaxmaster.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntaxmaster.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntaxmaster.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntaxmaster/]Old Site[/URL]
    [URL=http://www.syntaxmaster.info]Comming Soon[/URL]

  3. #3
    Join Date
    Jan 2005
    Location
    <(o)><(o)>
    Posts
    623
    Ohhhh Here is [url=http://boninroad.com/syntaxmaster/games/rockpaperscissors.php]Rock - Paper - Scissors : V1.0[/url]

    This was a little more than 6 lines but its mixed with html:
    Code:
    if(isset($_GET['weapon']))
    	{
    	if($_GET['weapon'] >= 0 && $_GET['weapon'] <= 2)
    		{
    		$class = array("0"=>'rock', "1"=> 'paper', "2"=> 'scissors');
    		$stats = array("00"=>'0', "01"=>'1', "02"=>'2', "10"=>'2', "11"=>'0', "12"=>'1', "20"=>'1', "21"=>'2', "22"=>'0');
    		$message=array("It's a tie!","You loose!","You Win!");
    
    		$player1=$_GET['weapon'];
    		$player2=rand(0,2); 
    		?>
    		<img src="images\<? echo $player1; ?>.jpg"  />&nbsp;&nbsp;<b>VS</b>&nbsp;&nbsp;<img src="images\<? echo $player2; ?>.jpg" />&nbsp;&nbsp;<font face="Verdana, Arial, Helvetica, sans-serif" size="+1" color="#FF0000"><? echo $message[$stats[$player1 . $player2]] ?></font>
    
    		<?
    		}
    	else echo "<h1>INVALID WEAPON BIOTCH!</h1>";
    	}
    ?>
    <p>
    <font face="Verdana, Arial, Helvetica, sans-serif" size="+1" color="#333333">Choose Your Weapon:</font><br />
    <a href="rockpaperscissors.php?weapon=0" target="_self"><img src="images\0.jpg" /></a> &nbsp;&nbsp;
    <a href="rockpaperscissors.php?weapon=1" target="_self"><img src="images\1.jpg" /></a> &nbsp;&nbsp;
    <a href="rockpaperscissors.php?weapon=2" target="_self"><img src="images\2.jpg" /></a>
    </p>
    [url=http://www.syntaxmaster.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntaxmaster.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntaxmaster.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntaxmaster/]Old Site[/URL]
    [URL=http://www.syntaxmaster.info]Comming Soon[/URL]

  4. #4
    Join Date
    Sep 2006
    Location
    Eat
    Posts
    1,657

    but

    But I wrote it in C++, so it took a few more lines

    Maybe you could add a "Code" section to the forums?

  5. #5
    Join Date
    Jan 2005
    Location
    <(o)><(o)>
    Posts
    623
    I was thinking the same thing after I saw this post in the "Internet Privacy" section... I will request a Code section and hopefully we can get it added to the forum soon.
    [url=http://www.syntaxmaster.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntaxmaster.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntaxmaster.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntaxmaster/]Old Site[/URL]
    [URL=http://www.syntaxmaster.info]Comming Soon[/URL]

  6. #6
    Join Date
    Sep 2006
    Location
    Eat
    Posts
    1,657

    ok

    Oh, ok, thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts