Store Moves to memory

I have a simple twist on the hunt the Wumpus game where the object is to find a pile of smelly socks and then return to the starting position. My code is very basic and not the most intelligent agent but it gets the job done. the problem I am having is returning to the starting position. I have considered using an array or a stack but I am unsure how to implement it. Thanks for reading
import java.applet.Applet;
   import java.util.Random;
   import javax.swing.JOptionPane;
    public class WumpusWorld extends Applet
       public void init ()
         Room   edsRoom = new Room("wumpusworld.room", this);
         Butler james   = new Butler (18, 3, edsRoom);
         System.out.print(james.getX());
       System.out.print ( james.getY()); 
         edsRoom.waitForStart();
         int[] move = new int[600];
         int index = 0;
         Random rand = new Random();
         while(true)
            while(james.isFrontClear() == true)
               james.forward();     
               move[index]++;
                          System.out.print(move[index]+"Shit\n");
            while(james.isFrontClear() == false && james.isLeftClear()||james.isRightClear())
               if(Math.random() < .25)
                  james.turnLeft();
               else if(Math.random() < .25)
                  james.turnRight();
               while(james.isFrontClear())
                  james.forward();
                  move[index]++;
               if(james.isFrontClear() == false && james.isLeftClear() == false && james.isRightClear() == false)
                  james.backward();
                  james.turnLeft();
               if(james.senseSmell() == 96 && james.seeSocks())
                  james.pickUp();
                  james.forward();
                  move[index]--;
                  System.out.print(move[index]+"Number of moves");
                              String outputStr;
                              outputStr = "Health"+james.getHealth();
                              JOptionPane.showMessageDialog(null,outputStr,"HEALTH",JOptionPane.INFORMATION_MESSAGE);
                              System.out.print(james.getHealth());            
            while(true)
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());
               System.out.println(james.seeSocks());
               james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());
               System.out.println(james.seeSocks());
            //james.forward();
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.forward();
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.turnLeft();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());     
               System.out.println(james.seeSocks());
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());
               System.out.println(james.seeSocks());
            //james.forward();
               System.out.println(james.senseSmell());
               System.out.println(james.senseBreeze());
               System.out.println(james.senseHeat());
               System.out.println(james.seeSocks());
            //if (james.seeSocks()) james.pickUp();
               System.out.println(james.getHealth());
         //james.turnLeft(2);
         //james.forward(4);
         //james.turnRight();
         //james.forward(7);
   }

