• Programming challenge #1
    26 replies, posted
So, an idea came up where you use a programming language obscure to you to create a requested application. The rules are as follows: 1) You must have little to no experience in the language. 2) You cannot use existing code however, public libraries are fine. 3) The code must be included with your submission. 4) The project must meet the criteria of the request. Here's the challenge list: 1) Using F# create a 3D ball that rolls around a plane and pushs other balls on the same plane. Due in five days. 2) Using C#, create a 3D stress-toy that you can "squeeze" from different angles. Due in 7 days.
Lets just do the example request to get the ball rolling. :v:
[QUOTE]Using C#, create a 3D stress-toy that you can "squeeze" from different angles. Due in 7 days.[/QUOTE] Stress toy for anyone who doesn't know: [img]http://cn1.kaboodle.com/hi/img/2/0/0/e5/5/AAAAAiJyw_UAAAAAAOVaEg.jpg?v=1206701421000[/img]
The looks like a blue balled baby alien with blood pouring from all its' orifices :(
It kind of looks like a clown where they missed painting the hood thing that it's wearing.
It's been the most used object in my room for the last two weeks :v:
hmmm I just finished sphere generation in C#, but that's with subdivision and everything... I could try my hand at the F# one considering you can use OpenTK as the OpenGL bindings, and the physics for that seem very simple. I'll just not use my C# sphere generation code and manually type out the coordinates for a unit sphere.
Are we allowed to read tutorials on the language, especially if we haven't used it before?
[QUOTE=kidwithsword;31069963]Are we allowed to read tutorials on the language, especially if we haven't used it before?[/QUOTE] Yes; the objective is to provide a challenge that forces you to learn.
and this, my friends, is how you create an OpenGL window in F# using OpenTK! [img]http://i.imgur.com/nTWxP.png[/img] [editline]13th July 2011[/editline] F# is strangely elegant in it's own way. It seems very impractical to use as a language for larger projects, and my biggest gripe is it's lack of ability to parse tabs properly... I don't want to set VS back to using spaces instead of tabs.
Wow I'm a noob at programming but would love to learn.
[QUOTE=robmaister12;31085241]and this, my friends, is how you create an OpenGL window in F# using OpenTK! [img]http://i.imgur.com/nTWxP.png[/img] [editline]13th July 2011[/editline] F# is strangely elegant in it's own way. It seems very impractical to use as a language for larger projects, and my biggest gripe is it's lack of ability to parse tabs properly... I don't want to set VS back to using spaces instead of tabs.[/QUOTE] Words cannot describe...
F#'s type inference is pretty awesome, this code is valid: [csharp]let calcSphere(rho, phi, theta) = let x = rho * sin(float32 phi) * cos(theta) let y = rho * sin(phi) * sin(theta) let z = rho * cos(phi) new Vector3(x, y, z)[/csharp]
[QUOTE=robmaister12;31096988]F#'s type inference is pretty awesome, this code is valid: let calcSphere(rho, phi, theta) = let x = rho * sin(float32 phi) * cos(theta) let y = rho * sin(phi) * sin(theta) let z = rho * cos(phi) new Vector3(x, y, z)[/QUOTE] I might look into F#. It looks interesting.
[QUOTE=robmaister12;31096988]F#'s type inference is pretty awesome, this code is valid: [csharp]let calcSphere(rho, phi, theta) = let x = rho * sin(float32 phi) * cos(theta) let y = rho * sin(phi) * sin(theta) let z = rho * cos(phi) new Vector3(x, y, z)[/csharp][/QUOTE] That's awesome! I'm going to spend some time with F# later.
should I keep posting updates here? I just finished sphere generation, it's a lot simpler when you realize there's a thing called [url=http://www.math.montana.edu/frankw/ccp/multiworld/multipleIVP/spherical/learn.htm]sphere coordinates[/url]... anyways: [img]http://i.imgur.com/FJlux.png[/img] [editline]13th July 2011[/editline] oh, I just realized... that website uses a z-up coordinate system, just flipped y and z and now getting the side view that I should be getting with a default frustum... [editline]13th July 2011[/editline] also that image had a weird projection applied to it because of glFrustum, I figured it would work better than the Matrix4 methods I'm using in my own personal C#/OpenTK project (or at least be lighter) but I just switched to it and it's projecting just fine now. I'll probably update again once I port my camera class over from C# (it's just a Vector3 position and some math for calculating the view matrix, if I'm going to rewrite it I'll end up doing the exact same math anyways)
this looks really fun i might partake into learning F# later
[QUOTE=robmaister12;31102195]should I keep posting updates here? I just finished sphere generation, it's a lot simpler when you realize there's a thing called [url=http://www.math.montana.edu/frankw/ccp/multiworld/multipleIVP/spherical/learn.htm]sphere coordinates[/url]... anyways: [img]http://i.imgur.com/FJlux.png[/img] [editline]13th July 2011[/editline] oh, I just realized... that website uses a z-up coordinate system, just flipped y and z and now getting the side view that I should be getting with a default frustum... [editline]13th July 2011[/editline] also that image had a weird projection applied to it because of glFrustum, I figured it would work better than the Matrix4 methods I'm using in my own personal C#/OpenTK project (or at least be lighter) but I just switched to it and it's projecting just fine now. I'll probably update again once I port my camera class over from C# (it's just a Vector3 position and some math for calculating the view matrix, if I'm going to rewrite it I'll end up doing the exact same math anyways)[/QUOTE] Yes, please do.
-snip- sorry it's an old program back when i didn't know diddily squat about c# thats the way i was taught
people would be better off looking into [url=http://msdn.microsoft.com/en-us/library/a72418yk(v=VS.100).aspx]actual beginner tutorials for C#[/url] than 20 lines of uncommented, unexplained code that is a bit convoluted in the way it's done. (you should use number.Length instead of just 1000, better yet just use a foreach loop since you never need to know the current index. Also "i" is generally used as the iteration variable, x is usually used as the x coordinate of a vector or for math methods. Your indentation for the last 4 Console.WriteLine lines are incorrect, and you can turn all those lines into one - Console.WriteLine("The largest number is " + largest + " and the smallest number is " + smallest + ". Press any key to continue...")
[QUOTE=robmaister12;31104716]people would be better off looking into [URL="http://msdn.microsoft.com/en-us/library/a72418yk(v=VS.100).aspx"]actual beginner tutorials for C#[/URL] than 20 lines of uncommented, unexplained code that is a bit convoluted in the way it's done. (you should use number.Length instead of just 1000, better yet just use a foreach loop since you never need to know the current index. Also "i" is generally used as the iteration variable, x is usually used as the x coordinate of a vector or for math methods. Your indentation for the last 4 Console.WriteLine lines are incorrect, and you can turn all those lines into one - Console.WriteLine("The largest number is " + largest + " and the smallest number is " + smallest + ". Press any key to continue...")[/QUOTE] that would of been helpful about 3 years ago [editline]14th July 2011[/editline] thanks for the tip though
no problem, if you keep plugging away at projects and looking at other people's source code, you'll eventually pick up some common coding styles and shortcuts. [editline]14th July 2011[/editline] I have to be at my internship tomorrow, so I won't get much done on this tomorrow. Here's my current progress: sphere generated, proper perspective frustum created, rewrote a simplified version of my C# Camera class to get camera movement, added lighting. There's one missing triangle (off by 1 error) that I'm too tired to fix right now, but I'll fix that some time tomorrow. It's all deprecated OpenGL - glVertexPointer, glVertexNormal with VBOs, lighting with glLight [img]http://i.imgur.com/bS9wU.png[/img] I think the real beauty of F# will shine once I start writing the physics, there's a lot of sequencing and iteration stuff in F# that made generating this sphere much easier than it was in C# (plus I figured out what sphere coordinates were, and I'll be going back to apply that to my sphere class in C#), so iterating through a List of spheres. After this is done, I'll probably toss it up on github and put some sort of open source license on it (thinking LGPL, any suggestions?) [editline]14th July 2011[/editline] fixed that off by 1 error, forgot that 0 % 8 = 0... off to bed now :v:
[QUOTE=robmaister12;31105668]no problem, if you keep plugging away at projects and looking at other people's source code, you'll eventually pick up some common coding styles and shortcuts. [editline]14th July 2011[/editline] I have to be at my internship tomorrow, so I won't get much done on this tomorrow. Here's my current progress: sphere generated, proper perspective frustum created, rewrote a simplified version of my C# Camera class to get camera movement, added lighting. There's one missing triangle (off by 1 error) that I'm too tired to fix right now, but I'll fix that some time tomorrow. It's all deprecated OpenGL - glVertexPointer, glVertexNormal with VBOs, lighting with glLight [img]http://i.imgur.com/bS9wU.png[/img] I think the real beauty of F# will shine once I start writing the physics, there's a lot of sequencing and iteration stuff in F# that made generating this sphere much easier than it was in C# (plus I figured out what sphere coordinates were, and I'll be going back to apply that to my sphere class in C#), so iterating through a List of spheres. After this is done, I'll probably toss it up on github and put some sort of open source license on it (thinking LGPL, any suggestions?)[/QUOTE] Yes, F# is a mathematical language after all.
F# = .NET scripting language?
[QUOTE=mmavipc;31144110]F# = .NET scripting language?[/QUOTE] yep
Ehm, F# is not a scripting language but a fully fledged functional programming language for .NET
[QUOTE=Shammah;31171912]Ehm, F# is not a scripting language but a fully fledged functional programming language for .NET[/QUOTE] You've gotta admit though it looks quite nice for a scripting language to use with .NET
Sorry, you need to Log In to post a reply to this thread.