• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

The NeoGAF Weekly Recreational Programming Challenge

Status
Not open for further replies.

wolfmat

Confirmed Asshole
What's going on?
The short and sweet is: A weekly topic, people code stuff, someone wins.
We are in week 2. Here is the countdown to voting:
t1342105200z0.png


List of challenges
Week 1 (Flora) ...... Winner: (1) lorebringer generates fractal-based plant life on your browser. (Post) (Solution link) (Source)
Week 2 (Mazes) .... Happening right now! CODE, YOU FOOLS. CODE!!

Rules

How does it work?
Each Friday, a programming challenge is posted. Any NeoGAF member can take part in the challenge. You can use any programming language you like to take part in the challenge. Once you're happy with your submission, you point us to either a compilate or the source code. How you do this exactly is up to you. Neither screenshots nor video suffice though.
The challenge runs until Thursday. On Thursday, we try to determine who won the challenge. We do this by voting. Voting ends on Friday.

Who posts the challenge?
I post the first challenge. After that, it's up to the challenge winner to either post the next challenge, or to give someone else the opportunity to post a challenge.

How does voting work?
Each NeoGAF member gets one vote. After voting is started with an appropriate post, challenge submissions are still accepted, but will probably get less votes. All challenge submissions are rounded up in a post to make it easy to find them. They are listed in order of submission post date.
It is okay to submit multiple times, as long as the submissions are dissimilar enough from each other.
Members vote for submissions, not for posters. They do this by saying "I vote for (some submission)" or similar.

What do I win?
That is for the challenge poster to decide. It might only be internets, it might be a Steam game, whatever. Of course it makes sense if the challenge poster has made sure he can actually produce the price when it's time. Also, remember that NeoGAF has a global audience, so things like iTunes codes only work if the region applies, for instance.
The person who has posted the challenge cannot claim the prize. If said person wins his own challenge, the prize goes to the next-best participant. The right to post a new challenge remains with the winner though, it is not attached to the prize.

What kind of challenges are okay?
Don't post overly hard challenges. Don't post challenges that would take a lot of time to complete. Don't post challenges that are actually your homework assignments or similar. Don't post challenges that need a lot of research. Apart from that, pretty much anything goes.
Preferably, you post challenges that are cool for non-programmers to experience. That includes audio- and video-related challenges, and ones that demand input and create output of some kind. But that's not really mandatory.

Does it have to be one week only?
As a challenge poster, you can extend the deadline if you want to at any point. The maximum amount of weeks a challenge can run is 4 weeks. You should only extend the deadline if you feel like it makes the challenge better though.

Do I have to write perfect code?
No. It's not about perfect code. It's about programming for entertainment, coming up with a cool thing, showing it off, and being proud of it. So there is nothing that can disqualify you. Just don't destroy stuff or delete files with your code.
So you can certainly write shitty code and get away with it in here. You might get lucky though insofar as others might give you pointers on what you might want to do differently.

What about copyright, trademarks and all that?

Use common sense. For example, if you invent a new collision detection algorithm that dwarfs all other algorithms out there while you're coding for a challenge, you might not want to publish it without making sure you're satisfied with the results of said publishing. Other than that, assume you're writing public domain code because noone on these boards can guarantee you rights to anything.
Of course, you cannot use trademarked content, and you have to respect the copyright of others. We're not above the law just because we're having a friendly coding challenge.

What are the go-to languages for this?
C, C++, Python, Java, C#, Objective C, Javascript.

Can I use custom frameworks, obscure platforms, esoteric programming languages?
If you do this, you need to be able to make it trivial for everyone to check your stuff out. For example, if you want to use LÖVE, then go ahead, but do it with the current release, and provide instructions on how to run your solution. If someone else has already posted run instructions, then it suffices to reference that post.

Where can I go to get help regarding all things programming?
Provided you've already used a search engine to dig for answers, you're of course welcome in the Programming |OT|.
 

wolfmat

Confirmed Asshole
Challenge Week 1: Flora
Write an application that generates visual representations of plants on the screen.

Price
Penny Arcade Adventures: Precipice of Darkness Combo Pack on Steam. The gift is already in my Steam inventory.

Voting has started!

Voting ends at 2012-07-06 1500 GMT
t1341586800z0.png


If you participate, you should be ready to post a challenge once voting is done and you are the winner.

Good luck!


Submissions


Winner: (1) lorebringer generates fractal-based plant life on your browser. (Post) (Solution link) (Source)
Votes: 7​


(2) wolfmat makes a scrolling terminal thing. (Post) (Source)
Votes: 2​


(3) Half and half uses fractals and adds mood with colours. (Post) (Source)
Votes: 2​
 

usea

Member
Awesome. Thank you for making this. Definitely gonna try and throw something together this weekend.
 

Rekubot

Member
I wouldn't even know where to start with this challenge but I'll definitely be following along. Good luck guys!
 

Haly

One day I realized that sadness is just another word for not enough coffee.
Yeah me too, I never touched fractals but it seems like the logical choice for an assignment like this.

Another possibility is "Game of Life" + some constraints to foster vertical growth.
 

wolfmat

