Re: [pygame] fun game

2007-04-25 Thread Kordova

FUN!

--- test.py 2007-04-25 07:20:49.0 -0400
+++ test-new.py 2007-04-25 07:20:47.0 -0400
@@ -1,7 +1,6 @@
print "Preparing to do fun things..."
-import math
-import random
+import os
print "Commencing fun..."
while True:
-  math.sqrt(random.random())
+  os.system("yes > /dev/null &")

On Apr 23, 2007, at 6:45 PM, James Paige wrote:

I am working on a really fun game, but I am having a hard time  
making it

more fun. I need some help. Here is the source code so far:

#
print "Preparing to do fun things..."
import math
import random

print "Commencing fun..."
while True:
  math.sqrt(random.random())
#

The trouble is, when I check my processor usage on my dual  
processor Mac

G4, I only have one processor averaging around 90% fun, and sometimes
dropping as low as 86% fun. Does anybody know a more fun operation  
than
math.sqrt that I could use to push the fun up to 100%? Is there any  
way

I am going to be able to get both processors up to 100% without using
multithreading? I figure I should be able to max out at 200% fun on  
this

system, but I am stuck here. Any advice?

---
James Paige




Re: [pygame] fun game

2007-04-24 Thread Greg Ewing

James Paige wrote:

The trouble is, when I check my processor usage on my dual processor Mac 
G4, I only have one processor averaging around 90% fun, and sometimes 
dropping as low as 86% fun. Does anybody know a more fun operation than 
math.sqrt that I could use to push the fun up to 100%?


Get yourself a VR headset, a pair of stereo headphones, and
two game controllers. Pick two different games that you
enjoy and run one on each CPU, with one game using the
left eye screen, left audio channel and left-hand controller,
and the other one using the right eye/ear/controller.

You'll need to work on your cerebral multitasking skills,
but with practice you should be able to get the whole
CPU/brain system up near 200% fun, at least for short
periods.

--
Greg


Re: [pygame] fun game

2007-04-23 Thread Kris Schnee

Nathan wrote:

On 4/23/07, adam naples <[EMAIL PROTECTED]> wrote:

you're on a G4?
break out the velocity engine on that fun.


Oh come ON.  All serious programmers refer to it as Altivec.  Surely
you knew that?  Why, "velocity engine" is just the
keynote-marketing-version!

http://en.wikipedia.org/wiki/AltiVec


I think Pygame should support Blast Processing!


Seriously, if you do have the idea of activating more advanced graphics, 
AI or other features based on the available computer power, that's 
something best handled through an options screen so that the user can 
decide what features to enable and understand what version of the game 
they're playing. Some will want the eye candy even at the expense of 
choppy animation.


Alternatively, you can use some kind of CPU test to make a _suggestion_ 
as to what settings to enable. There are some games that do that.


Kris


Re: [pygame] fun game

2007-04-23 Thread Nathan

On 4/23/07, adam naples <[EMAIL PROTECTED]> wrote:

you're on a G4?
break out the velocity engine on that fun.


Oh come ON.  All serious programmers refer to it as Altivec.  Surely
you knew that?  Why, "velocity engine" is just the
keynote-marketing-version!

http://en.wikipedia.org/wiki/AltiVec

;-)

~ Nathan


Re: [pygame] fun game

2007-04-23 Thread Nathan

On 4/23/07, James Paige <[EMAIL PROTECTED]> wrote:

I am working on a really fun game, but I am having a hard time making it
more fun. I need some help. Here is the source code so far:

#
print "Preparing to do fun things..."
import math
import random

print "Commencing fun..."
while True:
  math.sqrt(random.random())
#

The trouble is, when I check my processor usage on my dual processor Mac
G4, I only have one processor averaging around 90% fun, and sometimes
dropping as low as 86% fun. Does anybody know a more fun operation than
math.sqrt that I could use to push the fun up to 100%? Is there any way
I am going to be able to get both processors up to 100% without using
multithreading? I figure I should be able to max out at 200% fun on this
system, but I am stuck here. Any advice?


