Jump to content
  • Advertisement

Skizz

Member
  • Content Count

    1310
  • Joined

  • Last visited

Community Reputation

794 Good

About Skizz

  • Rank
    Banned
  1. Skizz

    linked list question

    I never intended to put anyone off programming and I'm sorry if that's the way it appeared. Skizz
  2. Skizz

    linked list question

    It's interesting how saying that programming might not be your best career option leads to such responses. Do other careers have the same issue? If I was tone deaf and training to be a violinist, would advice along the lines of 'this ain't for you kid' lead to similar outcry1? The article I indirectly linked to not only identified the double bell curve indicating that there are people who 'get' programming and those who don't, but also went on to say that even after a few years of tutoring and teaching, very few people moved from one group to the other. linternet, you are quite right, I am not the best programmer and I know it. I spend a lot of free time learning about programming, trying out new ideas, new languages, going over old code and so on. It would be true to say that there is no such thing as 'the best programmer' - the field is too huge. However, I do believe that there should be a minimum level of competence required before calling oneself a software engineer, more than a degree - other engineering disciplines have them, why not programming? It's a complex issue, there is definately a lot of code being written that is sub-standard but at the same time there's few ways to identify at interview who's going to produce the goods. Perhaps we delude ourselves with new and feature rich IDEs into thinking that anyone can program and that it is much easier than it really is. Or maybe it's a management issue not understanding the complexities of what appears to be simple. Also, linternet, don't feel too bad about being bashed on these boards, it's even happened to me. These days I make sure I double check what I post, even writing test applications to verify code. Skizz 1. But then we wouldn't have Beethoven
  3. Skizz

    linked list question

    As for the original linked list problem. Whatever you do, don't brute force a solution by trying out every combination of pointer manipulation you can think of. Take a step back and get out a piece of paper and a pencil and draw out the problem using boxes for the nodes and lines for the links and produce a sequence of steps that transform what you have into what you want. This pencil-and-paper technique is very useful, especially in interviews where they sometimes try to confuse you. It has happened to me - an interview question had a linked-list style structure but the implementation obfuscated the algorithm and stored the nodes in reverse order - new nodes added to the front of the list. Only through drawing the lists on paper as the code executed did the subtle trick become apparent. Before: |-------| |-------| |-------| L1 --->| A *---+-->| B *---+-->| C | |-------| |-------| |-------| |-------| |-------| |-------| L2 --->| 1 *---+-->| 2 *---+-->| 3 | |-------| |-------| |-------| Step 1: |-------| |-------| L1 --->| A *---+-->| B | |-------| |-------| |-------| |-------| |-------| L2 --->| 1 *---+-->| 2 *---+-->| 3 | |-------| |-------| |-------| |-------| R1 --->| C | |-------| Step 2: |-------| |-------| L1 --->| A *---+-->| B | |-------| |-------| |-------| L2 --->| 1 | |-------| |-------| R1 --->| C | |-------| |-------| |-------| R2 --->| 2 *---+-->| 3 | |-------| |-------| and so on.... After: |-------| |-------| |-------| |-------| L1 --->| A *---+-->| B *---+-->| 2 *---+-->| 3 | |-------| |-------| |-------| |-------| |-------| |-------| L2 --->| 1 *---+-->| C | |-------| |-------| This will hopefully show you which pointers need changing at each stage. Skizz
  4. Skizz

    linked list question

    Quote:Original post by Simian Man Besides, how do you know what daniel_i_l's goals in the field are? He could be a math student who just needs the basics. That would be a very badly designed course if the student needed to understand pointer manipulation in a language like C/C++ as a 'basic' requirement. Surely, a maths student would be better off using something like matlab? This question is computer science style question - abstract and unlikely to be of any use to real world development (hands up, who's needed to do this in a real world application?) If it's learning for fun then that is to be encouraged - there's nothing like learning new things (I still do). The caveat of course is that finding this difficult could be a sign that programming isn't going to be an enjoyable career. Skizz
  5. Skizz

    linked list question

    The major problem with software is that anyone can do it and produce something that works which leads others less technical to think they are capable. There is no professional status or accredition that is applied to software developers the way it is done in, say, electronics. As an analogy, I toyed around with electronics as a kid and even made some circuits work but I never got the hang of how a transitor really worked and as such would not really have much chance of getting a job designing electronic circuits (even after doing it to degree level - thankfully the software half of the course pulled me through). Software seems to be different in that lots of people think its the job for them but there's no one around to say otherwise. Perhaps if there was a more rigorous professional status to go with the software development job, then we might not have so much buggy software (and no need for stupid EULAs that accept no responsibility for faulty code). From my own experience, I have worked with very few (i.e. < 10) good developers in my 18 or so years of professional software development (i.e. being paid to do it). Most of the coders I work with, now and in the past, produce poor code and don't spend time refining their skills. Here are two anonymised examples from the project I am currently working on: // first example block_of_code while (condition) { block_of_code // identical to code above } // second example - convert drive number to drive letter switch (drive_number) { case 1: drive_name = "A"; break; case 2: drive_name = "B"; break; case 3: drive_name = "C"; break; // repeated in same manner until... case 26: drive_name = "Z"; break; } This level of coding is the norm! The company I'm currently contracting for has a C test as part of its interview process. The interviewee is given a PC with a default installation of DevStudio - a tool required for the job (would you hire a plumber who didn't know how to use a spanner?) The first coding question involves writing an algorithm to sort an array (bubble sort will do) and the second is to solve the 8 queens on an 8x8 chess board problem. Both problems can be solved in a dozen or so lines of code. Of all the interviews done since they started doing this test, some get the sorting problem but no one has managed the queen problem. One person even sneaked out the building. The point I'm trying to make, based on personal experience and the comments on several web sites (this being one) is that most potential software development employees really can't do the job and never get any better. There's nothing wrong with elitism, many professions fall into this - doctors, engineers, etc. and it may make things better if there was more of it in software. The truth hurts1. Skizz 1. Maybe not as much as jumping on a bicycle with no saddle.
  6. Skizz

    linked list question

    This looks like a homework question which reminded me of this blog. It makes a very interesting point and the academic link is interesting as well. To sum it up, if you plot programming ability against a population sample, you will end up with a double-bell curve: Ability | | *** *** | * * * * | * ** * |** ** --------------------- | which roughly means that you can divide the population into two groups - those that can program well and those that can't. The linked references above note that very few people managed to move from the non-programmer set to the other. The point is, linked lists and pointer manipulation are fairly basic and fundamental concepts for a programmer. Maybe you should work out which set you are in and then re-evaluate your future. You don't want to be the guy that ends up with code appearing here. Skizz
  7. Skizz

    designing scripted AI for a game

    In the same way that you'd have varying levels of detail when rendering graphics, your AI should be dynamically scalable as well. Characters that aren't in the player's vicinity do not need to update as often or as accurately. Don't fix you update interval, rather, have the interval determined by the proximity of the character to the player. Also, make sure the low frequency updates are staggered so the load is spread more evenly. As for multithreading, it's not an easy thing to implement. You could update AI in a separate thread, but the synchronisation is going to be difficult. Alternatively, you could use a job system whereby the non-main game threads process jobs from the AI, such as path finding, i.e. AI creates request to find path from current position to target, when thread finds a result, the result is sent back to the AI generating the request and the AI's state is updated. Of course this could mean the AI gets smarter at finding routes as more processors are added to the system which in turn leads to gameplay balancing issues. Skizz
  8. Skizz

    "Double" switch statements?

    Quote:Original post by ramearess As mentioned above you probably want a if else block. if (X==0 && Y==0) cout<<0; else if (X==0 && Y==1) cout<<0; else if (X==0 && Y==2) cout<<0; else if (X==1 && Y==0) cout<<0; else if (X==1 && Y==1) cout<<1; else if (X==1 && Y==2) cout<<2; else if (X==2 && Y==0) cout<<0; else if (X==2 && Y==1) cout<<2; else if (X==2 && Y==2) cout<<4; else if (X==3 && Y==0) cout<<0; else if (X==3 && Y==1) cout<<3; if else (X==3 && Y==2) cout<<6; else cout<<"Lyk, oh em gee, the numbers are outta bounds"; To quote Roboguy, you could, but please don't. Following SiCrane's comment, here's why: 1. It's a linear operation, O(n) 2. It's a bit obfuscated, especially if the number of if-elses becomes large 3. It's a maintenance nightmare 4. It's static, the lookup can't dynamically change As for the X*c+Y method, if ever Y >= c then you'll get problems. I personally think a state map is the best option: // This class is used to compare states class State { public: State (int x, int y) : m_x (x), m_y (y) { } friend bool operator < (const State &lhs, const State &rhs) { return lhs.m_x < rhs.m_x ? true : lhs.m_x > rhs.m_x ? false : lhs.m_y < rhs.m_y; } private: int m_x, m_y; }; // for this example, this defines the result for a given state and can // be used for a switch statement enum StateID { State0, State1, State2, State3, State4, State6 }; void main () { // this is the lookup map <State, StateID> states; // set up states // in this example, the state lookup is integral // there's no reason the lookup can't be a function pointer // this only needs to be done once states [State (0, 0)] = State0; states [State (0, 1)] = State0; states [State (0, 2)] = State0; states [State (1, 0)] = State0; states [State (1, 1)] = State1; states [State (1, 2)] = State2; states [State (2, 0)] = State0; states [State (2, 1)] = State2; states [State (2, 2)] = State4; states [State (3, 0)] = State0; states [State (3, 1)] = State3; states [State (3, 2)] = State6; // do some test lookups // first, a valid search map <State, StateID>::iterator result = states.find (State (2, 1)); if (result != states.end ()) { cout << (*result).second << endl; } else { cout << "Not found" << endl; } // now, an invalid search result = states.find (State (10, 9)); if (result != states.end ()) { cout << (*result).second << endl; } else { cout << "Not found" << endl; } } By using a std::map the lookup can change dynamically by adding / removing entries in the map. Skizz
  9. Skizz

    [.net] Serialization

    The .Net framework has a system for serialising classes, namely through the use of attributes. For example: [Serializable] class AClass { int m_member1; [NonSerialized] int m_member2; } The above class is marked as a class that can be serialised. Usually, all members are serialised but this can be overridden using the NonSerialized attribute or by implementing the ISerializable interface. Link to the MSDN description of the Serializable attribute an an example of how to use it. Skizz
  10. You are not calling Form1_Load from anywhere, unless you've removed some code in your post. Skizz
  11. Skizz

    Help with horizontal scrolling

    The value for gOffset must be bounded: 0 <= gOffset < gTextureWidth (or gTextureHeight for vertical scrolling) Consider what would happen should gOffset lie outside those bounds - the rectangle for the first draw command will is: rct.left = gTextureWidth-gOffset; rct.right = gTextureWidth; and if gOffset is < 0 then the left edge will be to the right of the right edge, which is clearly nonsense. So, the update to gOffset should really be: gOffset -= 4; if (gOffset < 0) gOffset=gTextureHeight; But you should really check the value is in the required bounds: if (gOffset < 0) gOffset=gTextureHeight; if (gOffset > gTextureHeight) gOffset=0; Skizz
  12. Skizz

    Help with horizontal scrolling

    If you understood how it scrolled vertically, getting it scroll horizontally would be trivial. The scrolling is done by drawing the image twice: |--------| | | <- first image | | ********** -| * * |- = distance = gOffset *--------* -| * * * * <- * = screen ********** | | <- second image |--------| Rather than drawing the whole image twice, only the visible portion of each image is drawn. Once you've determined how the co-ordinates are calculated, rotate the diagram to work out the new co-ordinates (effectively swap top/left, bottom/right, width/height). Skizz
  13. Skizz

    Getting HBITMAP from a DC

    Quote:Original post by irreversible equivalent of GetDIBits() that'd allow me to get a subsection of rdc into a buffer (eg a width x height patch at coordinates x, y). See my previous post, i.e. BitBlt. Skizz
  14. Skizz

    Source code request

    The main items the company will be looking for are: 1) That you wrote the code 2) The code is well structured 3) The code is understandable with appropriate comments 4) The code is well written I would say that you should send as much as possible. Anything that you consider sensitive and confidential you could do something like: void SensitiveFunction () { // code removed // This code is the result of personal research and can be viewed/discussed in // person upon request } Or something like that. Don't be too aggressive though as it will put potential employers off. Skizz
  15. Skizz

    Getting HBITMAP from a DC

    From the MSDN for SelectObject: Quote: The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type. What type of object is NULL? Is a BITMAP, a BRUSH, a PEN, a FONT or anything else that can be selected into a DC? To get the current contents of a portion of the thing a DC is drawing on you need to do the following: 1. Create a new bitmap 2. Create a new DC 3. Select new bitmap into new DC 4. BitBlt from DC of interest into new DC But if all you want is the dimensions and/or the format of the thing the DC is drawing to then you need to use GetDeviceCaps (link to MSDN information). Skizz
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!