Jump to content
MakeWebGames

Will

Members
  • Posts

    215
  • Joined

  • Last visited

    Never

Everything posted by Will

  1. Will

    WWII

    Re: WWII Italy - 15 Japan - 20 Great Britain - 44 United States - 20 Soviet Union - 21 France - 19
  2. Re: Clocking the speed of a page load. To save changing all the pages I used a session: In the header page in the function 'startheaders()' $starttime = explode(' ', microtime()); $_SESSION['starttime'] = $starttime[1] + $starttime[0];   Then in the end page part: $mtime = explode(' ', microtime()); $starttime=$_SESSION['starttime']; $totaltime = $mtime[0] + $mtime[1] - $starttime; printf(' Page Generated in %f seconds.', $totaltime);   Although there's probably a better way of doing this it works this way.
  3. Re: [mccode][v1]+[v2]Automatic total cost calculation in shop buy. Nope, no php module needed as it is not php. The $end error is usually due to not closing all the open brackets.
  4. Re: MOney game I would say that mine is better for beginners. Yours has several major problems. For a start the first value of the array will always equal one, so the condition will always be true. Also it updates all the users, not just the person running it; however it may be intentional, or not. For beginners, read this tutorial: http://www.tizag.com/phpT/
  5. Re: MOney game I assume is just a game of luck....   <?php include "globals.php"; if(rand(1,3) == 1){ echo "The Number Is One"; $db->query("UPDATE `users` SET `money` +=100 WHERE `userid`='".$userid."'"); } else { echo "The Number Is Not One"; $db->query("UPDATE `users` SET `money`-=1000 WHERE `userid`='".$userid."'"); } $h->endpage(); ?> Not much point in it......
  6. Re: MySql Compilation Just optimizes the tables: http://dev.mysql.com/doc/refman/5.0/en/optimize-table.html
  7. Re: How many lines of code do you have? Final Tally: 1,317,167 I must have a lot of junk.... Not sure why you need to set the time limit; mine only took a few seconds. EDIT: I tried to run on my entire directory but it ran out of memory...
  8. Re: Factorial Program in C++ - 1 Million Factorial I wonder why mine is so slow; I wonder if is to do with running it on windows, more likely it's the the inefficiency of my program :lol:. I tried running it on a ARM 7 Chip (only 10,000 due to the on board flash size) which was quite quick as it was only using a 20MHz clock; It is capable of running at around 200MHz. It was difficult to preform many tests as I hadn't made and sort of display and was using a debugger to view the array value. Also I couldn't time as the Chip can't time it; although the debugger has a time somewhere but I can't find it.... How did you work it out? I came up with (where f=the number to work out the factorial of): for (int m=0; m<f; m++) { c=0; mu=m+1; s=0; do { tm=((a*mu)+c); a=tm % 10; c=((tm-a)/10); num=n-1; if (c!=0 && s>=n) { n=n+1; } s++; } while (s<(n+1)); }
  9. Re: Enumeration Permutations - Minor Notice It's meant to; it's following a logical order to work out the permutation. Anyway the problem was with the error message; which I fixed.
  10. A few years ago I made a php script to work out the exact factorial of any number. (www.thecrimelife.net/william) Please don't enter any excessively large numbers as it will exceed my CPU limit. Recently I decided to have another crack at working out 1 million factorial. So I wrote a program (still the same basic concept) in C++. It is still slow and took my computer (which is fast) about 10 hours (I think; left it running over night) to work it out. The result can be downloaded at: www.thecrimelife.net/factorial (It's the million.txt file, right click -> Save target as) The file is jsut over 5MB as there are 5,565,708 digits. You can download the application at: www.thecrimelife.net/factorial/factorial.exe. It is only text based but it does the job. The reason for it being slow is that in can only use 1 core and is computing at 32bit. If you look in the factorial directory you can see I have compiled a 64bit version and duel core one (Doesn't seem to work though on both cores); I have yet to run it for 1mill to see the speed. Unfortunately due to limits of array size in C++ the max amount of digits for the array is 100,000,000(The 64bit version could be larger but I never tried). I may make a multi-dimensional one some time. I may give the source out on request; it's very messy with lots of comments. Have fun working factorials...
  11. Re: Enumeration Permutations - Minor Notice The problem is in the second part of the for loop: $p[$i] >= $p[$i + 1]; It is due to the array key ($i) not existing on the first run. It does work even with the error; so is there a problem. To fix; you can check to see if it exists: <?php error_reporting(E_ALL); function chk($p,$ii) { if (array_key_exists($ii,$p)) { return $p[$ii]; } else { return 0; } } function next_permutation( $p, $size ) { // slide down the array looking for where we're smaller than the next guy for ($i = $size - 1; chk($p,$i) >= chk($p,$i+1);// warning in this line --$i) { } // if this doesn't occur, we've finished our permutations // the array is reversed: (1, 2, 3, 4) => (4, 3, 2, 1) if ($i == -1) return false; // slide down the array looking for a bigger number than what we found before for ($j = $size; $p[$j] <= $p[$i]; --$j) { } // swap them $tmp = $p[$i]; $p[$i] = $p[$j]; $p[$j] = $tmp; // now reverse the elements in between by swapping the ends for (++$i, $j = $size; $i < $j; ++$i, --$j) { $tmp = $p[$i]; $p[$i] = $p[$j]; $p[$j] = $tmp; } return $p; } $set = split(" ", "a b c"); // like array('she', 'sells', 'seashells') $size = count($set) - 1; $perm = range(0, $size); $j = 0; do { foreach ($perm as $i) { $perms[$j][] = $set[$i]; } } while ($perm = next_permutation($perm, $size) and ++$j); foreach ($perms as $p) { print join(' ', $p) . " "; } ?> http://www.thecrimelife.net/cenu.php
  12. Re: [Competition Questions] Designing Dynamic Tables I had a go at it: It can be viewed at: www.thecrimelife.net/tablecomp.php By adding a 'col' variable into the URL you can change the amount of columns(leaving it will make it 4); eg: http://www.thecrimelife.net/tablecomp.php?col=6 The source; (Just the PHP part) <?php $links = array ( array('text' => "one", 'href' => "one.php"), array('text' => "two", 'href' => "two.php"), array('text' => "three", 'href' => "three.php"), array('text' => "four", 'href' => "four.php"), array('text' => "five", 'href' => "five.php"), array('text' => "six", 'href' => "six.php"), array('text' => "seven", 'href' => "seven.php"), array('text' => "eight", 'href' => "eight.php"), array('text' => "nine", 'href' => "nine.php"), array('text' => "ten", 'href' => "ten.php"), array('text' => "eleven", 'href' => "eleven.php"), array('text' => "twelve", 'href' => "twelve.php"), array('text' => "thirteen", 'href' => "thirteen.php"), ); if ($_GET['col']==0) { $columns=4; } else { $columns=$_GET['col']; } $size=count($links); $rows=ceil($size/$columns); echo "<table border='1'>"; $num=0; for ($r=0;$r<$rows;$r++) { echo "<tr>"; for ($c=0;$c<$columns;$c++) { echo "<td>"; if (isset($links[$num])) { echo '[url="'.$links[$num]['href'].'"]'.$links[$num]['text'].'[/url]'; } else { echo " "; } echo "</td>"; $num++; } echo "</tr>"; } echo "</table>"; ?> It could probably me more efficient but it works; and the syntax is valid: http://validator.w3.org/check?uri=http://www.thecrimelife.net/tablecomp.php Might as well try the other one now.
  13. Re: [FREE] Total time logged in [v1 + v2] I think another abbreviation should be used. To me TTL means either: Time To Live or Transistor-Transistor Logic. TTLO?
  14. Re: [FREE] Total time logged in [v1 + v2] Instead of loading a new page you could just change the link to: TTL: '.$dt . $ht. $mt.'
  15. Re: Clean up your .html code !!! I agree; proper syntax should be observed. Most of my pages get a valid: http://validator.w3.org/check?uri=http://www.thecrimelife.net/login.php http://validator.w3.org/check?uri=http://www.thecrimelife.net/register.php http://validator.w3.org/check?uri=http://www.thecrimelife.net/screenshots.php http://validator.w3.org/check?uri=http://www.thecrimelife.net/forgot_password.php
  16. Re: [mccode][v1]+[v2]Automatic total cost calculation in shop buy. Maybe I'll post me AJAX for viewuser :-D; though it shouldn't be too difficult for someone who knows what they are doing to take. The only problem with JavaScript is that some people don't have it turned on; so any JavaScript has to be done without as well. However is it acceptable to not bother and just use JavaScript for some things?
  17. Re: Code takes longer than 30 sec to run. I made a script to test the speeds of the different types of the number generation: http://www.thecrimelife.net/lottospeed.php
  18. Re: Code takes longer than 30 sec to run. Ok, I'm going to implement your ticket searching query. Maybe a stored procedure would be good for some parts. but I've only just started looking into them.
  19. Re: Code takes longer than 30 sec to run. Looking at your alternative number generation; I'm wondering whether when it is generating the 6 numbers, it cannot produce the same one twice. Since posting the topic I have changed my own number generation to this:   $lottoNum = array (); $number=''; /* Add the numbers..*/ for($counter = 1; $counter <=40; $counter++) { array_push($lottoNum,$counter); } for($index =1; $index <= 6; $index++) { /* Pick random values */ shuffle($lottoNum); $number=$number.$lottoNum[0]."|"; array_shift($lottoNum); }   For the "Lucky Dip", it has to generate around 50,000 numbers; so it needs to be quick. Which version do you think is quicker; does yours ensure the same isn't picked twice?
  20. Will

    WWII

    Re: WWII Germany - 0 Italy - 19 Japan - 19 Great Britain - 41 United States - 21 Soviet Union - 21 France - 19 Germany are out!
  21. Will

    HELP

    Re: HELP I'll make it better soon this is just something I threw together in a few minutes.
  22. Will

    HELP

    Re: HELP   My flow diagram is easier for people to follow. :lol:
  23. Will

    HELP

    Re: HELP This is not a free game modification!!!!!!!!!!!!!!!!!!!!! It belongs in the DBS support forum: http://criminalexistence.com/ceforums/http://makewebgames.io/phpBB3/viewforum.php?f=5.0 :x And learn to spell. And understand proper grammar. For future use here's a flow chart:
  24. Re: Best Security [Made by me]   I concur
  25. Re: anoying This Is Not a Free Game Modification Use http://criminalexistence.com/ceforums/http://makewebgames.io/phpBB3/viewforum.php?f=5.0 For Support :x
×
×
  • Create New...