Jump to content
  • Advertisement

bioagentX

Member
  • Content Count

    255
  • Joined

  • Last visited

Community Reputation

130 Neutral

About bioagentX

  • Rank
    Member
  1. Please look at code for question [SOURCE] //Suppose I have the following relationship with nodes containing strings Node node0 = new Node("Random String", null) //the first parameter is for the value of the node, and //the second parameter is where that node points Node node1 = node0 Node node2 = node1; node1 = null; //My question is, will node2 now point to Node0? //If so, how is that possible if node1 is no longer referring to node0? [/SOURCE][/source][/source]
  2. bioagentX

    If you ever played an MGS game...

    Actually, he is the 2nd best character. 2nd only to Solid Snake himself. None of the other Snakes, even liquid, even comes close. Revolver Ocelot is a P.I.M.P BTW: That guy in the picture has pedaphile written all over him. I recommend someone contact that school and fast.
  3. I'm trying to write a program that tests the speeds of three simple sorting algorithms. They are: selection sort, bubble sort, and Insertion Sort. The problem is, I'm not sure if my results are what they should be. I'd really appreciate it if someone could run this code, see how it works on their machine, and possibly inform me of any errors. Basically, there are 9 arrays. The first 3: a1, a2, and a3, are filled with random numbers in the range of 0-4999. The second 3: b1, b2, b3 are filled with numbers already sorted and in correct order. The last 3: c1, c2, c3 are sorted almost entirely, except for the last element which is set to the number 2. I think the sorting functions themselves are correct, so I think the error might lie in the initialization. One of my greates concerns is the fact that the InsertionSort method seems to take 0 milliseconds on an array that is already sorted. Now I know that since the array is already sorted it is going to take less time to sort through it, but shouldn't it take at least a few milliseconds to do this? Anyway, here is the code. I know its a lot to ask, but I've been checking it for like an hour and I can't see what the problem is. [SOURCE] import java.util.*; public class Test { public static void Swap(int a[],int i,int j) { int temp = a; a = a[j]; a[j] = temp; } public static void BubbleSort(int myArray[])//NOTE: This bubble sort does not contain the breakout section { for(int k = myArray.length -1; k>0; k--) { for(int j=0; j<k; j++) { if(myArray[j] > myArray[j+1]) { Swap(myArray, j, j+1); } } } } public static void SelectionSort(int myArray[]) { int minIndex = 0; for(int i=0; i<myArray.length - 1; i++) { for(int j= i + 1; j< myArray.length; j++) { if(myArray[j] < myArray[minIndex]) minIndex = j; } if(i != minIndex) { //swap the numbers Swap(myArray, i, minIndex); } minIndex = i + 1; } } public static void InsertionSort(int myArray[]) { for(int i=1; i<myArray.length; i++) { for(int j=i; j>0; j--) { if(myArray[j]<myArray[j-1]) { Swap(myArray, j, j-1); } else break; } } } public static void main (String[] args){ Date startTime; long sortTime; ////////// randomized arrays /////////// int[] a1 = new int[5000]; int[] a2 = new int[5000]; int[] a3 = new int[5000]; ///////// completely sorted ///////////// int[] b1 = new int[5000]; int[] b2 = new int[5000]; int[] b3 = new int[5000]; //////// almost sorted //////////////////// int[] c1 = new int[5000]; int[] c2 = new int[5000]; int[] c3 = new int[5000]; /////////////////////////////////////////// //set up arrays a1, a2 and a3, where each has 5000 random integers from 1-5000 in it. //see the bottom of p. 329 for an example of how to do it. for(int i=0; i<a1.length; i++) { a1 = (int)(Math.random() * 5000); } for (int j=0;j<a2.length ;j++ ) { a2[j] = (int)(Math.random() * 5000); } for (int k = 0; k<a3.length; k++) { a3[k] = (int)(Math.random() * 5000); } //set up arrays b1, b2 and b3, where each has 5000 integers from 0-4999 in it, perfectly sorted already. for(int i=0; i<b1.length; i++) { b1 = i; } for (int j=0;j<b2.length ;j++ ) { b2[j] = j; } for (int k = 0; k<b3.length; k++) { b3[k] = k; } //set up arrays c1, c2 and c3, where each has 5000 integers from 0-4999 in it, perfectly sorted already. //then set the last element of the array to 2. so it'll go 4996, 4997, 4998, 2. for(int i=0; i<c1.length; i++) { c1 = i; } for (int j=0;j<c2.length ;j++ ) { c2[j] = j; } for (int k = 0; k<c3.length; k++) { c3[k] = k; } c1[c1.length - 1] = 2; c2[c2.length - 1] = 2; c3[c3.length - 1] = 2; //for each array, do the sorts and see how long they take. //test this out going from 0-9 before you do it for 0-4999. //Used to test the arrays /*=============================== THE FOLLOWING IS CODE USED TO TEST THE ARRAYS ======================= */ /* System.out.println("BEFORE SORTS: \n \n \n"); for(int a=0; a<a3.length; a++) { System.out.print(a3[a]+ " "); } System.out.println(""); for(int a=0; a<b3.length; a++) { System.out.print(b3[a]+ " "); } System.out.println(""); for(int a=0; a<c3.length; a++) { System.out.print(c3[a]+ " "); } //////////The selection Sorts////////// //SelectionSort(a3); //SelectionSort(b3); //SelectionSort(c3); /////////The bubble Sorts//////////// //BubbleSort(a3); //BubbleSort(b3); //BubbleSort(c3); ////////the Insertion Sorts //InsertionSort(a3); //InsertionSort(b3); //InsertionSort(c3); /////////////////////////// System.out.println(""); System.out.println("AFTER SORTS: \n \n \n"); for(int a=0; a<a3.length; a++) { System.out.print(a3[a]+ " "); } System.out.println(""); for(int a=0; a<b3.length; a++) { System.out.print(b3[a]+ " "); } System.out.println(""); for(int a=0; a<c3.length; a++) { System.out.print(c3[a]+ " "); } System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println("");*/ //======================================== END OF ARRAY TEST CODE ============================================== //---------------------------------------------- //selection sort startTime = new Date(); SelectionSort(a1); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Selection sort of a1 took: " + sortTime + " ms."); startTime = new Date(); SelectionSort(b1); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Selection sort of b1 took: " + sortTime + " ms."); startTime = new Date(); SelectionSort(c1); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Selection sort of c1 took: " + sortTime + " ms."); //---------------------------------------------- //bubble sort startTime = new Date(); BubbleSort(a2); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Bubble sort of a2 took: " + sortTime + " ms."); startTime = new Date(); BubbleSort(b2); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Bubble sort of b2 took: " + sortTime + " ms."); startTime = new Date(); BubbleSort(c2); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Bubble sort of c2 took: " + sortTime + " ms."); //---------------------------------------------- //insertion sort startTime = new Date(); InsertionSort(a3); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Insertion sort of a3 took: " + sortTime + " ms."); startTime = new Date(); InsertionSort(b3); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Insertion sort of b3 took: " + sortTime + " ms."); startTime = new Date(); InsertionSort(c3); sortTime = (new Date()).getTime() - startTime.getTime(); System.out.println("Insertion sort of c3 took: " + sortTime + " ms."); } } [/SOURCE] Thx, --BioX
  4. bioagentX

    Final Fantasy 7. Serious question

    I played and beat the game about 3 to 4 years ago, so I remember my emotions when I saw that scene quite well. In fact, it was that game, as well as Metal Gear Solid One, that really made me want to be a game developer. Largely in part due to the greatness and quality that I saw in that one scene. First of all, I think the reason why so many people felt affected was because nothing similar had happenned in video games prior. Oh sure, it had happenned in movies all the time--and still does. But when it happens in a videogame, it affects the player a lot more. The player feels responsible--guilty--as if it was their fault. It wasn't aeris in particular that sparked so much emotion, it was the fact that such an innocent character that was doing something innocent (praying) died so brutally. Not only did she die, but she was murdered by a character that seemed to epitamize evil. This fact made her death so much more tragic. I felt this way even though I invested very little time into building up her character. In short, the reason why the scene is so remembered, is because it employed a unique tragedy in a videogame in full blown FMV format. The richness in quality of the video really helped to drive home the emotion, and due to the fact that she was a character that the player could control, players felt they had a closer relationship to the character than those from books or movies. Now onto the music Wihtout the music played in the scene(and there was music..I'd bet my life on it for anyone that didn't agree)it would have been far less affective. Music has a way of enticing the mind and inspring emotion. The sad simple toned melody really conveyed the idea of purity and innocense being killed. Music was important to this scene because the music in essence told us what to think. Music has a way of telling one what to think. If you don't believe me, imagine Aeris's death occuring to AC/DC music? Don't get me wrong, I love AC/DC, but rock is music that gets me excited and happy, not emotional and contemplative. And for that reason, because that music was able to inspire certain emotions, the scene of Aeris's death will continue to be remembered in video game history. [Edited by - bioagentX on December 12, 2004 10:35:45 AM]
  5. bioagentX

    Acid Pro 4.0

    My friend gave me a copy of Acid Pro 4.0 and I'm trying to learn how to use it. First of all, do I need a keyboard to use it? Can I make my own music without remixing previous songs? And where can I find a good tutorial on how to use Acid Pro 4.0? Thx for any help, --BioX
  6. bioagentX

    32-bit - long or int?

    Long will remain 32-bit, int will change to 64-bit when windows makes the change to a 64-bit OS.
  7. bioagentX

    Javascript help

    That doesn't seem to work. Are you sure you told me what I needed to know? In general can you use style sheets to make default event handlers (i.e something like mystyle:onMouseOver{color: red;})? --BioX
  8. I'm creating a website for a friend at this site. Now as you can see the site is far from finished, but my attention is currently focused on the navigation bar on the left. I'm trying to make it so that the link color changes not when the cursor rolls over the link, but if the cursor rolls over anywhere in the entire table cell. Currently the table cell just changes to the color orange, but I want the link color text inside of it to change to yellow. I'd really appreciate it if someone could tell me how I would go about doing this, I've been going at it for like 2 hrs now. Any help is appreciated, --BioX
  9. bioagentX

    Use of pointers in games

    I'm curious though, in this first example, why do you need to use a pointer. Can't you just have something like "Enemy players_current_target" and set it equal to the desired option. Why do you need to use a pointer instead of initializing another object itself? --BioX
  10. bioagentX

    Did "The Punisher" come out yet?

    Was it good?
  11. bioagentX

    Did "The Punisher" come out yet?

    I'm wondering if "The Punisher" hit theaters yet? Did I miss it?
  12. bioagentX

    The deal with Andre Lamothe

    @Mr Hankey: Is that really his significant other? He doesn't seem to happy in that picture.
  13. bioagentX

    The deal with Andre Lamothe

    Does Andre have a wife or kids? I know this is a wierd question but I've been reading some bios about him and I've come to the conclusion that he's probably in his late 30's early 40's. He is so on top of his email responses and he's willing to give so much time to his readers, I'm wondering if he has a family that he is neglecting because of all this kindness. --BioX
  14. bioagentX

    Class problem

    Oh ok, why? Sorry, this is last question I promise, I've been having difficulty with the 'static' keyword for some time. :) --BioX
  15. bioagentX

    Class problem

    Actually wait, its still not quite working. Here is my new code: #include<iostream.h> class Whatever { public: static int x; }; int main(/*int argc, char *argv[]*/) { int Whatever::x; /*for(int i=1; i<argc; i++) cout<<"Argument: "<<argv<<endl; */ return 0; } My error: Compiling... main.cpp c:\microsoft visual studio\myprojects\bittest\main.cpp(19) : error C2655: 'x' : definition or redeclaration illegal in current scope c:\microsoft visual studio\myprojects\bittest\main.cpp(7) : see declaration of 'x' Error executing cl.exe.
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!