I really dont understand how this works

alright first off this isnt for a school assignment so please dont feel guilty about "giving it away"
alright so this has to do with something called gridworld, if you ever seen it you know what it is, if you havents its basiclly a java built world that has bugs, rocks, flowers, and other things.
(here is a video showing the basics of gridworld http://www.youtube.com/watch?v=ZnWGOT5Bd2E&feature=related). i program in JCreator btw not greenfoot.
alright getting to the point i have the code for a bug someone build called a "chameleoncritter". what the bug does is change colors depending on what it is next to, so if it is next to a pink rock it changes pink, ive been reading the code and can honestly not figure out how this method changes its color depending on what it is next to. here is the code
* AP(r) Computer Science GridWorld Case Study:
* Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com)
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation.
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* @author Chris Nevison
* @author Barbara Cloud Wells
* @author Cay Horstmann
import info.gridworld.actor.Actor;
import info.gridworld.actor.Critter;
import info.gridworld.grid.Location;
import java.util.ArrayList;
* A <code>ChameleonCritter</code> takes on the color of neighboring actors as
* it moves through the grid. <br />
* The implementation of this class is testable on the AP CS A and AB exams.
public class ChameleonCritter extends Critter
     * Randomly selects a neighbor and changes this critter's color to be the
     * same as that neighbor's. If there are no neighbors, no action is taken.
    public void processActors(ArrayList<Actor> actors)
        int n = actors.size();
        if (n == 0)
            return;
        int r = (int) (Math.random() * n);
        System.out.println(n);
        Actor other = actors.get(r);
        setColor(other.getColor());
     * Turns towards the new location as it moves.
    public void makeMove(Location loc)
        setDirection(getLocation().getDirectionToward(loc));
        super.makeMove(loc);
}if anyone can explain to me how this works it would be excellent.
one more thing, here is a link to the gridworld api (list every method and class and its function).
http://www.horstmann.com/gridworld/javadoc/
Edited by: vouslavous on Apr 17, 2009 8:51 PM

public void processActors(ArrayList<Actor> actors)
        int n = actors.size();
        if (n == 0)
            return;
        int r = (int) (Math.random() * n);
        System.out.println(n);
        Actor other = actors.get(r);
        setColor(other.getColor());
}Randomly selects a neighbor and changes this critter's color to be the same as that neighbor's. If there are no neighbors, no action is taken.
Mel