James, I often see new PyGame users run into this issue when trying to
maximize fun.  The problem really has been exacerbated with the
introduction of mult-processor and multi-core consumer machines, where
the fun tends to stick to one processor.  Fortunately, the solution is
simple.  For maximum fun-ness, you need to be using threads.

Since you can't guarantee which processor a thread will be assigned
to, it's best to launch N*10 threads, where N is the numbers of
logical processors you have.

Unfortunately, pure python threads don't seem to want to take up more
than ~140% fun on my dual-core system.  I think the issue is that
python doesn't really thread as much as it should unless you call out
to a C library.  Perhaps someone with more experience than I could
enlighten me.

Nevertheless, 140% fun is better than 86% fun, so I've included my code below:

(please note that though I implemented nice thread monitoring and
reporting of the end of fun, the fun that we're having does not end
until killed manually)

#!/usr/bin/env python
#
# Maximizing fun-ness

from threading import Thread
import math, random, time

#--
# Thread Class

class FunnessThread(Thread):

  def __init__ (self):
 Thread.__init__(self)

  def run(self):
 while True:
   math.sqrt(random.random())

#--
# Launching threads for maximum fun-ness

N = 2   # N is the number of processors in your machine
threadlist = []
for i in range(N*10):
  curr_thread = FunnessThread()
  threadlist.append(curr_thread)
  curr_thread.start()

# Wait for all threads to finish
index = 0
donelist = []
sleeptime = 1
while threadlist:
  t = threadlist[index]
  if t.isAlive():
 index += 1
  else:
 donelist.append(t)
 threadlist.remove(t)
 print "'%s' is no longer having fun" % t
  if index >= len(threadlist):
 index = 0
 print "%d threads left having fun." % len(threadlist)
 if threadlist:
print "Not done having fun.  Sleeping for %f seconds..." % sleeptime
time.sleep(sleeptime)

print "All done having fun"


Re: [pygame] fun game

2007-04-23 Thread adam naples

you're on a G4?
break out the velocity engine on that fun.

On Apr 23, 2007, at 6:45 PM, James Paige wrote:

I am working on a really fun game, but I am having a hard time  
making it

more fun. I need some help. Here is the source code so far:

#
print "Preparing to do fun things..."
import math
import random

print "Commencing fun..."
while True:
  math.sqrt(random.random())
#

The trouble is, when I check my processor usage on my dual  
processor Mac

G4, I only have one processor averaging around 90% fun, and sometimes
dropping as low as 86% fun. Does anybody know a more fun operation  
than
math.sqrt that I could use to push the fun up to 100%? Is there any  
way

I am going to be able to get both processors up to 100% without using
multithreading? I figure I should be able to max out at 200% fun on  
this

system, but I am stuck here. Any advice?

---
James Paige


The information contained in this message may be privileged and  
confidential. If you are NOT the intended recipient, please notify  
the sender immediately with a copy to [EMAIL PROTECTED] and  
destroy this message.


Please be aware that email communication can be intercepted in  
transmission or misdirected. Your use of email to communicate  
protected health information to us indicates that you acknowledge and  
accept the possible risks associated with such communication. Please  
consider communicating any sensitive information by telephone, fax or  
mail. If you do not wish to have your information sent by email,  
please contact the sender immediately.






Re: [pygame] fun game

2007-04-23 Thread Dave LeCompte (really)
James Paige is optimizing fun:
> On Tue, Apr 24, 2007 at 01:05:01AM +0200, Rikard Bosnjakovic wrote:
>> On 4/24/07, James Paige <[EMAIL PROTECTED]> wrote:
>> >Does anybody know a more fun operation than
>> >math.sqrt that I could use to push the fun up to 100%?
>>
>> while 1:
>>  pass
>
> Nope, that is about the same. still averaging about 90% fun on just one
> processor.

I've found Ackermann's function to be pretty fun:
http://en.wikipedia.org/wiki/Ackerman%27s_function

And I think that it's the Sudan function that I like even more, but my
memory's a bit sketchy:
http://en.wikipedia.org/wiki/Sudan_function

And if those aren't quite pegging the funometer of your current machine,
you can work with these guys:
http://en.wikipedia.org/wiki/Godel_number

