Advertisement

Simple Programming Challenge

Started by September 11, 2012 07:33 AM
24 comments, last by ATC 12 years, 4 months ago

Is writing a quine just too easy for you? Then try your hand at the following simple programming challenge.

Write a short program that takes at least one hour of computational time (this can be a parameter if you want) to produce some interesting output. Pre-canned output is not interesting, nor does it take one hour to generate.


like... a mandelbrot?

Everything is better with Metal.

Here's my submission in a powershell script...


write-host "Hello " -nonewline
timeout /t 3600 /nobreak
write-host "world."


It takes exactly one hour to complete and the term "interesting" is a subjectively defined term.
Advertisement

Here's my submission in a powershell script...


write-host "Hello " -nonewline
timeout /t 3600 /nobreak
write-host "world."


It takes exactly one hour to complete and the term "interesting" is a subjectively defined term.




is their a particular reason you use write-host instead of echo?
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

[quote name='slayemin' timestamp='1347636325' post='4980083']
Here's my submission in a powershell script...


write-host "Hello " -nonewline
timeout /t 3600 /nobreak
write-host "world."


It takes exactly one hour to complete and the term "interesting" is a subjectively defined term.


is their a particular reason you use write-host instead of echo?
[/quote]

Yes, it lets me add extra parameters to control how the string is displayed, and thus is more robust and my prefered way of outputting text. Sure, I could use echo to output unformatted text, but if I found a need to start formatting it, then my code would contain a mixture of echos and write-hosts. So, I just choose to use write-host all across the board for the sake of consistency :)


#hello world with red text and green background without a terminating line break
write-host -foregroundcolor red -backgroundcolor green "hello world" -nonewline
Speaking of Quines, I was playing around with a self-referencing program a few weeks ago. I could get it to output its source code via a simple print function, but if I copy/pasted the printed source code, it wouldn't result in the same program anymore because the next compiled generation wouldn't be able to print itself. It's a perplexing problem. It reminds me of looking into the world within two mirrors reflecting each other infinitely.

I'm currently thinking that the problem is that my language is compiled. If instead I wrote my program in binary, I could instruct the program to read its own binary code and output the results (which would pretty much be a way to clone/copy yourself). Then I'd be able to run the clone and repeat the command for as many generations as I'd like.

The other approach I was thinking of was adding the C++ compiler as an embedded resource within the compiled executable. Then, the app could just print its source code and run it through the compiler, and somehow splice in its source code into the source code again, thus being able to self-compile and run as many generations as desired. What an interesting problem to contemplate :)

What constitutes a "programming language" ?
If what the OP wrote is they way I think it is, they want a "random" program of some kind ?
Just to go off the deep end, here is something "random" I came up with some time ago
[media]
[/media]

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

Advertisement
This challenge was partly inspired by the following realization...

You know the phrase "they say people only use 10% of their brain, imagine if they used it all"... Well, it's not true, every part of the brain is used.

On the other hand, "most games spend less than 10% of total CPU time on AI" is actually true. Imagine if AI used 90% of the total CPU time on a powerful quad-core i7... What would it be able to achieve?

On the other hand, "most games spend less than 10% of total CPU time on AI" is actually true. Imagine if AI used 90% of the total CPU time on a powerful quad-core i7... What would it be able to achieve?

I don't think AI "skill" scales linearly with processing power, my guess is it's more like an exponential complexity curve because of all the graph theory involved in artificial intelligence, so giving more processing power to the AI might not help that much. And of course there's the game logic and physics to run at the same time... but I agree that current AI is a bit stale, especially since it's pretty easy to exploit it once you understand how it works. And you can't unsee it either, once you've seen the AI break the immersion is gone forever.

I think the future is a system where you use your own brain as a computing extension to process AI (which would then become true intelligence) and challenge yourself, hopefully without cheating (perhaps you could isolate sections of the cortex to make sure the two different personalities don't interact, or you could replicate yourself for the duration of your gaming session). An interesting possibility is that you could connect your cat to the device and see if you can defeat him... huh.png

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

There's an unrealized issue here: "Perfect" AI is not fun. Play Quake3 with Xero on nightmare difficulty on the last level. He's pretty much a near perfect aim bot with a rail gun who will one-shot you just about every time. It's only possible to beat him because he's not "perfect". If he was perfect, he'd be impossible to beat.
Consider the game of chess and the AI for it: Chess AI is pretty much a min-max tree with depth and breadth. The AI is limited by how many moves in advance it can think before running out of memory. If you had infinite memory and lots of available CPU, you could make a "perfect" chess AI, where the best result you could hope for is a stale mate. Make one false move, and you lose. Sound fun?
Consider that same level of difficulty for games like Civ 5 or Starcraft 2. The AI is so good it doesn't need to cheat. The computer has massive advantages over a human being. Imagine if the Starcraft2 AI had perfect micromanagement for every zergling, where it'd run away if it has 1 hp? It could calculate exactly when to run away, when to fight, etc. to maximize its damage dealt vs. damage received ratio. It would always play perfect games and you'd always lose simply because you don't have the ability to micro at the same level.

On the other hand, "most games spend less than 10% of total CPU time on AI" is actually true. Imagine if AI used 90% of the total CPU time on a powerful quad-core i7... What would it be able to achieve?



It really depends on if the system needs more time to find the most optimal solution, so this wouldn't extend to every possible situation, and it also depends on the complexity of the AI, in such a manner that more time/processing = better results.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

This topic is closed to new replies.

Advertisement