View Single Post
Old 07-27-2003, 11:18 AM   #14 (permalink)
Quadraton
Addict
 
Location: Ottawa, ON, Canada
Holy Cripes!

The guy just learned the fundamentals of programming, and most of you are already suggesting he get into things like OpenGL and DirectX. You're going to make his brain explode

You're probably going to want to stay away from those things for now, because they can be quite advanced, even when performing seemingly simple tasks. And just a quick example of how complicated it can get, putting a simple pixel on the screen using DirectX is a matter of initializing DirectDraw, setting the drawing mode, creating a primary surface (and any optional clippers), getting a pointer to the surface, locking it, and knowing where to enter the value representing the colour into the surface's buffer. Not something you should be doing when you're just learning the fundamentals of programming, especially when you add the fact that DirectX is written entirely using COM.

Instead, what you should really do is start out with simple programs. I think that <B>Edvard_Grieg</B> was on the right track with his hangman game, but I just think it uses too much file accessing and parsing, which tend to be more novice skills. If you're only at the point where you've just learned abstract data fundamentals and multidimensional arrays, I would start out even simpler.

You could start out by writing a calculator that takes in a formula and spits out a response. Then when you've done that, try writing a calculator that takes input in Polish notation (you'll have to look that one up on the Internet). However, this idea is almost too simple, and won't keep you busy for long.

Instead, a good suggestion would be to write a text based program that simulates a scenario of some sort. Simulations tend to be more focussed on the thought process (i.e. figuring out how to simulate the scenario), but still use a lot of fundamental programming skills during the implementation.

Two good suggestions from my college days:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1) A line at a bank.

Create a single queue at a bank, with X amount of tellers open to serve the bank customers. Each teller takes a random amount of time (say between 1 to 10 minutes) to serve a customer before they can service another customer.

Give the bank line twenty customers, and see how long on average it takes for the 20th customer to be served if there are 2 tellers, 3 tellers, 4 tellers, etc. up to 10 tellers.

This actually becomes an interesting exercise, because you should be able to see a point where the efficiency of the bank peaks, and adding more tellers no longer improves efficiencies.

2) The life of a forest

This one is nice, because it actually uses two dimensional arrays. Basically, the idea is to create a two dimensional array (the size is up to you), and each element in the array represents an area in a forest. The areas can have three states: T = Full of green trees, I = Infested with insects, and D = Deforested

When the forest is displayed on the screen, you advance the forest through time periods by pressing a key. The rules for moving the forest through a time period are as follows:
- any 'T' that has an adjacent 'I' will become an 'I'
- any 'I' will be changed into a 'D'
- any 'D' will be changed into a 'T' (I believe you're only supposed to change the 'D' after <B>two</B> time periods have elapsed, but if this doesn't give you desirable results, try switching it back to one time period)

You decide what I mean by 'adjacent', whether it's only on the four major compass points (N, E, W, S), or if it's all eight points. To start the simulation, initialize several different arrays with different scenarios, such as:

T T T T T
T T I T T
T I D I T
T T I T T
T T T T T

or

T T T T T
T I D I T
T D T D T
T I D I T
T T T T T

And let them run, outputting the new forest after every time period. You could even create a user interface that allows the user to choose amongst several scenarios, and keeps track of how many time periods have elapsed.

As an extended challenge, if you know how to do text programming, you could give each forest state its own colour (i.e. T is green, I is purple, and D is brown), and instead of drawing a new array on the screen underneath the old array everytime a time period elapses, overwrite the old array on the screen. This method actually gives a stunning effect of animation if you just skip the key pressing, and let it run automatically (with a delay() to slow things down a bit).

=-=-=-=-=-=-=-=-=-=-=-=-=-

These are just a couple of ideas that I could think of off the top of my head. I'm hoping I was clear enough in my examples, but if you need any elaboration, just let me know, and I'll try to give a better description.
__________________
"A witty saying proves nothing"
- Voltaire

Last edited by Quadraton; 07-27-2003 at 11:35 AM..
Quadraton is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360