Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: concurency

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default concurency

    Concurrency Project

    A simple computer game allows game characters to move around a 2D space discretized into a grid, with each character or obstacle fully occupying a grid cell, and each character moving atomically to adjacent cells. Given a destination, characters search for the shortest path to their destination and attempt to follow that plan. Once they get to their destination, or if they cannot reach their destination at some point, (perhaps because another character has moved into the way) they pause a turn, and then choose a new destination and calculate a new movement plan.

    Model each character as a thread, initially distributed around the perimeter of an m×m grid, and given random destinations. Each character moves discretely, at 20ms intervals, although movement rates otherwise just depend on thread scheduling. Obstacle cells are never chosen for destinations, and paths are calculated with Dijkstra’s or any other convenient shortest-path algorithm, ignoring the current position of other characters.

    Provide an obstacle map for your simulation. The map should have a random r cells set to obstacles such as in the Figure shown below. Note that obstacles are never within two squares of the perimeter.


    Figure 1 - Red dots show perimeter-distributed characters whilst the black squares show the obstacles

    Your application should take n and m as parameters, in that order and construct a simulation of n characters on an m×m grid. A visual depiction is not required, although you may find it helpful for debugging. It should always be possible for characters at least 2 squares away from each other to move concurrently, and movement must be atomic. Explain why your simulation does not deadlock.

    Try your simulation for m= 20 and m= 100, and values of n and r that produce sparsely populated and densely populated situations. Let each simulation run for 2 minutes. Once the simulation has ended report the total number of moves made by each character


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: concurency

    Do you have any specific questions about your assignment?
    Please post your code and any questions about problems you are having.

    What have you tried?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: concurency

    Did you have a question, or did you just want to copy and paste your homework here?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!