Confirmed Asshole
I just draw randomized segmented lines like a crazy person, and apply finetuning. Fractals would work as well though. They would probably yield much more unique outcomes as well.

The biggest question mark for beginners who know for-loops, functions and all that is probably "How do I make a window with a surface on which I can draw pixels?". It's actually easy to find out though, and not a complicated thing at all. You usually don't have to reinvent any of this.

Once you know how to draw pixels, and maybe images, it's just a matter of playing with it. "So I start here, and then I draw a line to there, and from that point to there, and here comes the rotated blossom pic I made in MS Paint" is a valid approach. Or you do something completely different.
 
I've been meaning to get into a bit of canvas stuff with js recently so I think I'll have a go of this, will see if I can get something done today.
 

Tashi

343i Lead Esports Producer
Oooo very cool. Gonna work on something tonight. Probably gonna do it in XNA for practice.
 
Work in progress using JavaScript with HTML5 canvas. Not animated yet but I'm thinking of putting in a growth over time thing and some boxes to set parameters like angle of branches and colours of leaves etc. (Code will come later ofc :p)



wJYAG.png
 
Awesome idea. I've been meaning to do some stuff on L-Systems (Wikipedia) since I heard about them in my computer graphics lecture. I initially wanted to do something with Java, but since it doesn't seem too easy to use colors in Java console applications I switched to C#. Probably for the better, anyways.
 

Kinitari

Black Canada Mafia
Totally going to participate, GAF challenge is probably the only way I'll ever build a portfolio before I finish school.
 
Awesome idea. I've been meaning to do some stuff on L-Systems (Wikipedia) since I heard about them in my computer graphics lecture. I initially wanted to do something with Java, but since it doesn't seem too easy to use colors in Java console applications I switched to C#. Probably for the better, anyways.

I'm using L-Systems to generate the trees in the screen up above. I got lazy and just used a stochastic version of the plant system they give on the wikipedia page.
 
This is a very cool idea for a thread.

I'm going to go with the tried-and-true fractal trees:

Os1E9.jpg


This is done in C++ using Win32 GDI. Just recursively turn and draw, turn and draw. I need to figure out how to draw thicker lines with this api.
 
Discovered the greatness of multiple canvases as images. Really impressed with html5 canvas so far, definitely going to have to work on a small game with this thing. Turns out making lots and lots of fractal trees works pretty well:

waRAf.png
 

Phoenix

Member
Oooo I like this thread. Too late to get into it for this weekend though without cheating and using Unity ;)
 

Chris R

Member
You fractal tree people are making my stuff look terrible :(

And canvas is pretty cool, don't know if I'm going to try to animate my stuff or just make it static since I'm putting controls on the page the canvas is on to interact with it (change how much grass is present, the time of day, number of flowers, ect).
 

Phoenix

Member
I guess we should establish some ground rules though.


1) Is your application prohibited from using textures, what graphic libraries can you use?

2) How much of a framework can you use (i.e. could someone use DirectX, Unreal, Unity) or are you expecting the use of raw programming languages

3) Shouldn't 100% of the source of the application be publicly accessible to ensure the first 2?
 

usea

Member
I guess we should establish some ground rules though.


1) Is your application prohibited from using textures, what graphic libraries can you use?

2) How much of a framework can you use (i.e. could someone use DirectX, Unreal, Unity) or are you expecting the use of raw programming languages

3) Shouldn't 100% of the source of the application be publicly accessible to ensure the first 2?
I don't see why you can't use whatever you want. Hell, use speedtree if you want. I just don't think you'd get much out of it that way.
 

Chris R

Member
I don't see why you can't use whatever you want. Hell, use speedtree if you want. I just don't think you'd get much out of it that way.

Exactly. Use whatever. Just because someone's solution might look the best doesn't mean they will get the most votes though.

And since this is a graphical challenge I guess people wouldn't need to release their source code, but if I can't see how someone did something the odds of me voting for them are slim :p
 

wolfmat

Confirmed Asshole
I guess we should establish some ground rules though.


1) Is your application prohibited from using textures, what graphic libraries can you use?

2) How much of a framework can you use (i.e. could someone use DirectX, Unreal, Unity) or are you expecting the use of raw programming languages

3) Shouldn't 100% of the source of the application be publicly accessible to ensure the first 2?

I see where you're going with this. You can do whatever you want though. It's your thing.

Demanding that everyone makes the source code available for everyone is something I don't see a reason for. Sometimes, it's not even realistic.

If you do a cool trick in your code, maybe you want to talk about it a little at least, maybe post a snippet or whatever. But if you want to keep the magic completely under the hood, then go ahead and only publish whatever's necessary to get your app running.

If it turns out this breaks the whole thing, then we can always change the rules. But I don't think it will.

As for DirectX, Unreal, Unity, LÖVE, GameMaker, OpenGL, LWJGL, JMonkey, maybe even werkkzeug: You can use whatever you like. Even the Blender built-in game engine is cool beans, and that one makes graphical challenges pretty easy, comparatively. It's your choice. So if you want to use pygame or stb_truetype or some obscure math lib, go right ahead.

