![]() |
|
How to not puke while trying to learn to program? - Printable Version +- kanji koohii FORUM (http://forum.koohii.com) +-- Forum: Learning Japanese (http://forum.koohii.com/forum-4.html) +--- Forum: Off topic (http://forum.koohii.com/forum-13.html) +--- Thread: How to not puke while trying to learn to program? (/thread-7147.html) |
How to not puke while trying to learn to program? - IceCream - 2011-01-25 . How to not puke while trying to learn to program? - JimmySeal - 2011-01-25 I don't know if WPF is the best place to start programming. I've been at this programming gig for a while, and WPF still makes my head hurt often. In WPF, there's really no way around all those bindings and dependency properties, and it is a challenge to get a grip on them. It might be worth the time cutting your teeth on some console-based stuff first. As for your specific question, I suggest the following algorithm (pseudocode): for(i = 1 to 3) do pick a grid cell at random if(there is no mark in the grid on or next to that spot) mark that spot while(the selected cell was no good) How to not puke while trying to learn to program? - thurd - 2011-01-25 If you are not forced by external circumstances to use VB or the whole .NET thingy, I'd say ease yourself into programming by learning a language that is friendly to beginners & doesn't overwhelm you with enormous IDEs and lots of functionalities you'll never use. There are tons of really basic guides to Java, Ruby or Python, some of them focus on creating simple windows, grids etc. A simple application like you describe is a matter of sub-100 lines of code in them (some wizards would probably manage with just a couple of lines ).
How to not puke while trying to learn to program? - Gingerninja - 2011-01-25 Tried to learn programming stuff once... took me 15 minutes to to piss on with it to get one line of text to appear on screen when I ran the code. At that point, I sacked it off. Good on you those who have the patience, I certainly didn't. How to not puke while trying to learn to program? - FooSoft - 2011-01-25 It's OK, as a professional programmer I can say WPF makes me puke as well WPF is a terrible, terrible thing to learn as part of your first exposure to programming. I strongly recommend learning something like Python instead.
How to not puke while trying to learn to program? - bombpersons - 2011-01-25 If you're trying to get into programming, I wouldn't suggest starting with Visual Basic. Basic isn't well designed to incorporate a OOP design, which VB.NET tries to do. Also, VB's syntax is ugly as sin. I know quite a few people who had to program in VB for their A-Levels and they hated it. It's also pretty much never used in industry. I'd suggest looking at C# if you want to start programming in .NET, since it means you can easily move up to C++ later on if you want to. However, if you want something very easy to learn, then I'd suggest python. I think Jimmy's got the right idea. All you need to do is generate a random number in a loop, then if the block that number refers to is not next to a block that contains a circle, mark that block and increase a counter and stop when it reaches 3. C# / Psuedo code Code: int i = 0;How to not puke while trying to learn to program? - wccrawford - 2011-01-25 Wow, yeah, you jumped in pretty deep. I'm going to repeat a lot of the advice above: WPF = No! VB = Possible, but... C# = Much better. If I were teaching someone to program today, C# would probably be the language I'd pick, despite not having used it for years now. It's got an excellent (free) IDE, lots of community, good syntax, it's made for GUI stuff... Pretty much everything I'd ask for. How to not puke while trying to learn to program? - wccrawford - 2011-01-25 IceCream Wrote:@JimmySeal:Grid: Look into multidimensional arrays. Pick a block: Look into the Random functions. Know if there's a block next to this the chosen one: Again, multidimensional arrays. How to not puke while trying to learn to program? - JimmySeal - 2011-01-25 You can use C# with WPF just as much as you can use VB.NET, and I agree that it's a much nicer language to work with and probably more widely used overall. But, if everyone else where you are (wherever that is) is using VB.NET, then you might be better off sticking it out. You can't just mix and match the two that easily, and if these other people (whoever they are) need to modify your work, that might also be a problem. But you haven't told us anything about your situation, so I can't say the above for sure. How to not puke while trying to learn to program? - thurd - 2011-01-25 wccrawford Wrote:If I were teaching someone to program today, C# would probably be the language I'd pick, despite not having used it for years now. It's got an excellent (free) IDE, lots of community, good syntax, it's made for GUI stuff... Pretty much everything I'd ask for.There are a few problems with C# though ![]() 1. It's a cheap & inferior rip-off of Java 2. Microsoft is satan How to not puke while trying to learn to program? - JimmySeal - 2011-01-25 thurd Wrote:There are a few problems with C# thoughIn what ways is C# inferior to Java, pray tell? How to not puke while trying to learn to program? - vgambit - 2011-01-25 JimmySeal Wrote:Let's not start this here. This thread is about IceCream learning how to program. No elitism necessary.thurd Wrote:There are a few problems with C# thoughIn what ways is C# inferior to Java, pray tell? That being said, I would suggest starting with Ruby. There are plenty of interactive lessons available online. It's the simplest-to-understand modern language I know. How to not puke while trying to learn to program? - JimmySeal - 2011-01-25 IceCream Wrote:Nobody else will have to modify my programs, so the benefits of using the language everyone else is using (being able to copy bits of code from existing programs, or ask for help if i'm really stuck) i guess should be weighed up against how difficult the language is to learn. I'd like to be self-sufficient as much as possible, and be able to write programs fairly quickly when i think of ideas for experiments. But it could be anything, so i need to use a language that has good flexibility & that i can control lots of different things.I think VB.NET vs. C# is really a matter of preference and neither is much harder to learn than the other. Both have the same sets of features (where it matters) because they operate on top of the .NET framework. There is interoperability between them, in that if one of your colleagues compiles a bunch of functionality into a DLL and gives it out, you can utilize that regardless of which .NET language you're using. If most of your colleagues are using VB.NET, I suggest using that, as it will be easier to get help from the people who are doing stuff similar to what you're doing. How to not puke while trying to learn to program? - nadiatims - 2011-01-25 It's been a long time since I did any programming and have no idea what WPF is but I'll have a crack at an algorithm too. I have absolutely no idea if this algorithm would work though. // marks comments here's your grid. some kind of array holding boolean (marked/unmarked). By default they should be set as unmarked. 1,1;1,2;1,3;1,4; 2,1;2,2;2,3;2,4; 3,1;3,2;3,3;3,4; 4,1;4,2;4,3;4,4; //------------------------code starts here---------------- for(i = 1 to 3)//place the marks { //set a boolean vacant=1 //choose random grid coordinates x=random(1 to 4) y=random(1 to 4) //check vacancy of grid spaces for(j=-1 to 1) { for(k=-1 to 1) { if(x+j,y+k is marked){vacant=0} else{} j=j+1 k=k+1 } } //place mark if space is vacant if(vacant=1){mark (x,y)} else{} } How to not puke while trying to learn to program? - Zarxrax - 2011-01-25 Wow, if you are just starting to program, what you are doing sounds pretty complicated. You really, really need to start off learning the basics. Make a few fun little programs or follow some beginners tutorials to help get used to programming, and start to understand how it all works. Once you become familiar with the basics, its not too hard to add new, specific stuff into your arsenal. How to not puke while trying to learn to program? - battlehymnz - 2011-01-25 I think you should focus on just using text to display your output. Once you get the logic code down, setting it up in a GUI won't sound nearly as difficult as it does now. As far as how to set up the grid, I'd suggest using a multidimensional array. Something like: Code: int[,] grid = new int[3, 3]; /* C# Code */EDIT: Is it just me or is the formatting of this post a little screwed up? How to not puke while trying to learn to program? - Blahah - 2011-01-25 For what it's worth, I'm in a similar situation (have to start producing useful programs at short notice), although I do have some very minor programming experience. I've never done any GUI programming, but I've made basic command-line tools in various languages before losing the will to live. If you do it using Python we can learn together! How to not puke while trying to learn to program? - pm215 - 2011-01-25 battlehymnz Wrote:I think you should focus on just using text to display your output. Once you get the logic code down, setting it up in a GUI won't sound nearly as difficult as it does now.Yeah. A lot of programming is about breaking down problems properly so that you can deal with it one tiny bit at a time. Otherwise complexity in one area will spread its tentacles through the entire program and it'll be impossible to understand. In this case, as battlehymnz says, if you distinguish "how do I work out where I can put these random circles?" from "how do I draw the things on the screen" you've got two hopefully easier problems rather than one hard one. The other thing to note is that the answer to the "random circles" part is not very dependent on your choice of programming language or graphics or whatever. The syntax might differ, but a reasonable solution is going to look pretty similar in most procedural languages (ie most ones you might be using). Solving this kind of problem is really about logic and knowing the basic data structures and features of the programming language (and is the kind of problem that might be used as a teaching problem for learning to program). Actually drawing circles, on the other hand, is where you end up with something that's strongly tied to your programming language, graphics library and so on. Solving problems in this part is likely to involve a lot of looking things up in the documentation to answer questions like "how do I draw a circle in red rather than blue?". This is another reason this is a good place to split the problem up -- you don't have to keep switching how you're thinking about things. PS: if it is important for the research that the random circle layout has an exactly 1 in N chance of being one of the N valid layouts of circles, you might need to think carefully about how you're generating it to be sure you're not accidentally making some layouts more likely than others. If you just want it to be "vaguely random" then this probably isn't a problem. How to not puke while trying to learn to program? - bombpersons - 2011-01-25 The way I would do it would be to use create a node like object for each block. Each node would contain a list of pointers to other nodes that are next to them. That way all you would need to do is add a method to loop through all the references and check if the node is marked to the node class. in C# Code: class NodeI've used this method before to create a boggle game that could solve itself using radix trees for one of my university module assignments. How to not puke while trying to learn to program? - chamcham - 2011-01-25 NOTE: I thinking of a 4x4 grid in terms of x,y coordinates. They range from (0,0) to (3,3). Also, I'm assuming no wrap-around (i.e. one edge of the 4x4 matrix wrapping around to the other side). Here's how to check for adjacency (i.e. are the points next to each other): For example, Let's take points A and B. a)Subject the x-coordinates of A and B. Take the absolute value of that. b)Subject the y-coordinates of A and B. Take the absolute value of that. c)If either of those numbers is greater than 1, then you're good to go..... :-p It makes sense if you think about it. If either the x or y coordinates is more than 1 square away, then the circles are NOT next to each other. Otherwise, they are next to each other. Considering that we need to make 3 points here's what to do (for a 4x4 square). Point A= random point in the square Point B = take point A and move 2 or 3 (chosen at random) points in the x-direction Point C = take point A and move 2 or 3 (chosen at random) points in the y-direction If you think about it, in a 4x4 square, two points are either 0, 1, 2, or 3 squares away (including diagonals). Zero squares is not acceptable since we want 2 distinct points. One square is not acceptable, since we don't want the squares to be next to each other. So that leaves us with being 2 or 3 squares away. Finally, when you have the coordinates, you can build the array as follows: Initialize an array to zero. Circle1 = A Circle2 = B Circle3 = C No loops needed.... :-) If you need to account for wrap-around, some changes are necessary. How to not puke while trying to learn to program? - brianobush - 2011-01-25 Just to chime in with others against VB. It isn't the best way to start off. Something simpler is usually best to get your feet wet. python is a good choice. How to not puke while trying to learn to program? - iSoron - 2011-01-25 chamcham Wrote:Considering that we need to make 3 points here's what to do (for a 4x4 square).You will never generate this configuration: ● ○ ○ ○ ○ ○ ● ○ ○ ○ ○ ○ ○ ● ○ ○ And if you are unlucky, you may end up with two adjacent points: ○ ● ○ ○ Three ← steps results in ○ ● ● ○ (assuming you wrap around) EDIT: Here's a python implementation. Squares are numbered from 0 to 15 like this: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Code: from random import randintHow to not puke while trying to learn to program? - Thora - 2011-01-25 Icecream, does this mean they extended your short-term stay in Kyoto? Whatever the plan, I'm so glad it's working out for you. I showed your report to my friend who had left the investment banking jungle to research african jungles. I was surprised to see photos of the chimpanzee's using computers! [edit: in your report] He knew about your lab and said your boss is well respected. This friend did his masters in something related to wildlife conservation and is now worked on his PhD in something related to animal congnition and evolution. He's made 2 wildlife documentaries and a children's TV show (kind of an animal version of mythbusters). I thought you might find his career change story inspiring. :-) Excuse the interruption folks - back to your wizardry. (I don't think my experience with pencilled and punched cards, paper ribbons, dingy basement lab and overnight waits for the results would help much.) lol How to not puke while trying to learn to program? - shadysaint - 2011-01-25 Just to throw my 2 cents in... Learn to program with Java and Python. Both of these languages are rather straightforward as far as the fundamentals of programming are concerned. And more importantly, they are actually useful (unlike VB). Although if you're an engineer, I would suggest learning Octave (and/or Matlab). How to not puke while trying to learn to program? - chamcham - 2011-01-25 iSoron Wrote:I wasn't assuming wrap around and even stated that.chamcham Wrote:Considering that we need to make 3 points here's what to do (for a 4x4 square).You will never generate this configuration: But on second thought, my first solution was incorrect. I thought about wrap around and it actually makes the problem easier. Point A= random point in the square Point B = take point A, move 2 points in the x-direction and choose any y-coordinate Point C = take point A, move 2 points in the y-direction and choose any x-coordinate It's a right triangle and none of the points will ever be adjacent to one another. |