Similar Messages

  • How much does this cost? & I still can't understand how this work

    How much does this cost? & I still can't understand how this work

    Hello mkopti,
    ePrint is a free feature include on most of our wireless printers that are e-all-in-one enabled. It allows you to register your printer on HP's website http://www.eprintcenter.com and create an account. Once an account has been created you can enable the web services feature, after connecting to a valid network with internet access, which will print off a registration code you can use to add the printer to your account and customize an email address for the printer. This allows you to print to the printer from virtually anywhere simply by sending an email to the printers email address and when it is received it will print.
    Most of these printers are also Airprint enabled meaning you can print locally from the same network on the iPad, iPod, and iPhone (version 4.3.2 and higher) by using the built in "Print" command in the idevices.
    If you have any other questions or need clarification feel free to reply to this post and I will try to answer any questions you have.
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • I need help understanding how this works. AS 2.0

    Its my first time here and i only started learning flash today. I aint too great with maths and i was showed this piece of code that makes a triangles point follow the cursor. It involved mathimatical things ( which i aint so great at) and the guy said "You dont need to know how it works, just how to use it." well i copied his code and it worked, but i have no idea how to use it in other rotation apart from the one he taught us. I dont even understand how to redo his code i saved it to a word document and anytime i wanted to make something rotate something in that fashion i would refer to that. But i dont want to have to do that, i want to know how to use it, dont have to understand it, but use it for other rotation matters. If you are going to help, please try to be a bit simmple i explaining it, cause im new. Dont get me wrong i aint thick but i can find it a bit hard to follow some things, that is i my current problem.
    here is the rotation code:
    onEnterFrame = function()
    hero._rotation = getmouse(hero);
    getmouse = function(mc:MovieClip):Number
    dy = _ymouse-mc._y;
    dx = _xmouse-mc._x;
    rad = Math.atan2(dy,dx);
    rotate = rad*180/Math.PI
    return rotate+90
    also if it helps, here is the video i was watching: http://www.youtube.com/watch?v=w3OfrpbNhHs
    please if you can, explain how the entire thing works.
    thanks for any help given in advance.

    Hi,
    Here's a short primer.  It may not be sufficient but here goes.
    1st, move the closing bracket at the end and put it on the third line.  This makes the code more efficient
    onEnterFrame = function(){                               // this causes Flash to repeatedly
                                                                              execute the next line at the
                                                                              frame rate you selected
                                                                              for your document
           hero._rotation = getmouse(hero);               // this tells Flash to rotate a
                                                                              movie clip (named hero) based
                                                                              on the function getmouse()
    };                                                                     // putting the }; here makes the
                                                                              code more efficient and readable
    getmouse = function(mc:MovieClip):Number{   // This is the function called with
                                                                             mc referring to hero that was
                                                                             passed from the second line.
         dy = _ymouse-mc._y;                                // dy means delta y which subtracts
                                                                            the y position of the movieclip
                                                                            from the mouses y position
         dx = _xmouse-mc._x;                               // dx = delta x (same as above line
                                                                            but on the x axis)
                                                                         // once you have the x and y sides
                                                                            you male a triangle.
                                                                            Now use trig to find the angle
         rad = Math.atan2(dy,dx);                           // the computer works in radians
                                                                            the arc tangent atan2 will give the
                                                                            angle in radians
         rotate = rad*180/Math.PI                            // you want to convert the radians to
                                                                            degrees, that's what this line does
         return rotate+90                                         // this returns the value of rotate back
                                                                            to the calling function in line 2.
                                                                            the +90 determines which part
                                                                        // of the hero movie clip is facing the
                                                                           mouse.
    If you put the mouse cursor over any of the green reserved words above in the Actions panel you will get a desctription of what these do.
    hope that helps.

  • I just dont understand how to work photo shop HELP ME

    my mom bought this for me and im reading the directions and trying to figure out how it works i just dont get it at all!!! i dont know why, im good at using computers i just nvr grasped the concept of how to work this
    if you have a helpful hint please comment  thank you

    Adobe TV has a whole selection of free videos that should help you to get started.
    http://tv.adobe.com/show/learn-photoshop-elements-8/
    You can also find lots of videos using Google...
    http://www.google.com/search?hl=en&client=opera&hs=6js&rls=en&q=Photoshop%20Elements%208&u m=1&ie=UTF-8&tbo=u&tbs=vid:1&source=og&sa=N&tab=wv
    or YouTube
    http://www.youtube.com/watch?v=F1ZEEPNaqQ0
    If you just search for Photoshop Elements (without limiting it to Photoshop Elements 8 as I did) you will get even more results...most if not all things should work in version 8. (Version 8 user interface will look different and may have additonal features as each version gets new goodies.)

  • HT1926 is there anyway around not being able to  download itunes on the surface i downloaded an app for the RT call RTremote and its for itunes but i dont understand how it works

    i have recently purchased a Surface RT because i liked the idea of the PC/Tablet but now im beginning to think i screwed myself over. for instance i cant download itunes well... i can it goes through the entire download and at the very end it tells me that i cant run this on my PC asnd wants me to get evrything out of the windows store. i dont understand this i still have a desktop feature that looks and is like any other computer but why can i not download itunes? also i downloaded the RT remote app which is supposed to access itunes but it as to be up and running on your desktop I DO NOT UNDERSTAND THIS! please help

    It is not possible to install iTunes on a Windows RT device.  The RT device is not a full scale computer OS.

  • SMTP Banner mismatch - still not understanding how this works?

    I have a new Exchange 2010 install.  
    My outgoing email is getting flagged as spam.  MX Record test shows SMTP banner mismatch.
    I understand that you don't change the FQDN on the receive connector using the GUI.
    I have created an additional Receive connector so I have the following:
    Receive Connectors:
    Client Comm
    Default Comm
    My question is how to I change the smtp banner and which connector do I set it on.  The syntax needed for the Set-ReceiveConnector is kicking my butt.
    It sure is frustrating that the new Windows World is so centered around Powershell command lines. Very frustrating and backwards technology.
    The documentation on the Set and Get-Receiveconnectors is very poorly written. IMHO.

    My reverse DNS is setup correctly.
    This is an issue with the receive connector banner page.  Some email hosting services, AOL, Hotmail etc.  are flagging my outbound email as junk.  So they must be doing a test to see that my receive connectors have the wrong SMTP banner.
    My send connector is ALSO setup correctly.  
    I need help with the syntax in using the Set-receiveconnector cmd.
    Follow:
    http://technet.microsoft.com/en-us/library/bb125159(v=exchg.141).aspx
    Create a Internet type custom receive connector. My assumption is that you receive internet messages directly to the hubs. When you create an Internet Receive Connector it will allow anonymous senders to connect to it so it will work for internet messages. 
    In the Specify the FQDN this connector will provide in response to HELO or EHLO field, type the name advertised in response to the SMTP HELO or EHLO verb. If you leave this field blank, the fully qualified domain name (FQDN) of the Hub
    Transport server or Edge Transport server is automatically added when the connector is created
    Twitter!:

  • Help understand how this works

    Hows everyone doing, i need some help understand this. This is my first time using Lulu. From the reviews i'v read about it they tell me this is the #1 place to come to to get my books printed. Here the question,  i have all 3 of my books ready to be uploaded do i just sent that in, then they send me the prints ? or so they self them for me. Sorry if this seems like a dumb question, but its my first time using this particular site.

    Here's a quick overview:
    You start the new book wizard. Click "Create," pick a book type and size (hardcover, paperback, etc.; 6x9, 8.5 x 11, etc.), and click "Make this book."
    Hint: If you want the widest distribution for your book, pick a size / type that has a green checkmark next to it.
    The wizard will guide you to name your book, apply an ISBN (or get a free one), upload your contents, and upload your cover or design a cover. It will guide you to set pricing and distribution, and many other options.
    When you've done all that, your book will be available to order. You will see two prices: the one you pay, and the one other people pay. The one you pay is the printing cost per book. It may be anywhere from $2.50 to $20.00 or more, depending on options you pick -- probably coser to the low end.
    On that first page, where it says "Create," there is a calculator that will figure roughly what your book will cost (printing costs), so you can plan your options around that calculator.
    So you order as many books as you want, pick shipping, pay with a credit card, and in a few days, the books are on your doorstep.
    I hope that helps.

  • Transitions still screwy. Can somebody help me understand how this works?

    I'm struggling to understand why my transitions and/or titles aren't working right when exporting.
    On the video I'm currently putting together I'm using the scrapbook theme.
    When I preview the video it looks perfect but when I export it I get this:
    During the yellow "title" sequences, the video is supposed to be running inside a "photo frame" graphic and then at the last 1/2 second or so zoom right into the remainder of the video. What happens instead is that the video gets to the point where the title graphic is supposed to zoom gracefully into the video and instead it just cuts right to the video. The inverse happens at the beginning of the title sequence as well.
    I have two links that illustrate this. One is a screenshot of the section of the project in question and the other is a video of the preview with the quicktime .mov running underneath it.
    Sorry for the crappy quality of the video with the watermark. It's clearly not worth the price their asking to get rid of the watermark since it's nowhere near that jerky on my screen.
    Any help you can give me would be great. This is happening on almost all these titles in this project and has happened a lot in the past.
    http://www.mvlawn.com/screenshot/Screen%20shot%202009-11-16%20at%206.25.36%20PM. png
    http://www.mvlawn.com/screenshot/iShowU-Capture.mov
    (Ignore the exclamation triangles, I didn't have my external drive plugged in when I took the screenshot)
    THANKS!!
    Message was edited by: Kevin Berube

    One thing to keep in mind is that when you have a transition (it looks like you are using Fade Through Black), it takes half the frames from the preceding clip and half the frames from the following clip. Si if you have a 1/2 second fade through black, it needs 8 frames from the preceeding clip and 8 frames from the following clip.
    But you have the photo album title also contending for those same eight frames.
    I think you would get better results if you either
    1) removed the fade through black transition, or
    2) moved the start of the title to the right so that it started on the 9th frame or later.

  • HT1481 i dont get how this works

    i forgot my pass word from my ipod, and its says ( IPOD IS DISABLED ). how can i take that off???

    You'll need to connect the device to iTunes and restore it.  If iTunes doesn't recognize the iPod still, try manually placing it in recovery mode first and then performing the restore in iTunes. See this article for instructions on putting the iPod into recovery mode.
    iOS: Unable to update or restore
    B-rock

  • I really can't understand how this recursive works??

    Hi all,
    I have got a recursive function that checks for palendrome string. But it is confusing. I know that a string is palenromme if it is empty or has a char or first char and last one are same and middle is palindromme too.
    but can't understand how this function works.
    class Palindromme
         boolean palindrom(String s)
              if (s.length() <= 1 || s.equals(null) || s=="") //this is the stopping point
                   return true;
              else
              {                    //recursive definition
                   return ( s.charAt(0) == s.charAt(s.length()-1) ) && palindrom(s.substring(1,s.length()-1));
    specially i don't know how palindrom(s.substring(1,s.length()-1)); is working cause it has to be increased for each loop.
    abdul
    PS: actually i don't know how recursion works from Data structure point of view

    Hi,
    ok your palindrome is : "otto"
    return ( s.charAt(0) == s.charAt(s.length()-1) ) && palindrom(s.substring(1,s.length()-1));
                  o                     o                                   tt
    so first part is true                                        
    in the second part palindrom is called again but with the remaining tt
    so second time :
    return ( s.charAt(0) == s.charAt(s.length()-1) ) && palindrom(s.substring(1,s.length()-1));
                   t                     t                                 ""
    Third time:
    if (s.length() <= 1 || s.equals(null) || s=="") //this is the stopping point
    return true;after all for otto the recusion is:
    return ( s.charAt(0) == s.charAt(s.length()-1) ) && s.charAt(1) == s.charAt(s.length()-2) ) && nothing left of otto);
    Phil

  • I want to understand how crypto works.

    Hi, I want to understand how crypto works and all. where i can start with. i really dont know anything about crypto. i need to understand how DC and keys and algorithims work together and how they work. pls suggest me where and with what i can start.

    Since you asked on the Java Cryptography forum, I would recommend beginning with this book:
    Beginning Cryptography with Java
    David Hook
    ISBN: 978-0-7645-9633-9
    http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764596330.html

  • Need a Little Help with Understanding How Layers Work in PSE

    I have PSE version 5 and I am using it on a PC with Windows XP.
    As I get more into editing photos, I am enjoying it, but confusion is also starting to set in.  My question is about layers.  When I go to edit a photo for web/email use only, I start by resizing it to 72 ppi and then reducing the pixel dimensions quite a bit.  Then after that I normally go through this process of editing the photos by using normally about three different commands.  One is Levels, then I may go to Shadows/Highlights, and then my last command is always sharpening.  I used to do this all on one layer, but then finally learned to put each one of these editing features on their own layer so I can make changes/deletions without too much trouble.
    When I started doing the separate layers, I was just making a copy of the background layer each time and then touching that particulay layer up with Levels, Sharpen or Shadows/Highlights.  But I noticed that depending on the order in which the layers were placed, some changes would be obscured.  If I put the Levels layer on top, and then the Sharpen layer and the Shadows/Highlight layer below that, the sharpen effect and the shadows/highlights effects were no longer there.  I could only see the levels effect.  The photo was still not sharp and so on.  If I put the Sharpen level on top, then the photo showed the sharpen effects, but now the Levels and Shadows/Highlights effects were no longer visible.
    So then I started to make a copy of the background initially, do a levels adjustment here, then, instead of making a copy of the original background layer again, I would make a copy of the layer that now has the levels changes on it.  Then do the sharpen effect on this layer.  This way I had all the changes on one layer as long as I put that layer as the top layer.  But then I realized that I once again fI didn't have a layer with only one fix on it.   Finally, I started to use an adjustment layer for Levels, put this as the top layer, make a copy of the background layer, do shadows/highlights, copy background layer again, do sharpen, and this seems to work a little better.  But even with this way, depending on what order I place the sharpen and shadows/Highlights layers, one of them still seems to get obscured by the layer above it.
    Can someone help me to understand how layers work in this regard.  I am obviously a little confused here.
    Thanks,
    Lee

    You really aren't working efficiently. First of all, do your editing on a full sized version of the photo, since you have more data for PSE to work on and will get better results. Use save for web to make your web/email copy when you are totally done. You can resize it down on the right side of the save for web window.
    Duplicating a regular layer makes an opaque layer that obscures the layers below it. It's best to start off by not working on your original image, so that you don't have to worry if you mess up. If you're working on a copy, you can work right on the background layer, or only duplicate the layer once and apply your changes to that. So you'd apply both shadows/highlights and sharpening to the same layer.
    Finally, you should use an adjustment layer for levels. Layer>New Adjustment Layer>Levels. This will put levels on a transparent layer above your image, but you will need to click the layer below it to get back to a pixel layer to apply other changes (you can't sharpen an adjustment layer, for example).

  • I barely got my iphone on sunday & i really dont understand Wi-Fi or Edge

    I do not understand how that works, and what's the difference between Edge & Wi-Fi and also how i can connect to Wi-Fi because i am really lost ;o( lol

    Will try to keep this in simple terms.
    Edge is just a fancy name AT&T has for it's service.
    If you are using your phone and see the E next to your signal strength, you are on Edge. This means you can email, browse the web, send SMS etc.
    Pretty much just means your phone will work.
    WiFi is a term from the computer world mainly. For many homes that have internet access, people have bought Wireless Routers to plug into their cable/dsl modems that will broadcast a wireless signal (WIFI) so other computers with a wireless card can connect to their home network and browse the web all sharing the same connection. Laptops with WiFi cards in them can also go to places like Panera Bread, Starbucks, bookstores, etc that offer free WiFi (those places setup a wireless router(s) just like people at their homes did) but they expose them publicly to anybody within range (usually within the store or just outside is the range).
    Your iPhone has a WiFi card in it. So if you have setup a wireless network at home, you can jump on it and thus browse the web and send emails (and shop on iTunes) from your phone at Broadband speeds (which is faster than using Edge).
    If you have never setup a wireless network at home, then really all you can do is use free spots (or friends homes that set one up).
    WiFi simply means you are jumping onto a wireless network that is nearby (not everywhere) to gain broadband speeds to using internet related features of your phone. And WiFi is only available where you find a WiFi hotspot or set one up yourself.
    Edge is the AT&T network that lets you make calls as well as all the other internet related features (just slower). And Edge is available anywhere in the AT&T coverage.
    Message was edited by: DaVBMan

  • HT1386 When i connect my iPhone to iTunes, it says i have to set up my iPhone, and wont allow me to sync any media i have already purchased on it. My phone is not new, so I dont understand? This all came about when i updated the iOS 6 software.

    When i connect my iPhone to iTunes, it says i have to set up my iPhone, and wont allow me to sync any media i have already purchased on it. My phone is not new, so I dont understand? This all came about when i updated the iOS 6 software. I have tried to re-set up my phone but it makes no difference and deletes everything off my phone.

    bubblesblom wrote:
    Okay, so my friends think it is funny to change the passcode on my iPhone.
    Maybe you should get new friends.
    I'm not sure that recovery mode works when you have to trust the computer, but did you try it?
    If you can't update or restore your iOS device - Apple Support
    If that won't work, perhaps you can use Find my iPhone from a computer in your iCloud.com account to erase the device.
    iCloud: Erase your device - Apple Support
    This has nothing to do with the Find my iPhone app being installed on the phone, but you do have to have Find my iPhone activated in the iCloud settings on the phone.

  • How works lync when I made a video conferences with someone in my same building?I want to understand how lyncs works, when I made video conferences with someone in my same building, if my call go to to server and then go to the person I´m calling. Or if L

    I want to understand how lyncs works, when I made video conferences with someone in my same building, if my call go to to server and then go to the person I´m calling.
    Or if Lync realizes that we are in the same building so it never leaves, so it don’t generate traffic. My concern is the bandwidth consumption.
    Please a I need the information.
    thanks

    In addition, you can refer to the following link about the media connection in different scenarios:
    http://www.shudnow.net/2010/12/06/lync-server-2010-port-ranges-and-audiomedia-negotiation/
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make
    sure that you completely understand the risk before retrieving any suggestions from the above link.
    Lisa Zheng
    TechNet Community Support

Maybe you are looking for

  • Cover Flow Mix Up and Album Song Mix Up Question

    I just got an 80gb ipod and have all my songs on it now. i am just about finished with getting all of the album covers that i didnt have into my itunes now. i didnt get any of the album covers from itunes, i just did a search for all of em in google.

  • System Hang, kernel panic.

    Hello list, Doing some independent research into an issue we are having here. We have 21 x4540s running 5.10 Generic_141445-09. They are used as NFSv4 servers to front-end servers. The x4540s that are used for mail (postfix+dovecot) periodically hang

  • Embedding HTML in the Title Bar of a JFrame

    Hi Folks, I have a simple question. Do you know I can I employ an HTML-enabled script in the title bar of a JFrame? I would like to make use of the subscript tag in HTML <sub>, yet it didn't work out: public class MyFrame extends JFrame{ super("<html

  • Can't Access files in file manager

    I can't access any of the files on my nokia 5530 memory card through the file manager. The music player still displays and plays all the music files which are on the memory card. But image gallery doesn't display memory card pictures anymore.And I ca

  • HT204379 How can I create a screensaver?

    Trying to find a simple way to do this. Not sure what file format this should be or what program to use to create it. Was trying to do something simple like export a Keynote animation as a mov file, then convert to a screensaver. Thanks!