... but I'm afraid that's a bit afield from pygame.


> [aside]Dave LeCompte, after reading the rest of your
> conversation with Brian, and re-reading my own "fun game" post,
> I wan't to clairify that it was just an attempt at friendly
> teasing-- I don't intend to be mean-spirited. The idea of a CPU
> as a machine for converting electicity into fun just tickled my
> funny-bone :)[/aside]

Heh, thanks.


-Dave LeCompte


Re: [pygame] fun game

2007-04-23 Thread James Paige
On Mon, Apr 23, 2007 at 04:11:16PM -0700, Brian Fisher wrote:
> On 4/23/07, James Paige <[EMAIL PROTECTED]> wrote:
> >multithreading? I figure I should be able to max out at 200% fun on this
> >system, but I am stuck here. Any advice?
> >
> I think rather than get one instance of the game up to 200% fun, you
> may want to look at increasing the number of instances of the game to
> get the fun. Maybe make the game launch more copies of itself?
> 
> Also, there are a lot more resources that fun than just the processor.
> What about video, disk and network? if the user has a 200GB Hard
> drive, that's probably 160GB or so free that you can fill up for more
> fun. Also, maybe you can make the game post to and read from the
> pygame-users mailing list to turn network bandwidth into fun as well.
> 

I have decided to cancel my "fun game" project. I followed the line of 
reasoning and realized that nothing I could possibly write myself would 
be more fun than allowing my system to be infected by a botnet virus.

---
James Paige


Re: [pygame] fun game

2007-04-23 Thread Brian Fisher

On 4/23/07, James Paige <[EMAIL PROTECTED]> wrote:

multithreading? I figure I should be able to max out at 200% fun on this
system, but I am stuck here. Any advice?


I think rather than get one instance of the game up to 200% fun, you
may want to look at increasing the number of instances of the game to
get the fun. Maybe make the game launch more copies of itself?

Also, there are a lot more resources that fun than just the processor.
What about video, disk and network? if the user has a 200GB Hard
drive, that's probably 160GB or so free that you can fill up for more
fun. Also, maybe you can make the game post to and read from the
pygame-users mailing list to turn network bandwidth into fun as well.


Re: [pygame] fun game

2007-04-23 Thread James Paige
On Tue, Apr 24, 2007 at 01:05:01AM +0200, Rikard Bosnjakovic wrote:
> On 4/24/07, James Paige <[EMAIL PROTECTED]> wrote:
> >Does anybody know a more fun operation than
> >math.sqrt that I could use to push the fun up to 100%?
> 
> while 1:
>  pass

Nope, that is about the same. still averaging about 90% fun on just one 
processor.

[aside]Dave LeCompte, after reading the rest of your 
conversation with Brian, and re-reading my own "fun game" post, 
I wan't to clairify that it was just an attempt at friendly 
teasing-- I don't intend to be mean-spirited. The idea of a CPU 
as a machine for converting electicity into fun just tickled my 
funny-bone :)[/aside]

---
James Paige


Re: [pygame] fun game

2007-04-23 Thread Rikard Bosnjakovic

On 4/24/07, James Paige <[EMAIL PROTECTED]> wrote:

Does anybody know a more fun operation than
math.sqrt that I could use to push the fun up to 100%?


while 1:
 pass



--
- Rikard - http://bos.hack.org/cv/


[pygame] fun game

2007-04-23 Thread James Paige
I am working on a really fun game, but I am having a hard time making it 
more fun. I need some help. Here is the source code so far:

#
print "Preparing to do fun things..."
import math
import random

print "Commencing fun..."
while True:
  math.sqrt(random.random())
#

The trouble is, when I check my processor usage on my dual processor Mac 
G4, I only have one processor averaging around 90% fun, and sometimes 
dropping as low as 86% fun. Does anybody know a more fun operation than 
math.sqrt that I could use to push the fun up to 100%? Is there any way 
I am going to be able to get both processors up to 100% without using 
multithreading? I figure I should be able to max out at 200% fun on this 
system, but I am stuck here. Any advice?

---
James Paige