I looked into the approaches and I appreciate the idea because I had never heard of those algorithms before and for a more advanced project i will look into those. I think for this project a stack or array will be more ideal. I have a working stack now that stores a value for each move. forward = 1, backward = -1, left = 2, and right = 3. Now i dont know how to go about the pop. should i use a case switch or if statements. The plan is to swap the values, that is when bactracking backward = 1, forward = -1, right = 2, and left = 3. here is the new code.
   import java.applet.Applet;
   import java.util.Random;
   import javax.swing.JOptionPane;
   import java.util.*;
    public class WumpusWorld extends Applet
       public void init ()
         Room   edsRoom = new Room("wumpusworld.room", this);
         Butler james   = new Butler (18, 3, edsRoom);
         edsRoom.waitForStart();
         int direction = 0;
         boolean n = true;
                    Random rand = new Random();
         Stack movesMade = new Stack();
         while(james.seeSocks() == false)
            if(james.isFrontClear() == true){
               james.forward();
               movesMade.push(new Integer(1));
                if(james.isFrontClear()
                  james.forward();
                  movesMade.push(new Integer(1));
               if(james.isFrontClear() == false && james.isLeftClear()||james.isRightClear())
               direction = rand.nextInt(2);
                  if(direction == 0)
                     james.turnLeft();
                     movesMade.push(new Integer(2));
                  else if(direction == 1)
                     james.turnRight();
                     movesMade.push(new Integer(3));
               if(james.isFrontClear() == false && james.isLeftClear() == false && james.isRightClear() == false)
                  james.backward();
                  movesMade.push(new Integer(-1));
                  james.turnLeft();
                  movesMade.push(new Integer(2));
               else if(james.senseSmell() == 96 && james.seeSocks() )
                  james.pickUp();
                  break;
            while(!movesMade.empty())
          // Insert backtracking pop here

Similar Messages

  • Add Move to Memory option for Applications in Settings for Dell Venue 7 OS

    The "Move to Memory Card" option was not enabled by Dell. It should be. <Forum violation = soliciting>. Dell, please add this feature. It is useless to have a memory card if you can't store apps on it. That's the main purpose of it. The camera is so slow it really isn't going to be useful to store photos on memory card, not even sure this option is enabled LOL. Anyways. Need to be able to store Apps and increase system memory to speed up operation. As it is anything over 5GB in total apps will bog down the Venue 7 making it basically useless. I feel like it's like using dial-up all over again. I should have got the iPad Air.

    I'm running a 32gb card for music and movies.  Have no problems.  Load the card via computer attached with usb cable.

  • How to store movies on Apple TV without keeping them in the iTunes library

    I'd like to know how I can store movies on the Apple TV without having to keep them in the iTunes library. I'd like to use the 160Gb of space on my Apple TV without having to use the same space on my nearly full MBP hard disk !
    Thanks in advance...

    Totem wrote:
    The idea of storing songs, movies and photographs on the ATV is to allow the end-user to turn off their computer and just use the device like a stereo/video component.
    Ah! Of course... I wasn't even considering this b/c I'm one of these people who almost never has his computer off b/c I work from home and also do a lot of web surfing, etc. but obviously many many people have the computer shut off much more often than it is on.
    So, alright. I see why the hard drive is there... it just seems so tempting for it to be able to be more of a stand alone device, more like another computer with iTunes on it rather than like a big iPod that sits under my TV. I guess I'll file that away in my tech wish list...

  • How to store movies & TV shows in a different location

    Hi there!
    I've seen many of you asking (unfortunatelly with no clear answer) how to store movies & TV shows into another location away from the iTunes Music folder. This idea is to store videos on an AirDisk drive and keep music on the MacBook for example!
    I've been trying to do so in the past few days but some pb have occured...
    - it is possible to replace the Movies folder by an alias pointing to a Movies folder in the AirDisk drive: existing movies will be playable in iTunes.... the problem is that when I try to add new movies iTunes do not store them into the Movies folder on the AirDisk but in the local music folder (very strange as it is a video file!).
    Has anyone succeeded in using such mechanisms?!
    Many thanks for your answers!
    Guillaume,

    kazbe81 wrote:
    I've got a couple of movies and tv shows that I've deleted from my purchase list on itunes as well as my download file on my computer but they are still on my itunes in the cloud does anyone know how I can delete these?
    You cannot delete them from iCloud.
    They are purchased and will always be available in iTunes in iCloud for you to download again if you wish.

  • Can't I use time capsule to store movies from itunes?

    Hi,
    Here's my problem. I have a Time Capsule running as a router as well as a HDD and my OS is Windows 8. My music and Tv Shows purchased on Itunes are stored on the TC. However when I try to store movies I get this message:
    "This item is incompatible with your hard drive.
      You have a FAT32-formatted hard drive. This means that you cannot buy items that are larger than 4 GB. Click OK to learn more."
    Is there anyway to store my movies on it without change the quality from HD to SD? And if someone knows please tell me why the limit is 4 GB and not 10GB for example(it would definitely solve the problem).

    Sure.
    Why are so many peolple asking this?
    Just store your files there. 
    And when using Time-Maschine for the back-up select the Time-Capsule (whatever name your has) as the place to store the date.
    cheers, anne

  • I purchased a Shakira movie (HD). I watch it OK in my PC, but when trying to watch it in my TV using Apple TV I get an endless rolling wheel. I can watch other Apple Store movies with no problem. Any ideas of what's going on?

    I purchased a Shakira movie (HD). I watch it OK in my PC, but when trying to watch it in my TV using Apple TV I get an endless rolling wheel. I can watch other Apple Store movies with no problem. Any idea of what's going on?

    Welcome to the Apple Community.
    Try repopulating iTunes with the problematic files.

  • How to store movies in oracle 8i

    Hi, I'm workin on an oracle 8i based project. In that project I need to store (.dat) movies in database. I'm using Java as my front-end tool. Plz give me the exact procedure to store movies not necessarily .dat, but movies of any format as thinking I'm the naive user of oracle.

    The exact procedure would depend on the tool set you are using and on your Oracle version.
    You would use the BLOB datatype to hold the movie file and you can manipulate it using the dbms_lob package. See the manuals.
    If you provide more details on the tools being used, the application, average size of clip, etc... someone may be willing to provide more specific advice.
    HTH -- Mark D Powell --

  • Store to Store (Movement type 311) and Transportation Module

    Hi,
    We have a new business requirement to link store to store movements (currently using 311 movement type) to the transportation module. Can anyone help me on how to set up this link?
    Thanks in advance,
    Finbarr

    Dear Finbarr O'Donovan
    trasportation planning for shipment
    inorder to implement transportation Module
    define Transportation Planning Point Determination,Define Number Ranges for Shipments,Maintain Transportation Relevance,Maintain transportation relevance for routes,Define Shipment Types,Maintain Standard Selection Variants for Shipment List,Define Transportation Connection Points
    <i><b>Additional Data 1 Priority</b></i>
    01 Urgent Process; High priority Shipment
    02 Express Delivery
    03 Collect  / Ex Works
    04 Priority 04 / Priority +
    05 Priority05  / Standard priority
    06 Priority 06 / Low priority
    To change the priority of the assigned deliveries and Transfer orders
    <i><b>Additional data 2 Staging area</b></i>
    Copied to the assigned deliveries and transfer orders
    <i><b>Shipment status Planning</b></i>
    Who     Outbound planning
    When
    Planning shipment is completed and the warehouse activities can be started (Staging area known)
    What
    Output type is created = Picking Wave / group.
    Groups all transfer orders for several deliveries to the same ship-to address (based on Shipping point, Shipping condition, Route, Ship to number, Warehouse number, Address number).
    <i><b>Shipment status Check-In</b></i>
    Who     Dispatch controller 
    When      
    Truck arrives at the gate and the driver must check himself in.
    Why
    To monitor the forwarder
    <i><b>Shipment status Loading Start</b></i>
    Who     Dispatch controller
    When
    Warehouse internal activities are completed.
    Deliveries are on the Bay and the documents need to be added to complete the shipment.
    > Not possible if the Warehouse processes are still not completed
    What
    Print outs
    Pack list
    Delivery Note
    <i><b>Shipment status Loading End</b></i>
    Who     Dispatch controller
    When
    Loading of the truck is completed.
    What
    Print outs
    Truck manifest
    <i><b>Shipment status Shipment completion</b></i>
    Who     Dispatch controller
    When
    Dispatch activities are completed and the truck has left the yard
    What
    Triggers goods issue
    Which is trigger for Billing
    <i><b>Agenda Outbound monitoring</b></i>
    VL10     Collective Processing of Documents due for Delivery 
    VL06O     Outbound delivery monitor
    VT11     Transportation planning list

  • I want to store movies on an SD disk, watch them on the way to Europe, then use the chip to record photos in my camera.  I can't get the iPad mini to recognize the videos I've recorded.

    I want to store movies on an SD disk, watch them on the way to Europe, then use the chip to record photos in my camera.  I can't get the iPad mini to recognize the videos I've recorded.

    I'm a bit lost - you first say
    "The only file(s) I can sometimes get it to recognize are the ones shot with a camera onto an SD card"
    then you say
    " If I take an unused SD card and record video with my camera, it will see, and import the file to the Photo app."
    In the first statement, aren't you using an SD card in the camera?  And what do you mean by "unused SD card"?    Cameras put their files in specific folders on a card, and your device only reads photos and video from those folders, not from anywhere else on the card.

  • How can I store movies in the cloud and access them from my devices?

    Hello,
    I would like to store movies in the cloud and access them from my device without having to download them to the device because there is not enough space on the harddrive to store them on it. How would I do this? Would I have to download the movies to my PC or could I store them directly in the cloud?
    Thanks,
    Tyler

    Unfortunately I don't use sugarsync myself, I have a dropbox account and it works slightly differently.
    As I understand it you can upload files to a folder in sugarsync from your computer without having them sync to any of your devices. You can access that folder from any of your devices, and although you would need to download them in order to play the video file, you could then delete them without deleting the files in the sugarsync folder in the cloud.

  • How can I store movies in the cloud and access them on my devices without having to download them to them?

    Hello,
    I would like to store movies in the cloud and access them from my device without having to download them to the device because there is not enough space on the harddrive to store them on it. How would I do this? Would I have to download the movies to my PC or could I store them directly in the cloud?
    Thanks,
    Tyler

    Would I have to download the movies to my PC or could I store them directly in the cloud?
    There is good news coming!
    Technology experts are working on a movie storage system where YOU have physical possession of the movie.
    This system stores the movie digitally on an optical disk system that will not be dependent upon a congested, complicated, and fragile network.
    Because all of the data is stored only a few feet from your television, all the bottlenecks are removed.  Performance and reliability are virtually flawless.
    Further, the system will not utilize any form of security codes, authentications, or passwords. Once the optical disc is purchased it can be moved around freely at will, and can even be lent or given to friends and neighbors with zero hassles.

  • Where to Store Movies???

    Is it better to store movies in the imovie events or in iphoto? Right now I have many home movies stored as imovie events on several hard drives. However, its a bit cumbersome if I'm trying to make a project using photos & videos its a lot of go between.
    Anyway, if its better to store in iphoto, is there a way for imovie to show videos stored in multiple iphoto libraries?
    Thanks in advance for any pearls of wisdom...

    I think it's a matter of choice, personally I don't see any particular advantage in moving them (with possible exceptions) but there would really be no need to have them in both places.
    The exceptions I mention are:
    Having video in im instead of ip, frees the video from being stored in your photo library, you would be able to move it to an external drive for example without having to move all of your photo library.
    Also being in iphoto, the video is shared with other iphoto users, this isn't the case with im video.

  • HT4914 can I store movies in itunes match

    Can I store movies in itunes match, or does it purely support music only?
    Thanks
    Andrew

    Music only. From HT4914
    Summary
    iTunes Match is a feature of iTunes in the Cloud that allows you to access your personal music library from any authorized computer
    tt2

  • Navigating iTunes store movies in iPad

    OK, I hope I am missing something, but this is driving me a bit mad.
    Is it possible to navigate the iTunes Store movies and TV collection by genre, on your iPad? It is possible within iTunes on the Mac, but I cannot for the life of me find a way to do it on the iPad.
    All I can do is see the top charts, or a Genius list, or Featured ... but there seems to be no way to choose to browse, for example, all movies in the Family genre.
    Can anyone help? Am I just being particularly dense today?
    Kip

    I know that content differs from country to country depending upon laws and restrictions of the country and the content being licensed in that country, but it seems that the button should be there if you have the Movies tab in iTunes in the music section. Typically, if content is not available, the tab will not show up at all.
    Try doing a search for anything in the movies section and then cancel the search. See if the button shows up. Try quitting iTunes completely as well and then try again. This is a copy and paste that I keep handy for quick "generic" fixes. You can try these as well.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Quitting iTunes - Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.

  • HT3775 cannot open movie on memory stick

    how do i open movie on memory stick on my macbook

    I wiped my iphone as there was an issue with the audio.
    Decided not long after to wipe my laptop also.
    I downloaded my purchases back onto my laptop.  Tried to sync, and got the same error.
    Deleted the purchases from my iphone.  Went into Itunes on the iphone and downloaded a purchase right on the iphone.  Same problem.
    Any solution for that?  It is happening with more than one movie.  In particular, The fast & the furious, the fast and the furious: tokyo drift.
    Some movies work, like Fast & Furious (the fourth installment).
    I have unlimited bandwidth so I don't care how many ways or times I have to try to get this to work again on my iphone, but please there needs to be a solution.

Maybe you are looking for

  • Strange problem... Query runs faster, but report runs slow...

    Hi Gurus, We are using Report 10g on 10g Application server and solaris. we created a report on a table which has 10,000 rows. The report has 25 columns. when we run this query in Toad it took 12 sec for fetching all these 10,000 rows But when we run

  • Flex services with multiple return types

    Hello, We are creating a webapplication with flex and php. Everything is working very good, until we got to the library part of the application. Every service so far had only 1 return type (eg: User, Group, ...) Now for the library we want to return

  • Mac Pro 8 core - great, but not great... Any ideas please?

    Hi Guys, Firstly, let me say I'm Apple Certified in FCP so I'm not a newbie, however I am having a hard time coming to terms with my current situation. My G5 Quad appeared to be struggling on some basic (3 layers of text) real time stuff in PAL DV, a

  • Insufficient space on vault to back up library

    I have a vault on an external 500Gb firewire drive, and aperture will not update as it says there is not enough space on the drive, although there is 100Gb free and the library is only 364Gb total, any ideas? G5 Dual2ghz 4Gb Ram. Library on 500Gb Sat

  • Switching from case to event structure

    I once down converted some LV 7.0 code to 6.0 and it (automatically) converted an event structure to a case structure.  When trying to upgrade some code to change a case structure to an event structure, I didn't see any means for doing that (a flat s