Game structure

Hi .
Thinking about to organize code, I was wondering, if, it wouldn´t be better, instead of creating a new Game instance when restarting the game, if I should create a restartGame method inside Game´s class. Maybe, that´s a better approach, if I need to remove all listeners, stop all movieclips, nullify some references, etc.
Or maybe, just an endGame and an initiate method
Thanks

either is ok as long as there's nothing left in memory from a previous game that won't be re-used in the next game.

Similar Messages

  • Flash 9 Game Structure

    I just switched from flash 8 to flash 9 and am looking for
    tutorials to make a simple game where you move a character just so
    I can get a feel for the structure of a Flash 9 game. You can't put
    ActionScript into movie clips anymore. I heard you have to make
    everything classes and put them in seperate files. Do you need to
    do this? Can the ".as script files" be in the same folder as the
    SWF or do they have to be in a certain folder structure? I am
    completely lost.

    This behavior is also reproducible on firefox 1 / flash 9 as
    well was firefox 2 / flash 9. The seg fault appears regardless of
    whether the plugin is installed system-wide or to a single profile.
    See:
    related
    thread on Ubuntu forums

  • Help with Game Display structure and adding independant objects

    I'd like to do two things and I'm not sure how to set up the code.
    1) Add 1 to n enemies that think and move on their own. Basically their own threaded life I think.
    2) Add 1 to n weapons fire that when the thread is finished apply the damage.
    Currently I'm only using Graphics2d to draw everything to an off screen image. The issue I have is that most of the individual object stuff is wrapped up in the main game loop rather than added to the object itself.
    Here is my current working pseudo code: I have this working but seems like I need to make it more flexible. Just not sure how.
    public class combatDisplay extends JPanel{
    @Override
    protected void paintComponent(Graphics g){
         creates Graphics2d offScreenImage
         wipeClean offScreenImage
         drawPlayers 0 to n
         drawSpaceShip 0 to n --> drawMe(offScreenImage);
         drawWeaponShots 0 to n
         drawExplosions 0 to n
         draw offScreenImage to panel
    public void setPlayers (ArrayList al) {}
    public void setObjects (ArrayList al) {}
    public void setSpaceShips (ArrayList al) {}
    public void setWeaponShots (ArrayList al) {}
    public void setExplosions (ArrayList al) {}
    class Spaceship{
         Point location
         Polygon shape
    public void drawMe (BufferedImage bf){
         draw Polygon
    class WeaponShot{
         Point location
         Polygon shape
    public void drawMe (BufferedImage bf){
         draw Polygon
    class GameLogicLoop {
         movePlayer
         moveEnemies
         fireWeapons
            applyDamage
    }It seems like I should just spawn an enemy thread that checks its own ranges and does its own movements. But I'm not sure how to get that to display the offscreen image. Can an arraylist hold a thread?
    Likewise, with the weapons fire.... it should be self contained to check hit, display itself, display explosion or hit, then apply damage to its target when animation is completed. These two seem like a similar code structure I'm just not sure how to set it up yet.
    Any psuedocode would be helpful.

    Morgalr,
    Awesome responses thanks. Normally I don't code so it is an interesting (read hard) learning curve for me. Usually I just design and hire someone smarter than me to code.
    If you don't mind taking a look, I tried reworking everything toward the approach we have been discussing. If you see anything glaring and troublesome, please yell.
    Ship Class is its own thread that can paint itself. Basically it is a sitting ship.
    DisplayPane is the image painting class.
    loopGame tells the objects when to paint and passes the image reference around.
    package controller;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Polygon;
    import java.awt.image.BufferedImage;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class Controller extends JFrame {
        DisplayPane pane;
        Ship satallite;
       public Controller(){
            setTitle("Controller");
            setBounds(0,0, 400, 400);
            setLayout(null);  //absolute position
            setResizable(false);
            pane = new DisplayPane(getBounds().width, getBounds().height);       
            add(pane);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLocationRelativeTo(null);
            setVisible(true);
       class DisplayPane extends JPanel{
           BufferedImage offImage;
           public DisplayPane(int width, int height){
               offImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
               setBounds(0, 0, width, height);
           @Override
           protected void paintComponent(Graphics g){
                g.drawImage(offImage,0,0,this);
           public BufferedImage getImage(){
               return offImage;
           public void setImage(BufferedImage tempImage){
               offImage = tempImage;
           public void wipeImage(){
                Graphics2D big = offImage.createGraphics();
                big.setColor(Color.BLACK);
                big.fillRect(0, 0, getBounds().width, getBounds().height);
       class Ship implements Runnable{
           Thread thread;
           int speedStep;
           boolean bAlive = true;
           Point point = new Point(0,0);
           public Ship(String shipName, int speed){
               thread = new Thread(this, shipName);
               speedStep = speed;
               point.x = (int) ((int) 300 * Math.random());
               point.y = (int) ((int) 300 * Math.random());
           public void start(){
               thread.start();
           public void kill(){
               bAlive = false;
           public void drawShip(BufferedImage tempImage){
                Graphics2D big = tempImage.createGraphics();
                int[] pXfrigate = {point.x, point.x-4, point.x-4, point.x+4, point.x+4};
                int[] pYfrigate = {point.y, point.y+7, point.y+17, point.y+17, point.y+7};
                Polygon frigateShape = new Polygon(pXfrigate, pYfrigate, 5);
                Polygon currentShip = frigateShape;
                big.setColor(Color.GRAY);
                big.fillPolygon(currentShip);
                big.setColor(Color.RED);
                big.drawPolygon(currentShip);
           public void run() {
               int delay = 500;
               while (bAlive){
                   try{
                       System.out.println(thread.getName()+" x: "+point.x+" y: "+point.y);
                       Thread.currentThread().sleep(delay);
                   }catch (Exception e){}
       public void loopGame(){
            satallite = new Ship("Dot", 0);
            satallite.start();
            while (isVisible()){
                pane.wipeImage();           
                satallite.drawShip(pane.getImage());
                pane.repaint();
                try{
                    Thread.sleep(0);
                }catch (Exception e){}
                satallite.kill();           
            System.exit(0);
       public static void main(String[] args) {
            Controller control = new Controller();
            control.loopGame();
    }

  • Help needed on designing the structure of a flash game

    Hi,
    I am studying the codes from http://www.emanueleferonato.com/2009/01/16/designing-the-structure-of-a-flash-game-as3-ver sion-part-3/. What I don't get is at level_selection.as. Where does main_menu_button come from? I can't find where it has been created. I only see main_menu, not main_menu_button.
    Please help.

    The codes in level_selection.as looks like this, but the problem is I cannot find main_menu_button anywhere, except for main_menu.
    package {
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.display.SimpleButton;
        public class level_selection extends Sprite {
            public var main_class:the_game;
            private var level_thumb:level_thumbnail;
            public function level_selection(passed_class:the_game) {
                main_class = passed_class;
                for (var i:int = 1; i<=5; i++) {
                    level_thumb = new level_thumbnail(i,main_class);
                    addChild(level_thumb);
                main_menu_button.addEventListener(MouseEvent.CLICK, on_main_menu_button_clicked);
            public function on_main_menu_button_clicked(event:MouseEvent) {
                main_class.show_splash();

  • Structure of a game pgram

    Hi,
    I wish to do a simple online poker game in java. Shall I write the code throgh socket programming? Is there any need to create a server through socket?(becuase I wish to implement this on a remote host). If I create a server, How will I run it remotely?Should I use the remote server instead of server program created by me?
    I have experience in PHP programming. Also I have created simple chat programs run on My school's LAN. Shall I use remote Tomcat server for this purpose?
    Shall I use servlet instead of socket programming.
    Please help me.
    Thanking in advance.
    From,
    Vinod A.

    The answer to most of these questions are; it depends.
    If you want to have the program visible to the internet I would suggest using a JSP server like tomcat.

  • Can you share FP Controls between different Event Structures

    I'm creating a program that will either read real-time data from an VNA on the GPIB bus, or read a saved s2p (Agilent) file and analyze it. The FP consists of 5 graphs, and various controls which handle events like printing, changing filters, or exiting. on the BD I have a case structure controlled by an operator selection pop-up. I tried using the same FP controls in the event structures I have setup in each case, as only one event structure would ever be executing at any given time, but the program doesn't seem to like it ast run-time. I've worked around the issue by creating "duplicate" controls and using the property setting to make them visible/disabled, etc., but the is seriously congesting my BD.
    Anyone know a way to share controls with seperate event structures?

    It sounds like the root problem is the overall structure of your program. I highly recommend that you check out the Queued Message Handler project template in LabVIEW 2012, that will show you how to utilize a single event structure and pass events to a consumer loop. If you program is too large to consider an architecture change at this stage of the game, then there is a workaround for your problem.
    What is most likely happening is that you have the event structures all set to lock the front panel until the event completes. However the case structure that you have wrapped around these event structures is causing all but one of these event structures to be unreachable thus preventing you from handling the event. Again, as I stated above, the "RIGHT WAY" to fix this is to select a better program structure but the "kluge work-around" fix is this: Dynamically register for the value change event on all of the controls you are trying to trap events for. Dynamic events can be deregistered and re-registered at run time. This will allow only the event structure in the active owning case structure to be registered for the events, thus no other event structures will get in your way.
    Disclaimer: This advice is given based on very minimal information and a great deal of speculation and may not be correct. Please include your code if you need further assistance.
    Charles Chickering
    Architecture is art with rules.
    ...and the rules are more like guidelines

  • How can i adopt the iPhone App-Structure to iTunes for Sync?

    Hello Community!
    I usually buy apps or games directly over the iPhone-App-Store and i also manage the folder structure directly on the iPhone Screen.
    Yesterday i bought a new App via the iTunes Store on my MacBook (don't know why, i thought it would be no problem)
    ITunes is set to manual organisation (the box "App Sync" is not set in iTunes).
    So my problem is:
    I cannot install my recently bought app on my phone without enable synchronisation with iTunes.
    But if i set iTunes to app sync it is going to destroy my folder structures and  remove apps i bought with the iPhone EVEN if i click "Transfer Purchases"!
    Is there a way to manually install the app without destroying my complete structure and losing apps?
    Sorry for the critics, but this is not very user-friendly!
    Thanks for Help!
    Greetings from Germany ,
    Patrick

    This article will tell you where your iPhone backup is stored on your computer:
    http://support.apple.com/kb/ht4946 iTunes content is NOT part of the iPhone backup. You can either copy your iTunes library to your new computer, or you can re-download your purchased iTunes content(except ringtones) to your new computer; http://support.apple.com/kb/ht4527

  • How to structure several scenes (in symbols) on the main stage timeline

    Hi,
    I'm new to edge animate but have a Flash background and I'm working in Edge Animate on a game which is structured in several scenes. Each scene I did put in a symbol. Now I wonder how to build the main timeline or the "story - controller" so to speak. I have all the scenes but I do not know how to connect them.
    In Flash it was possible to add keyframes of scenes one after another (like stairs) and jump forward or backward if needed to load the movie clips. In Edge Animate all scenes (or symbols) are in place from the beginning of the timeline and I cannot move the symbol to a later keyframe. Of course I can move animations in the timeline. The only way I think is to hide the symbols first and make them visible if needed. But this does not seem to be the right way and I don't understand the concept of structuring complex animations yet.
    I would like to know how to structure several scenes in Edge Animate properly. Something like a scene loader or unloader would be useful. Highly appriciate any hints to a solution.
    Thank you,
    JP

    resdesign wrote:
    You can also use edgecommons to load edge composition into another edge composition.
    Thank you to your tipp so I try to organize my scenes into compositions. I can successfully load a composition (scene2) into the main container :
    EC.loadComposition("scene2.html", sym.getSymbol("mainContainer"));
    Now I'm facing another situation. At the end of the loaded composition scene2 is a "Next Scene" button suppose to load scene3.html composition into the main container. "Next Scene" is a nested button inside the loaded composition screen2 symbol. How do I load the next compostion from the current one? This code for On Click of course does not work:
    EC.loadComposition("scene3.html", sym.getSymbol("mainContainer"));
    I think the refer to the mainContainer is wrong. Is it just a targeting issue or is it the wrong approach in general?

  • Is there any way to make my iPod just use a folder/filename structure?

    I'm really sick and tired of the half-baked way my iPod insists - INSISTS - upon displaying tracks by the metadata.
    Sure, it's nice and neat, but frankly, it's a pain in my arse. A lot of the music I want to play is mp3 files ripped from my videogames, or files which are extremely old and have no metadata. Given this, I just want it to display them the way Windows does - by letting me organize my music into folders, and displaying them by only the filename, regardless of the metadata.
    It's very difficult to find, for example, a certain song by Bon Jovi, which has no metadata. My other Bon Jovi music has it, but this one song does not. The other songs, if I view the huge list, are displayed alphabetically by the metadata name tag, and not by my filename tag. This one song, lacking metadata, is displayed only by filename.
    Or my videogame music - almost all of it follows a format of ## - filename.mp3. Unfortunately, I have like, ten or so game's soundtracks that I have done this with, so there's like, 10 files which only appear as 02 - filename. On my Windows PC, there is no conflict, as I have them sorted into appropriate sub-folders of my giant my music directory. But my iPod refuses to do this.
    How can I make my iPod behave consistantly and display the files in a structure of my manual creation, instead of having it trying to do everything for me and buggering the job royally?

    I just have a hard time comprehending why they don't handle file structure sorting.
    It's not a difficult thing to understand. It is, in fact, a computing science +industry standard+, deviations from it are the +unusual and esoteric+, not something I'd expect from one of the industry's giants - certainly not a mandatory deviation.
    It seems like it's a decision that only serves to frustrate people. I can understand why they would want a metadata sorting mode; I can even see making that the default setting... I'm just kind of flabberghasted at the uninclusion of an alternative file sorting method for those of us who trust our own devices better than metadata that may be incorrect, missing, typographically flawed, or what-have-you. I can get to my own music just fine... On my PC. Why not my iPod? Why does the industry-leading mp3 player have to make it a frustrating and difficult chore to find the media I want to play?

  • How do I get a game to work in more than just my account?

    I bought a game for my son at the weekend, which I installed successfully and it works fine in my account. But despite having it selected in Parental Controls, it won't work in his account. I tried removing all controls for him, but it still didn't work. The icon for the program looks like the general Apple icon, with ruler, brush, and pencil, and when you click on it a message appears saying "You cannot open the application because it may be damaged or incomplete". Well this isn't true, because it works in my account.
    I tried searching for info about the error message on the Internet, and found advice on dealing with the message when it appeared with a completely different program. It advised right-clicking on the icon, and clicking on Show Package Contents, then Contents>Mac OS. Then it said double click on the icon (which opens Terminal) in there and next time it should run OK. This didn't work, but I noticed that there was not as much text in the Terminal window in my son's account as in mine, so I wonder if I need to enter the same text for him. This is all getting rather complicated, but does anybody know anything about Terminal, and whether any of this makes sense? Or is there something else I need to do?

    Sphinx,
    The folder that you copied should already contain any saved games, and they must remain where they are, relative to the game itself.
    If you would like the copy to go back into the Applications folder, go right ahead and put it there, replacing the original. As long as you are just moving it, not making a copy, ownership will be retained by your son.
    Kiraly has posted a command for use in Terminal. The command he has given does nothing for ownership, but rather changes permissions such that anyone will be able to run the game. The problem with this is that any new saved games will revert to the default permissions, and you will again encounter errors.
    It is far better, in my opinion, to manage ownerhip in this case, not permissions.
    OK, let's get started. The command to change ownership of any item is rather simple:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">chown <who> <what></pre>
    the "who" part will refer to a user by short name, and the "what" part will be the path to a file or folder. So far, we have three elements included in our command, and each one is separated by a space. The problem with this is that we can only modify items that we own; only "root" can modify items regardless of ownership. So, we are more often required to "become root" in order to execute this command:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">sudo chown <who> <what></pre>
    By preceeding our command with "sudo," we tell the command to execute as the "root user." Only admin users are allowed to perform this action, so we will be asked for our admin password. Once we have typed the command correctly, we press <RETURN>. We will receive a password prompt. We then type our password (it will not be echoed) and again press <RETURN> to execute the command.
    This works fine for single files, but we will usually be dealing with more than a single item. Your case is a good example; one where ownership of an entire directory structure, including any "nested" files and folders, must be changed. For this, we need to add an "option" to the command: the "-R" option. This tells the command to change the ownership of the item named in the "path," and then to do the same "recursively" to every file and/or folder nested inside. It also implies that the target is a directory:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">sudo chown -R <who> <what></pre>
    Let's now talk about the two remaining variables, the "arguments" to the command.... The first argument (the "who" part) requires a bit of discussion. In simple terms, this will be a user's short name. However, it will most often also be necessary to change the "group ownership" when we change ownership. There is a separate command to accomplish this, but we can easily forego the need to use this second command by including it in this one. The tool we must use to do this is the ":" modifier, inlcuded in our "who" argument. In 10.3 and later, all users are members of their own, unique group, so we simply use their short name (which is also their group) twice:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">sudo chown -R <who:who> <what></pre>
    Now for the final part, the "what" argument... As stated earlier, this will be the path to the intended target (for example, /Users/HOME/Documents/My_Folder). Here, we must discuss the possibility that a path name will include spaces. We can name directories in OS X using spaces, but UNIX needs a little help with them. Since UNIX will normally see any space as an indication that another element to the command is coming, we must explicitly tell it that such is not the case. In other words, we must "escape" the space. We do this by using the forward slash before our space: "\" Let us assume that we have a folder named "My Folder" for which we want to change ownership. Our command will look something like this:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">sudo chown -R fred:fred /Users/fred/Documents/My\ Folder</pre>
    Obviously, the above command also assumes that we are logged in as "fred," and we are giving ourselves ownership of a folder in "fred's" HOME folder.
    If this path naming convention is daunting to you, or you simply aren't sure of the correct path, the process can be automated somewhat. Any item can be dragged from the Finder into the Terminal window, and Terminal will automatically fill in the correct path. In this case, we would type the first part of our command:
    <pre style="overflow:auto; font-family: 'Monaco'; font-size: 10px">sudo chown -R fred:fred</pre>
    Next, we would type a trailing space, and then we would drag our folder from the Finder into the Terminal window. Finally, we would press <RETURN>, enter our admin password, then press <RETURN> again to execute.
    Scott

  • Game Center confusion

    I have an iPod 3gen and iPhone 4S. I want to use Game Center to play games on both with current data. But on one game (Smurfs Village) it keeps asking which version of the game I want to play and won't keep the current one. On another game, it continues to load an old game (Clash of Clans) and it won't allow me to delete the old one and restart the game either. And yes, I've deleted the game off the iPod and iPhone through Game Center multiple times and restarted the devices. Nothing seems to work.
    How do I fix?

    I've just had the chance to try my headphoens in another iphone (version 3.1.3) and they alsod o not work on that.
    Looks like I have broken headphones, but no sign of damage also checked for loose contacts on wires.
    after taking as much care as possible i guess I'm onto my 2nd pair of headphones now, thats going along with the three sets of usb cables Iv gone through. Apple must improve the structure of there wires on these phones and ipods. they can easily split or become warn due to movement in pockets and just handeling in general

  • Using XML-based object structures to represent data in code/at run-time

    Hello,
    I have quite a "high level" question which has be bothering me for some time, and I haven't found the subject tackled in any books. I believe J2SE/J2EE is not an important divide here.
    Lets say I want to develop a J2SE game application with two programs: a "level designer", and a "level viewer", and I want to store the level files in an XML format.
    My question, and I use this example only to try and illustrate it, is:
    when coding the level designer or viewer, is it reasonable to use an XML-based object hierarchy for representing a level in code/at run-time, i.e. using the standard Java DOM APIs? Or should one (as I would have done before XML came along) develop a set of classes much closer to modelling the real form of a level, and then add a means to convert those objects to/from to XML format?
    This second option of course I would use/would have used if I wasn't thinking about XML, but isn't it sometimes easier to just read in an XML file into a DOM representation and just use the data straight out of that structure, rather than go through the bother of parsing the XML into a set of unrelated objects defined by a different family of classes? What shapes your decision here? And if the second option is best, what is the easiest way of converting to/from the XML?
    Thank you for any advice.
    Greg

    Hi Christian,
    Can I ask: what about if your domain was quite 'close' to an object/DOM representation of XML?
    For instance, what if a game operated by acting out a theatrical script, a spoken conversation, between two characters, perhaps somehow influenced at points by the user, and a particular level was just a different script for the characters.
    One could imagine that the object representation of this would in the end be quite similar to how you'd represent XML, i.e. like a tree of nodes, where each node was a line from the script, and some nodes were a decision point where different nodes could be chosen from.
    Would you still want to avoid using XML-based classes to represent the underlying 'game', or is there a point where you would 'give it' to the similarity and use existing XML structures directly?
    Thank you for any advice
    Greg

  • Pets Game - No Buy "PADLOCK"

    many pets players are happy with their owners and/or situation and banner up as "no buy" pets to avoid being taken out of these situations... the reasons are various but usually because good friends wish to stay together... there is currently no method a player can have limited and mutual agreed protection against other players who wish to split up these arrangements.. in the etiquette of the game buying a "no buy" pet is considered harassment A solution would be to put a "NO BUY PETS PADLOCK" on our pet pages to prevent these potential harassments / bullying... put a padlock icon.... open and closed... when a pet AND it's owner BOTH mutally agree and click on the lock icon then the pet becomes "unavailable" to sell and it's buy button is dimmed.... something along these lines would make a real difference in player satisfaction with the game... all other issues and contraversies aside... it would give players some limited control over their ownership and prevent pets game harassment... not only is it an easy thing to do... it is the RIGHT thing to do.. how hard is it to get tagged to pay any attention to our repeated request for this feature.. why is that? each pet would have a lil padlock icon.. or something similar... on it's page next to the pic somewhere... it has two positions... open and closed.... when it is open... that means that pet is AVAILABLE for sale.... period.... when it is closed... that means BOTH the owner and the pet have clicked on the icon to indicate the pet is LOCKED / UNAVAILABLE...  it takes a MUTUAL agreement between both pet and owner to activate the NO BUY padlock... once activated... EITHER ONE of the owner - pet pair can UNLOCK the pet by clicking the icon again... two in agreement can lock it and it takes BOTH OWNER AND PET TO DO THAT... to deactivate the palock... it only takes ONE... EITHER the owner or the pet to unlock it....  the programming construct is far simpler than most any other feature on the pet page... it's a simple logical field insertion...
    OWNER CLICKS THE PET PADLOCK *AND* THE OWNED PET CLICKS PADLOCK = TRUE = PET UNAVAILABLE...  EITHER ONE OF THE OWNER *OR* PET DOES NOT / UNCHECKS PADLOCK = FALSE = PET AVAILABLE  easiest thing in the world to do... easier than instant grits... we are talking minor minor stuff that a decent coder could knock out in a couple hours here ppl.... it would make a HUGE diff in the game...  1) no more puttin "no buy" in banners... so there is more room for other stuff 2) ppl can tell right away whether it's a for real "no buy" situation or something else 3) no more rewarding no buy snatchers to harass other pet players4) allows responsible player control over alternates 5) keeps profiles "married up" in a worry free environment 6) PREVENTS PETS GAME CYBER BULLYING 7) keeps newbs and stoopid people from making the worst play in the game 8) adds to the fame and fortune of boxing kitty as a problem solver  ok.. forget 1-7... just do it for number 8 UPDATE 4/17 = i'm going to keep adding more thoughts to this thread as time passes... during the the time this thread has "under consideration" status... more thoughts for tagged and all to consider.... One of the best ways for Tagged to increase its revenues is to sell gold to it's users... gold that can be converted to pet cash... and help a player clean up mistakes or increase value and standing in the game... whether you are a pets game purist and think it a short cut or not... (same is true with other games where gold can be converted).... it is tagged's right as a business to conduct business as they see fit... and selling cyber gold is a money maker... it's just the way it is... So one might think Tagged would be interested in allowing users a way to increase the security of the profiles in which they could invest.... a player would almost CERTAINLY feel more CONFIDENT about purchasing gold and converting it to pet cash IF they had some way to know that his/her profile were protected by a NO BUY PADLOCK... as normally the case when a pet is bought in violation of no buy.. there results a lot of anger... frustration... and in most cases... a profile is abandonned or "DUMPED" in retaliation to the NO BUY VIOLATION... I for one have ZERO interest in buying gold to build a profile knowing i have ZERO chance to protect and preserve when i have it placed with a friend or a good owner... i am sure there are others who would INVEST MORE WITH GOLD AND DO SO WITH CONFIDENCE were we given something as simple as this modest level of protection... So not only is the NO BUY PETS PADLOCK a simple and easy mechanism to put in place... it would also end a lot of drama and needless hassles... close the window of opportunity for online harassment (we can block a user with privacy settings but not from buying our profiles in pets game... leaving that vulnerability open is like putting a screen door on a submarine)... AND it would be good for Tagged's profitablity by encouraging people to invest MORE in their profiles....(tagged can do this by BUILDING SECURITY AND VALUE into the profiles obviously) From any and all perspectives... the NO BUY PETS PADLOCK is a win for everyone Update 4-25-12 well it has happened to your old pal BK.... after being split up from my GF and pets game partner 8 times in the last 5 months... i've decided the ongoing hassle just isn't worth it and will be withdrawing my primary profile from the pets game... after playing pets daily going on 3 years... it will seem odd.... and sure i'm just a little player in the grand scheme of things.... maybe one has to be 100 times my value to gain anyone's attention to the NO BUY PADLOCK idea... i've no delusions there... and yet i wonder... how many other members of tugged have withdrawn / opted out / abandonned profiles due to a hostile take over?...  in my case there is no doubt.. the person behind the chain pets and splitting up our married profiles has a long sad history on tagged for harassment, issuing threats and using pets game to intimidate... it's a shame that a friendly game can be abused by a few for such purposes.. this fellow has been deleted by tagged in the past and somehow always manages to get re-instated.... go figure if i were a tagged admin or a programmer and responsible for creating a fun and friendly environment for this SOCIAL networking game...  it would be a high priority to build in simple safe guards that prevent online cyber bullying.... if i were a suit in tagged's management structure... i would look to find ways to increase profitability and drive a design the ENCOURAGES investment in member profiles... more visits, more ad hits, more gold sales, etc... the NO BUY PETS PADLOCK just makes good business sense from all perspectives.. you'd think business savvy execs would see this simple solution incorporated ASAP...   if nothing else... the NO BUY PETS PADLOCK could also limit tagged's exposure to liability from being named co-defendant in any type of civil suit over cyber-bullying as a result of negligence... negligent means being aware that you've created a condition or environment that is conducive to unlawful or harmful activity, being aware that such coniditions exist and then failing to effect a rememdy... just FYI... new laws around this issue are being written every day... and if i were a big wheel at tagged... i'd be paying better attention and taking prompt action to limit this exposure to potential litigation.... especially since Pets Game is tagged's number one product Update 6-3-2012 i've read over some of the comments posted... and i do appreciate what ppl are saying even though they may not agree.... so i'll respectfully respond to a couple of them ... i think the two biggest objections to the padlock idea are as follows.... 1) one player wrote..."the object of the game is to buy and sell pets.. a padlock would be an impediment to that...."
    response = if you as a pet or an owner do not wish to be or own "No Buy" pets... then the padlock would not change how you wish to play... it is an OPTION available to players that would require BOTH the owner and the pet's consent before the padlock is set... therefore if you do not wish to keep a pet then you simply do not set the padlock... same if you are an owned pet... other players can buy and sell as usual.... the padlock would only be activated by mutual consent... after those that wish do so activate the padlock... there still would be no shortage of good pets to buy and sell... simply having the option wouldn't change anyone's game except for people who buy "no buy" pets as a habit 2) another pets player wrote .. " I make it a point to buy "no buy" pets because i know they will be bought back and i make a quick profit".... response = i cannot caution new players enough against adopting this strategy... it may work sometimes but the odds are against you... many more times than not you will be stuck with an abandonned pet that will drain its cash and migrate to a different profile.. it's a good way to throw away your pet cash... true... there are no "official" rulles against buying a "no buy" pet and there is no mechanism in the game to prevent that..... however it is consdiered in the etiquette of the game to be a "hostile" action which violates the wishes of the pet and it's owner... it's a matter of respect... when a player snatches a "no buy" pet.. there is no obligation for the person to play or maintain that profile any longer... for this reason it is not the wisest of strategies to employ... the end result is usually making people mad / causing drama...  snatching of no buy pets usually forces someone to abandon a profile that they have enjoyed and developed over time (years in some cases)... and it is a HUGE hassle for the NO BUY pet to move friends, other content, etc... not to mention that the profile loses wishers and position in other games they may be playing... snatching a "no buy" pet is the most disruptive play one can make in the game... it is received badly 99.9 percent of the time and will not make one many friends in the game that way... some commenters have said "i buy "nobuy" pets on purpose"... but in fairness what these commenters are NOT saying is they know it's an extremely risky manuever with really no genuine desire to OWN the pet they are buying... rather they are looking for quck profit from a buy back.... this is why our "nobuy" pets wind up in dumps and on pets with insulting pics and banners, etc..... the violators of "no buy" do so usually because they know it's a big risk, utterly disruptive and rarely keep the "no buy" pet onto their primary pet page..... worse yet and often... the buyer of a no buy pet begins a campaign of bullying and treats against the pet if it does not play, if the original owner does not buy back or otherwise get sold.....  if this is not how harrassment in pets game is conducted then i don't know what is...
     one thing that i'm hoping TAGGED and pets players will understand is that our pet is just part of the larger profile... we have worked not only to build our pet page but our status/ranking in other games as well... we have customized our profiles and put work into building friends lists and other content.... in other words... our profiles are VALUABLE to us and tagged should help us protect that which we value... when a player snatches a no buy pet.. sometimes years of work and development go down the drain in an instant... just two clicks by someone else can make a valuable profile worthless to it's owner... tagged should give us some way to prevent that kind of damage Update 6-11-12 i'm reading the comments and i appreciate the support.. if nothing else i hope this thread will educate others about the whole "NO BUY" concept.... there are lots of good reasons why a player would not want to have others take the pets from their page... sometimes it's a pet that is won in a key race... sometimes it's a "stacker"... sometimes and prolly most the time its a friend.... but if this thread can at least save botht the owners and buyers of "NO BUY" pets from some unnecessary drama... then i'll take what victory i can from keeping this convo going... and i'm not blasting or flaming any one for being honest and expressing their opinion... that is what makes the discussion more valuable and meaningful.... so please bear that in mind when you read thru comments...  one other theme that runs thru the dissenting opinion...ppl are saying "ok.. if you don't want to be bought then instead of "no buy" .... you should just "opt out"... i can see where ppl think that all is fair game... and perhaps without official "rules" and a padlock mechanism... for the time being... opting out would be one way to tell other players "do not buy me"... right?... i get it.... however...i think the idea here is to ENCOURAGE ppl to play pets in a way that is fun and enjoyable... is it not better to bring people INTO the game rather than driving them OUT of the game?... buying a no buy pet tends to have the later effect...it causes people to leave the game or at least to abandon the jacked profile / pet... that's not what any of us want i don't think.. including tagged... on the other hand... i should mention in all of this... that if one takes the time to talk to ppl you see on the playground... make friends and enjoy a social networking game together... that IF YOU ASK b4 you buy... some NO BUY pets will be the best pets you'll own... most long time players would agree they just want some small degree of control... it's a good fit when the player and owner have a mutual desire to be in the arrangement... and yes... ppl do have to be raised which requires ppl to trade and flip pets...  so here's a tip from your ole pal BK... make friends and ask first.... you'll find most pets players are a good lot for the most part... but about the fastest way i know to get on ppl's bad sides is to snatch their "no buy" pets without some previous arrangement...   it's a social networking game most of all... play nice... be good company... that's the best advice i can give ya... UPDATE 6-13-12 was talking to a friend who does not play pets... she had opted out as many have suggested a player do... and yet even though she had opted out of pets game... as soon as she comes online then pets players buy her and flip her anyway... she has told me she has no interest in playing pets game ... finds it "distasteful" that ppl put values on others... and does not appreciate the hostility she's encountered from ppl that expect to her play pets game since they have bought her...... in other words.... opting out does not always work.... and ok... i explain to her that it is just a game... like trading baseball cards at one level and not take things personally... but here's an interesting angle on why we need the NO BUY PETS PADLOCK... i'm sure there are other members of tagged / hi5 who have no interest and would rather NOT be involved at all...  another friend and posters here have commented about winning k pets and owning non-playing profiles which are bannered "no buy" and are set free from their owners once they have built enough pet cash to do so... these profiles are obviously ownerless... bannered no buy... there is no intent to maintain or play them as a normal profile... and yet other players still buy them and expect a response and the pet to be maintained so it will sell... therefore another option with the NO BUY PADLOCK would be if a pet is OWNERLESS for whatever reason.. either a set free has occured... an owner quits the game and ghosts... whatever... if a pet is ownerless then it could set the Padlock to lock it in as a "no buy"... any attempt to buy the pet/profile at that point would return a "Pet is unavailable for sale" condition...
     this would make sure that members with no desire to play pets and that repsonsible players have a way to set a profile so that it cannot be "pulled" back into the game again... if you really consider all the reasons for the PADLOCK... i'm hoping everyone will see how useful this feature could be and benefit everyone UPDATE 6-14-2012 just had a lil thought to throw in here.... i see pet players all the time saying "i show up everyday... i play well and buy pets.. i have good numbers in value, cash and assets.... and still.. no one will buy and raise me".... right?... i wonder how many players like that would be helped if more established players were not required to re-invest all the profit in buiding their own profiles because as it is now... the only defense against being snatched by a "NO BUY" pet buyer is to raise your value to such an amount that it's prohibitive... and in some cases... even not then...  the padlock would be one thing that allows ppl to concentrate on helping others up in the game rather than always having to play on the defense.... does that make sense?... FURTHER UPDATES AND EXPLORATION OF OP CAN BE FOUND IN THREAD COMMENTS due to size limitations in the TOPIC / OP ...Please read on and add your KUDO if you agree... thanks

    I agree with this idea 100%  Taggeds answer will be that buying pets is the purpose of the game, and no buy was created by the players not them. What they fail to take into consideration is that sexual harassment, threats, bullying is what has made many of us be no buys.  The current game is more runs than it is pet buying, the ONLY reason to buy no buys is pure greed and harassment, and that wasn't the intent of the game either.  JUST like they had to adjust and incorporate the key runs as part of the game, they need to listen to the players who choose to be no buy, and many spend large $s on their profiles, and give us a way to stay where we choose.  There are surely enough pets who are not no buy, to keep the game going.  The lock would drastically cut down on the fighting and amount of complaints that they get, there is no down side to giving us a pad lock. 

  • What prog language/tools for a browser based online game ?

    I am going to start a project for an multiplayer online game community soon, and need some advice.
    The community will consist of the game itself, forum, wiki and irc-chat and use f/oss software to keep the running costs as low as possible.
    The game is the heart of the community and will be a turn-based wargame with roleplaying and strategy options, mainly text based with some graphics and animations  and played through a browser. (These kind of games are often referred to as Multiplayer Online RolePlaying game MORPG )
    The SQL player database will have up to approx 100k player records, each of which will have many fields.
    The game code will run 24/7 on a linux server (distro not chosen yet) and needs to fulfill these requirements :
    easily maintanable by multiple programmers
    programmers should be able to develop/test parts of the code on their own pc's using linux or windows.
    good, fast access to the player DB
    combat calculations will be mathemically complicated, and need to be fast
    User interaction will be through a web-page
    A way to keep users from accessing the game code directly to avoid computer players. (it's possible this has more to do with the code structure than with the language)
    Most games of this type seem to use a php/ C combination, but that appears to have several drawbacks.
    Specifically code maintainability and distinguishing between humans and bots/computer players are a problem for these games.
    What environment do you think would fulfill these requirements ?
    P.S. if this is to theoretical, check out these links to see some similar games :
    Lords of Legend
    Ogame

    i think java could be a good choice for the programminglanguage. Most computer have the JVM installed already...

  • Help with Kevin Bacon game

    I would really appreciate some help. Yes this is an assignment who in his crazy mind would try to do this just to learn or practice their java. I have some code already done but I ran out of memory. The other thing my code works like the one at Virginia University. I'm awarding 10 dukes I can award another 10 dukes. I'll let you know later, thanks in advance.
    This is the code I have:
    import java.io.*;
    import java.util.zip.*;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Set;
    import java.util.Iterator;
    * A class that download files , create Maps and search for information with
    * in the maps, giving an output of the actor that share more movies with the
    * input actor that the user gives
    public class DataBase
      private Map map1 = new HashMap( );  // actor
      private Map map2= new HashMap( );   //movies
      private int okactor = 0;
    // Main Method
      public static void main (String args [])throws IOException
        DataBase testing = new DataBase();
        System.out.println("Program was run in Pentium 4 in AUL");
        System.out.println("Starting Time : " + System.currentTimeMillis());
        testing.loadFile("C:\\My Documents\\FIU\\COP3530_Data_Strutures\\program5\\actresses.list.gz");   
        testing.loadFile("C:\\My Documents\\FIU\\COP3530_Data_Strutures\\program5\\actors.list.gz");
        //testing.loadFile("\\\\Cougar\\cop3530\\actresses.list.gz");   
        //testing.loadFile("\\\\Cougar\\cop3530\\actors.list.gz");
        System.out.println(" Ending Time of Downloading:  " + System.currentTimeMillis());
        int infiniteloop = 0 ;
           while (infiniteloop == 0)
                     System.out.println("Number of Actors and Actresses : " + testing.getActorCount());
                  System.out.println("Number of Movies: " + testing.getMovieCount());  
                      System.out.println("");
                      System.out.println("Enter a name please");
                      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                      String name = in.readLine(); 
                      testing.computeSharedMovies(name);
                  List listofnames = new ArrayList();
                  listofnames =  testing.mostSharedMovies();  
                  testing.print(name, listofnames);
    //static class actor 
      private static final class Actor
         String name;
         int    data;  // number of shared movies,
                       // determined by computeSharedMovies
         public String toString( )
           { return name; }
         public int hashCode( )
           { return name.hashCode( ); }
         public boolean equals( Object other )
           { return (other instanceof Actor) &&
                    ( (Actor) other ).name.equals( name );
    *Loads the two files files
    *@param String is the fileName to be download
      public void loadFile( String fileName ) throws IOException
           BufferedReader x = new BufferedReader ( new InputStreamReader(new GZIPInputStream (new BufferedInputStream( new FileInputStream(fileName)))));
                String line;
          int start = 0 ;
          ArrayList actorList = new ArrayList();
          ArrayList movies = new ArrayList();
          Actor key = new Actor();
          int p = 0;    //parameters
          int p2 =0 ;
          String you = null ;
          String year = null;
          String trimMovie = null;
          int par1 = 0;    //parameter
          int par2 =0;
          String addingmovie = null;
            while((line = x.readLine()) != null)
                if(line.indexOf("Name") == 0 )
                      start++;
                if(start == 0)
                continue;
                  if( start >= 1)
                                  if(line.indexOf("-----------------------") == 0)
                                          break;
                                  if(((line.trim()).length()) == 0)
                                         continue;
                                  else if(line.indexOf("----") == 0)
                                          continue;
                                     else if (line.indexOf("Name") == 0)
                                             continue;
                                  else if(line.indexOf("\t") != 0)
                                     p  = line.indexOf("\t");
                                     p2 = line.lastIndexOf(")");
                                     String actor = (line.substring(0,p));
                                       key = new Actor();
                                       key.name = actor;                              
                                        you = (line.substring(p, (p2 + 1)));
                                          if (you.indexOf("(TV)") > 0)
                                                         continue;                                                                                                
                                       p = you.indexOf("\t");
                                       p2 = you.indexOf(")");
                                      you = (you.substring(p, p2 +1)).trim();                                 
                                            if(you.indexOf("\"") == 0)
                                                    continue;                                                                                        
                                            year = you ;
                                       p = year.indexOf("(");
                                       p2 = year.indexOf(")");
                                       year = year.substring(p + 1 , p2);                                 
                                            if ( ( ((Comparable)year).compareTo("2002") ) >= 0)
                                                    continue;                                                                                         
                                     you = you.intern();                                                                  
                                     movies = new ArrayList();
                                      movies.add(you);
                                     movies.trimToSize() ;                    
                                        map1.put(key , movies);
                                           if(map2.containsKey(you))
                                                      ((ArrayList)map2.get(you)).add(key) ;
                                            else
                                                         actorList = new ArrayList();
                                                           actorList.add(key);
                                                           actorList.trimToSize() ;                                                          
                                                           map2.put(you, actorList);
                               else if(line.indexOf("\t") == 0)
                                    par1 = line.indexOf(")");
                                    par2 = line.indexOf("\t");
                                    trimMovie = (line.substring(par2, par1 +1)).trim();
                                    trimMovie = trimMovie.intern();                              
                                    String ye = trimMovie;
                                    par1 = trimMovie.indexOf("(");
                                    par2 = trimMovie .indexOf(")");                              
                                    ye = (ye.substring(par1 + 1 , par2));                             
                                     addingmovie = (line.trim());
                                           if(addingmovie.indexOf("(TV)") > 0)
                                           else if ( (((Comparable)ye).compareTo("2002")) >= 0)
                                           else  if(addingmovie.indexOf("\"") == 0)
                                           else if(addingmovie.indexOf("(archive footage)") > 0)
                                            else
                                                     if(map1.containsKey(key))
                                                                 ((ArrayList)map1.get(key)).add(trimMovie);                         
                                                              ((ArrayList)map1.get(key)).trimToSize() ;
                                                    else
                                                          movies = new ArrayList();
                                                          movies.add(trimMovie);
                                                          movies.trimToSize() ;
                                                          map1.put(key, movies);
                                              if(map2.containsKey(trimMovie))
                                                 {     ((ArrayList)map2.get(trimMovie)).add(key);
                                                     ((ArrayList)map2.get(trimMovie)).trimToSize() ;
                                            else
                                                           actorList = new ArrayList();
                                                         actorList.add(key);
                                                        actorList.trimToSize() ;
                                                        map2.put(trimMovie, actorList);
    *Compute the amount of shared movies for all actor compared to the one
    *given from the user
    *@param String actor is the actor that the user wish to search for some
    *other actors/actresses with the most shared movies with him
        public void computeSharedMovies( String actor )
             Actor actor2 = new Actor();
             actor2.name = actor;
            if(map1.containsKey(actor2))
                  okactor = 0 ;
                  Actor actor3 = new Actor();
                  actor3 = actor2;
                      for(int count = 0 ; count < ((ArrayList)(map1.get(actor2))).size() ; count++)
                           String movie = (String)((ArrayList)(map1.get(actor2))).get(count);      
                                for (int count2 = 0 ; count2 < ((ArrayList)map2.get(movie)).size() ; count2++)     
                                          Actor iuu = (Actor)((ArrayList)map2.get(movie)).get(count2);
                                          if(!(iuu.name).equals( actor3.name))
                                                     iuu.data++;
             Set entries = map1.entrySet();
             Iterator itr = entries.iterator();
                 List x2 = new ArrayList() ;
                 Actor big = new Actor();
                 big.data = 0;
                 List list = new ArrayList();
             while (itr.hasNext())
                       Map.Entry thisPair = (Map.Entry) itr.next();                 
                          Actor actorCompare = ((Actor)thisPair.getKey());                                   
                          if( actorCompare.data > big.data)
                               big.name = actorCompare.name;
                               big.data = actorCompare.data;
                               list = new ArrayList();
                               list.add(actorCompare);
                      else if (actorCompare.data == big.data)
                                list.add(actorCompare);
          }//end of if, if actor is in map
           else
                   okactor = 1;
    *Prints the final output
    *@param String actor1 is the actor pick by the user to be search
    *@param List most is the list with all the actors/actresses that had
    *the most shared movies
      public void print (String actor1 , List most)
         if(okactor == 0)
               Actor actorPrint = new Actor();
               actorPrint.name = actor1;
               Actor y = new Actor();
               y = actorPrint;
               List  list = new ArrayList();
               list = most;
               int data = ((Actor)list.get(0)).data;
               ArrayList list2 = new ArrayList();
               list2 = (ArrayList)(map1.get(actorPrint));
                  for(int getActor = 0 ; getActor < list.size() ;getActor++)
                           System.out.println(list.get(getActor) + "  :   (" +  data  + "  " + "Shared roles)");
                            Actor name3  = (Actor)list.get(getActor);
                           String na  = name3.name;
                             Map map3 = new HashMap();
                            ArrayList ji = new ArrayList ();
                            ji = (ArrayList)map1.get(list.get(getActor));
                    for (int array1 = 0 ; array1 < ji.size()  ; array1++)
                         map3.put( ji.get(array1) , na);
                    for(int count = 0 ; count < list2.size() ; count++)
                           if(map3.containsKey(list2.get(count)))
                           System.out.println("                    " + (list2.get(count))); 
             Set entries =map1.entrySet();
             Iterator itr = entries.iterator();
             Actor  actortoclean = new Actor();
                  while(itr.hasNext())
                       Map.Entry thisPair = (Map.Entry)itr.next();
                       actortoclean = (Actor)thisPair.getKey();     
                       actortoclean.data = 0 ;      
       else  //else if okactor greater than 0
       System.out.println("THE ACTOR IS NOT IN FILE PLEASE TRY AGAIN") ;
    * Coputes what actors or actresses have the most shared movies
    *return a List with all the actor that have the most shared
    *movies
      public List mostSharedMovies( )
        if(okactor == 0)
        Set entries = map1.entrySet();
        Iterator itr = entries.iterator();
        List x = new ArrayList() ;
        Actor big = new Actor();
        big.data = 0;
        List list = new ArrayList();
          while (itr.hasNext())
                  Map.Entry thisPair = (Map.Entry) itr.next();
                     Actor o1 = ((Actor)thisPair.getKey());
                          if( o1.data > big.data)
                               big.name = o1.name;
                               big.data = o1.data;                 
                               list = new ArrayList();
                               list.add(o1);
                           else if (o1.data == big.data)
                                list.add(o1);
        return list;
      else
         return null;
    *Gives the amount of actor in the map of actors
    *return an int with the quantity
      public int getActorCount( )
          return map1.size();
    *Gives the amount of movies in the map of movies
    *return an int with the quantity
      public int getMovieCount()
           return map2.size();
    }Kevin Bacon Game
    For a description of the Kevin Bacon game, follow this link http://www.cs.virginia.edu/oracle/ . Try the game a few times and see if you can find someone with a Bacon Number higher than 3. In this program you will find all persons with a Bacon Number of 8 or higher. One of these persons is a former President of the United States.
    Strategy
    This is basically a shortest path problem. After that is done, find the large Bacon numbers by scanning the bacon numbers and print out the high-numbered actors and their chains. To print out a high-numbered actor, you should use recursion. Specifically, if some actor x has a Bacon number of b, then you know that they must have been in a movie with someone, call them actor y with a Bacon number of b-1. To print out x's chain, you would print out y's chain (recursively) and then the movie that x and y had in common.
    The Input Files
    There are two data files; both have identical formats. These files are: actors file and actresses file. These files are both compressed in .gz format, and were obtained from the Internet Movie Database. Combined, they are 52 Mbytes (compressed!) and were last updated October 17, 2002. These files are available at ftp://ftp.imdb.com/pub/interfaces/
    These datafiles contain approximately 571,000 actors/actresses in a total of 192,000 movies, with 2,144,000 roles. These files also list TV roles, but you must not include TV roles in your analysis.
    Before you run on the large data sets, use the small (uncompressed) file sample.list(http://www.fiu.edu/~lmore004/cop3530/sample.list) to debug the basic algorithms. In this data file, there are six actors, named a, b, c, d, e, and f, who have been in movies such as X, Y, and Z.
    Input File Hints
    Since it is not my input file, I cannot answer questions about it. Here are some observations that I used in my program, that should suffice. You can read the input file line by line by wrapping a FileInputStream inside a BufferedInputStream inside a GZIPInputStream inside an InputStreamReader inside a BufferedReader. You may not uncompress the file outside of your program.
    There are over 200 lines of preamble that can be skipped. This varies from file to file. However, you can figure it out by skipping all lines until the first occurrence of a line that begins with "Name", and then skipping one more.
    There are many postamble lines, too, starting with a line that has at least nine dashes (i.e. ---------).
    A name is listed once; all roles are together; the name starts in the first column.
    A movie title follows the optional name and a few tab stops ('\t'). There are some messed up entries that have spaces in addition to tab stops.
    The year should be part of the movie title.
    Movies made in 2003 or later should be skipped.
    A TV movie, indicated by (TV) following the year, is to be skipped.
    Archive material, indicated by (archive footage), is to be skipped. (Otherwise JFK is a movie star).
    Cameo appearances, indicated by [Cameo appearance], should be skipped.
    A TV series, indicated by a leading " in the title is to be skipped.
    A video-only movie, indicated by (V) following the year is allowed.
    Blank lines separate actors/actresses, and should be skipped.
    Strategy
    In order to compute your answers, you will need to store the data that you read. The main data structures are a Map in which each key is an Actor and each value is the corresponding list of movies that the actor has been in, and then a second Map, in which key is a movie and each value is the list of Actors in the movie (i.e. the cast). A movie is represented simply as a String that includes the year in which it was made, but an Actor includes both the name of the actor, and a data field that you can use to store computed information later on. Thus, ideally, you would like to define a class that looks somewhat like this (with routines to compute Bacon Numbers not listed):
    public class Database
      private static final class Actor
         String name;
         int    data;  // Bacon number ,
                       // determined by computeBaconNumbers
         public String toString( )
           { return name; }
         public int hashCode( )
           { return name.hashCode( ); }
         public boolean equals( Object other )
           { return (other instanceof Actor) &&
                    ( (Actor) other ).name.equals( name ); }
        // Open fileName; update the maps
      public void loadFile( String fileName ) throws IOException
      public int getActorCount( )
      public int getMovieCount( )
      private Map actorsToMovies = new HashMap( );
      private Map moviesToActors = new HashMap( );
      Memory Details
    The description above is pretty much what you have to do, except that you must take extra steps to avoid running out of memory.
    First, you will need to increase the maximum size of the Java Virtual Machine from the default of 64Meg to 224Meg. You may not increase it any higher than that. If you are running the java interpreter from the command line, the magic option is -Xmx224m. If you are using an IDE, you will have to consult their documentation --- don't ask me.
    Second, you will quickly run out of memory, because if you find two movies that are the same, but are on different input lines, the default setup will create two separate (yet equal) String objects and place them in the value lists of two different actors. Since there are 2.1 million roles, but only 192,000 movies, this means that you will have ten times as many String objects as you really need. What you need to do is to make sure that each movie title is represented by a single String object, and that the maps simply store references to that single String object. There are two basic alternatives:
    The String class has a method call intern. If you invoke it, the return value on equal Strings will always reference the same internal String object.
    You can keep a HashMap in which each key is a movie title, and each value is the same as the key. When you need a movie title, you use the value in the HashMap.
    Option two is superior (performancewise) to option #1 and it is required that you use it to avoid memory problems.
    When you maintain the list of movies for each actor, you will want to use an ArrayList. It takes little effort to ensure that the capacity in the ArrayList is not more than is needed, and you should do so, to avoid wasting space (since there are 571,000 such array lists).
    When you construct the HashMaps, you can issue a parameter (the load factor). The higher the load factor, the less space you use (at the expense of a small increase in time). You should play around with that too; the default is 0.75; you will probably want a load factor of 2.00 or 3.00.
    You must be very careful to avoid doing any more work in the inner loops than you need to, including creating excessive objects. IF YOU CREATE EXCESSIVE OBJECTS, YOUR PROGRAM MAY SLOW TO A CRAWL BECAUSE ALL ITS TIME WILL BE SPENT IN THE GARBAGE COLLECTOR OR RUN OUT OF MEMORY COMPLETELY.
    What to Submit
    Submit complete source code and the actors/actresses with Bacon Numbers of 8 or higher. Include the complete paths for each of the actors/actresses (with shared movie titles). Also indicate how long your algorithm takes. This means how long it takes to load, and also how long it takes to run the shortest path computation (not including the output of the answer), by inserting calls to System.currentTimeMillis at appropriate points in your code, and tell me how many actors and movies there are. Also, insert this code (at the end of your program) that tells me how large the VM is:
    Runtime rt = Runtime.getRuntime( );
    int vmsize = (int) rt.totalMemory( );
    System.out.println( "Virtual machine size: " + vmsize );
    Don't forget to write in the processor speed of the computer you are using. If it's somewhat fast, or provably space-efficient, you can get extra credit. You cannot receive credit for a working program if your program fails to produce a large set of actors and actresses with Bacon Numbers of 8 or higher. Note: the data you will work on and the data the Oracle uses (and the IMDB data) are all slightly out of sync. So you might not be able to exactly reproduce the results, although I was able to get a complete set of Bacon Numbers 8 and higher when I ran my program on October 23, using the Oct 17 files.
    Due Date
    This program is due on Thursday November 14.
    Additional Notes
    The exact sizes of the data files are 36381624 and 18263563 bytes, respectively. If you download and the files are larger, then you messed up the download. Note that if you are using Windows XP, these files might be uncompressed during downloading. If so, you can use this program to recompress the file. If the files are smaller, then the download probably got interrupted before it finished and you will need to retry. Here is a gzipped sample.list for you to test that aspect of your program.
    Running on COTTON in the AUL, which is a 450 MHz Pentium III, and accessing the files over the network as "\\\\couger\\cop3530\\actors.list.gz", (and similarly for actresses.list.gz), and with no other processes running besides notepad, the data files loaded in 180 seconds. You should be able to get faster results on a faster machine. Some of the AUL machines are 1.6 GHz. You should indicate which AUL machine (with processor speed) ran your submission.
    Entries with years such as (1996/I) are optional.
    When writing and reading make sure you are using BufferedInputStream and BufferedOutputStream, as appropriate.
    Sketch of the basic shortest path computation:
    // typically invoked with Kevin Bacon as parameter
    // This is the basic algorithm; there's stuff

    I forgot to post the code, here it is:
    import java.util.LinkedList ;
    import java.io.*;
    import java.util.zip.*;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Set;
    import java.util.Iterator;
    import java.util.HashSet;
    * A class that download files , create Maps and search for information with
    public class DataBase2 implements Serializable
      private Map map1 = new HashMap((int)515927, (float)0.85 );  // actor
      private Map map2= new HashMap((int)172911, (float)0.85 );   //movies
      transient private Map map3 = new HashMap();   //movie and movie
      transient private int okactor = 0;
      transient static final int INFINITY = Integer.MAX_VALUE;
    // Main Method
      public static void main (String args [])throws IOException
        int c  = 0 ;
        System.out.println("Program was run in Pentium 4 in AUL");        
        DataBase2 testing = new DataBase2();   
        try{   
            ObjectInputStream ii1 = new ObjectInputStream (new BufferedInputStream (new FileInputStream("file2.ser")));
        catch (FileNotFoundException ex)
            System.out.println("FILE NOT ON DISK PLEASE WAIT WHILE DOWNLOADING");
            long x = System.currentTimeMillis();
            testing.loadFile("\\\\Cougar\\cop3530\\actresses.list.gz");   
            testing.loadFile("\\\\Cougar\\cop3530\\actors.list.gz");
            long y = System.currentTimeMillis();
            System.out.println("DONE WITH DOWNLOADING, USING NORMAL METHOD " +(y - x)/1000 + " seconds");                       
            System.out.println("The actors count is:  " + testing.getActorCount());
            System.out.println("The movies count is:  "  + testing.getMovieCount());
            testing.loadser(testing);      
            System.out.println("END OF DUMPING");      
            testing.findBacon();  
            c++;        
        if (c == 0 )
            long o= System.currentTimeMillis();   
            testing = testing.fastloading(testing);
            long y = System.currentTimeMillis(); 
            System.out.println("DONE WITH LOADING, FROM SERIALIZED FILES  " + (y-o)/1000 + "seconds");         
            System.out.println("The actors count is:   " + testing.getActorCount());
            System.out.println("The movies count is:   " + testing.getMovieCount());
            testing.findBacon();             
            Runtime rt = Runtime.getRuntime( );       
            int vmsize = (int) rt.totalMemory( );       
            System.out.println(" " );
            System.out.println( "The Virtual Machine size is : " + vmsize + " bytes" );
    //static class actor 
      private static final class Actor implements Serializable
         String name;
         int    data;  // number of shared movies,
                       // determined by computeSharedMovies          
         public String toString( )
           { return name; }
         public int hashCode( )
           { return name.hashCode( ); }         
         public boolean equals( Object other )
           { return (other instanceof Actor) && ( (Actor) other ).name.equals( name );}
    *Method to find the bacon number of each actor
    *and also send information, actors greater than 7,  to be print
      public void findBacon()
        ArrayList actorlist = new ArrayList();
        long time1 = System.currentTimeMillis();
        Actor actor2 = new Actor();    
        actor2.name = "Bacon, Kevin";
        actor2.data = 0;
        Set entries =map1.entrySet();
        Iterator itr = entries.iterator();
        Actor  actortoInfinity = new Actor();
        Set listofMovies = new HashSet();          
                    while(itr.hasNext())
                            Map.Entry thisPair = (Map.Entry)itr.next();
                            actortoInfinity = (Actor)thisPair.getKey();    
                            if((actortoInfinity.name).equals( actor2.name))
                                    actortoInfinity.data = 0 ;                     
                            else
                            actortoInfinity.data = INFINITY ;      
         Actor actor3 = new Actor() ;      
         LinkedList list = new LinkedList();
         list.addLast(actor2) ;
         Actor out = new Actor();
                    while (list.isEmpty() != true)
                            out = (Actor)list.getFirst();
                        list.removeFirst() ;
                                    for(int count = 0 ; count < ((ArrayList)(map1.get(out))).size() ; count++)
                                            String movie = (String)((ArrayList)(map1.get(out))).get(count);                      
                            if(listofMovies.contains(movie))
                            {continue;}
                            else
                            listofMovies.add(movie);
                                    for(int count2 = 0; count2 < ((ArrayList)(map2.get(movie))).size() ; count2++)
                                                    actor3  =   (Actor)(((ArrayList)(map2.get(movie))).get(count2) )  ;
                                            if(actor3.data == INFINITY)
                                                actor3.data = out.data + 1;
                                                list.addLast(actor3) ;
                                    if(actor3.data >= 7)
                                            actorlist.add(actor3);                                                                 
                                                             }//inner loop                
                         }//else
                     }//outer loop
                 }//while loop
         long time2 = System.currentTimeMillis();
         System.out.println("Done gettig Bacon Number(shortest path): " + (time2 - time1)/1000 + " Seconds");
                    for(int count = 0 ; count < actorlist.size() ; count++)
                                    print((Actor)(actorlist.get(count)));
    *Method used to print the chain of information within
    *each actor with Bacon number of 7 and over
    *it uses recursion to do it
      private void   printPath (Actor target)
        int c = 0 ;  
        Actor actor = new Actor();
            String movies ;
              if (target.data == 0)
                  System.out.println("-----------------------------END OF PATH-----------------------------");                           
              else
                    for(int x = 0 ; x < ((ArrayList)(map1.get(target))).size(); x++)
                    movies = (String)(((ArrayList)(map1.get(target))).get(x));
                    for (int y = 0 ; y < ((ArrayList)map2.get(movies)).size() ;  y++)
                            actor = (Actor)(((ArrayList)(map2.get(movies))).get(y));
                            if(actor.data == target.data - 1)
                                    System.out.println("* " + target + "  acted with " + actor+ " how's BK # is " + actor.data + ", both in movie: " + movies ) ;
                                c++;
                                break;                      
                     }//inner loop
                   if (c > 0)
                   break;
                  }//outer loop
              printPath(actor);
    *Gets the actor to print
    *and sends the same actor to
    *PrintInfo method to print
    *its chain
    *@param target the actor to print
      public void print(Actor target)
                            System.out.println(" " );
                                    System.out.println(" " ); 
                            System.out.println(" " );
                                    System.out.println(target.name + "'s Bacon number is: " +target.data);
                                    System.out.println(" " );
                                printPath(target);                                                                                                                                                                         
    *A method to load the Serialization file
    *so it,the file,  can be manipulated
    *@param x the DataBase object to be load
    *with all the files
    *@return the object x with all the file
    *withit
      public DataBase2 fastloading(DataBase2  target2) throws IOException
            try{ 
                    ObjectInputStream ii1 = new ObjectInputStream (new BufferedInputStream (new FileInputStream("file2.ser")));
                    target2= (DataBase2) ii1.readObject();
                    ii1.close();
        catch(ClassNotFoundException e )
           System.out.println("Error, class exception");
        catch(FileNotFoundException ex)
           System.out.println("Error, the file is not on the disk");       
        return target2;            
    *Method to write the Object DataBase2, created before, into a Serializable file
      public void loadser(DataBase2 ObjecttoLoad ) throws IOException
            ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream("file2.ser")));
            oo.writeObject(ObjecttoLoad);
            oo.close();
    /**Method use to download files for the first time
    *it creates maps, which contains actor and movies
    *@param fileName it gets the file to be read and
    *used to get the data into the maps
      public void loadFile( String fileName ) throws IOException
          BufferedReader x = new BufferedReader ( new InputStreamReader(new GZIPInputStream (new BufferedInputStream( new FileInputStream(fileName)))));
          String line;          
          int start = 0 ;    
          ArrayList actorList = new ArrayList();
          ArrayList movies = new ArrayList();
          Actor key = new Actor();
          int p = 0;    //parameters
          int p2 =0 ;
          String you = null ;
          String year = null;
          String trimMovie = null;
          int par1 = 0;    //parameter
          int par2 =0;
          String addingmovie = null;
            while((line = x.readLine()) != null)
                if(line.indexOf("Name") == 0 )
                    start++;                       
                if(start == 0)
                continue;                       
                if( start >= 1)
                                  if(line.indexOf("-----------------------") == 0)
                                         break;                    
                                  if(((line.trim()).length()) == 0)
                                     continue;
                                  else if(line.indexOf("----") == 0)
                                     continue;
                                      else if (line.indexOf("Name") == 0)
                                             continue;
                                  else if(line.indexOf("\t") != 0)
                                     p  = line.indexOf("\t");
                                     p2 = line.lastIndexOf(")");                               
                                     String actor = (line.substring(0,p));                                        
                                             key = new Actor();
                                             key.name = actor;                               
                                             you = (line.substring(p, (p2 + 1)));                                                                                                                                                                                                                                                                              
                                             if (you.indexOf("(TV)") > 0)
                                                            continue;                                                                                              
                                     p = you.indexOf("\t");
                                     p2 = you.indexOf(")");
                                         you = (you.substring(p, p2 +1)).trim();                                    
                                          if(you.indexOf("\"") == 0)
                                                             continue;                      
                                     year = you ;      
                                     p = year.indexOf("(");
                                     p2 = year.indexOf(")");
                                     year = year.substring(p + 1 , p2);                                 
                                           if ( ( ((Comparable)year).compareTo("2002") ) >= 0)
                                                  continue;                                           
                                           if (map3.containsKey(you))
                                               else
                                                          map3.put(you, you);                                                                                              
                                     movies = new ArrayList();
                                     movies.add(map3.get(you));
                                     movies.trimToSize() ;                         
                                     map1.put(key , movies);
                                          if(map2.containsKey(map3.get(you)))
                                                              ((ArrayList)map2.get(map3.get(you))).add(key) ;
                                          else
                                                              actorList = new ArrayList();
                                                                          actorList.add(key);
                                                                      actorList.trimToSize() ;                                                                     
                                                                      map2.put(map3.get(you), actorList);
                             else if(line.indexOf("\t") == 0)
                                    par1 = line.indexOf(")");
                                    par2 = line.indexOf("\t");                                                          
                                    trimMovie = (line.substring(par2, par1 +1)).trim();
                                    // trimMovie = trimMovie.intern();                           
                                    if(map3.containsKey(trimMovie))
                                    else
                                    map3.put(trimMovie , trimMovie);
                                    String ye = (String)map3.get(trimMovie);
                                    par1 = trimMovie.indexOf("(");
                                    par2 = trimMovie .indexOf(")");                             
                                    ye = (ye.substring(par1 + 1 , par2));                                                               
                                    addingmovie = (line.trim());
                                        if(addingmovie.indexOf("(TV)") > 0)
                                            else if ( (((Comparable)ye).compareTo("2002")) >= 0)
                                            else  if(addingmovie.indexOf("\"") == 0)
                                            else if(addingmovie.indexOf("(archive footage)") > 0)
                                        else
                                            if(map1.containsKey(key))
                                                            ((ArrayList)map1.get(key)).add(map3.get(trimMovie));                            
                                                            ((ArrayList)map1.get(key)).trimToSize() ;
                                            else
                                                    movies = new ArrayList();
                                                    movies.add(map3.get(trimMovie));
                                                    movies.trimToSize() ;
                                                    map1.put(key, movies);
                                           if(map2.containsKey(trimMovie))
                                                {   ((ArrayList)map2.get(map3.get(trimMovie))).add(key);
                                                    ((ArrayList)map2.get(map3.get(trimMovie))).trimToSize() ;
                                               else
                                                            actorList = new ArrayList();
                                                                    actorList.add(key);
                                                            actorList.trimToSize() ;
                                                            map2.put(map3.get(trimMovie), actorList);
                                      }     //end of last else if          
                        }//end of if
                }//end of while
        }//end of method
    *Gives the amount of actor in the map of actors
    *return an int with the quantity
      public int getActorCount( )    
          return map1.size();
    *Gives the amount of movies in the map of movies
    *return an int with the quantity
      public int getMovieCount()
           return map2.size();
    }//end of DataBase2 class

Maybe you are looking for