Addendum to the rules:
The person who has posted the challenge cannot claim the prize. If said person wins his own challenge, the prize goes to the next-best participant. The right to post a new challenge remains with the winner though, it is not attached to the prize.
 

Tacitus_

Member
You fractal tree people are making my stuff look terrible :(

And canvas is pretty cool, don't know if I'm going to try to animate my stuff or just make it static since I'm putting controls on the page the canvas is on to interact with it (change how much grass is present, the time of day, number of flowers, ect).

Don't worry, my fractal stuff looks horrible! And now it's started misbehaving when I tried to apply a color change and won't turn properly anymore >_>
 
I think my entry is pretty much done. There's loads of stuff I'd like to do with it still but I should really get back to my other work.

You can run it here: http://lifenoodles.ronkmonster.com/
I have the defaults set low enough that most pcs should be fine to run it but feel free to crank the number of trees up a lot and see how it performs. Let me know if it won't run or does something odd as I've only tested in chrome and firefox. Chrome is much faster drawing this than Firefox is as well.

You can get the source from the page just with a rightclick -> save as but here's the direct download link anyway: http://lifenoodles.ronkmonster.com/plants.zip

Disclaimer: I still need to optimise and clean up the source, it's a hacky mess. Don't judge me gaf.
 

wolfmat

Confirmed Asshole
Here's my submission: flora.py

Edit: This version is for consoles that can only do ASCII: flora_bw.py

I'll post a GIF later. Here's a screenshot though:

How to prepare running it:
0. Make sure you've got Python 2.6.7 or above installed, but NOT Python 3 or above. Python 2 is the way to go in this case.
1. Make sure you have a terminal that supports UTF-8
2. Make sure the terminal supports ANSI colours and escape sequences
2. Set the font to Menlo Regular 14pt
3. Set the line spacing to 0.81
4. Set the letter spacing to 1

How to run it:
0. Open the terminal
1. Navigate to the directory where flora.py is
2. python flora.py
3. Let it run
4. If you want to exit the program, press Ctrl-C

Fun stuff:
— You can resize the terminal before running; the thing adjusts
— It is unpredictable, but self-similar, and has no fractal stuff
— It scrolls and there's shadowing (lol)

Not so fun stuff:
— It might flicker, that's because the fillrate is severely limited. Reduce your terminal size.
— Minimal terminal height is 15 lines
— It has only been tested thoroughly on Mac OS X

If you do not have Menlo, then play around with terminal fonts until it looks right. It's not easy for me to find out which font works perfectly everywhere. Sorry for that.
Menlo is a standard OS X font.

Note that the program clears the screen by basically scrolling down. If your terminal starts slowing down after running the program, clear the terminal's line buffer (or type "reset" without quotes and press enter).
 

usea

Member
I don't have menlo (I'm running windows 7), but I have a similar font. I can't get your script to run, using python 3.1.

If I execute "python flora.py" from the command line, the error I get is:
Code:
D:\temp>python flora.py
Traceback (most recent call last):
  File "flora.py", line 26, in <module>
    height, width = os.popen('stty size', 'r').read().split()
ValueError: need more than 0 values to unpack

stty is a unix command. Does this mean your script won't work in windows?
 

usea

Member
I replaced it with 80, 80 as strings. It runs now, but I can't figure out how to have the command line use utf-8. it scrolls endlessly with
Code:
&#915;ûê&#8592;[32m&#915;ûê&#8592;[32m&#915;ûê&#8592;[32m&#915;ûê&#8592;
&#915;ûê&#8592;[32m&#915;ûê&#8592;[92m&#915;ûê&#8592;[32m&#915;ûê&#8592;
&#915;ûê&#8592;[31m&#915;ûê&#8592;[31m&#915;ûê&#8592;[30m&#915;ûê&#8592;
&#915;ûê&#8592;[32m&#915;ûê&#8592;[32m&#915;ûê&#8592;[32m&#915;ûê&#8592;
&#915;ûê&#8592;[92m&#915;ûƒ&#8592;[92m&#915;ûê&#8592;[32m&#915;ûê&#8592;
&#915;ûê&#8592;[32m&#915;ûê&#8592;[92m&#915;ûê&#8592;[32m&#915;ûê&#8592;
etc. Maybe I need a better console..
 

wolfmat

Confirmed Asshole
Yes, you need a better console. UTF-8 support is key, and ANSI colour support via escape sequences is also necessary. Otherwise, it's just broken, and I don't know how to fix it.

Well, I could make a variant that uses no colour, and non-UTF-8 letters.

Anyway, here's something that can detect the console dimensions on Windows, at least:
http://pastebin.com/LRLFSwmT
 

wolfmat

Confirmed Asshole
Okay, for the poor Windows folks who only have cmd, and anyone else who enjoys ASCII art, here's an alternative: flora_bw.py


(It flickers real bad on cmd though)

I'm done! That's it! Thanks for the bug report, usea! Looking forward to what you guys come up with!

Edit: The second screenshot managed to get there after 6 steps because I adjusted the redraw line, takes too long otherwise with such a big image.
 
Status
Not open for further replies.
Top Bottom