• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Rat and Maze protocol

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So far i've built an array of char W= wall, O=open, R= rat, and P= path
I have another class "RAT" which will navigate through the maze. so im having trouble with the method to get the position of the rat when it is navigating through maze. this is what i have. Anyone have any good links similar to this??

 
lowercase baba
Posts: 12992
66
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would probably have a Rat class that I could ask it where it is. It should know where it started, and it knows where it moved, so it should know where it is.
 
christian scherlong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:i would probably have a Rat class that I could ask it where it is. It should know where it started, and it knows where it moved, so it should know where it is.



Okay thanks ill write up the rat class and see if that helps me out
 
Marshal
Posts: 73266
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
christian scherlong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:And welcome to the Ranch


Thanks !!
im still having a little trouble with this lol ill let you guys know if i need any help
 
Campbell Ritchie
Marshal
Posts: 73266
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is the maze array static? Do you intend all rats always to navigate the same maze? Do you intend never to change anything in the maze?
 
christian scherlong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Why is the maze array static? Do you intend all rats always to navigate the same maze? Do you intend never to change anything in the maze?


yeah im creating a maze and a rat which will navigate through it. The maze will never change. Afterwards we have to use a client and server in order for other people to use their rat to navigate through our maze and we have to navigate through theirs. My question is since my maze will be my server and my rat the client, do i have to write the server in the same class as the maze and the client in the same class as the rat ? Thanks
 
Campbell Ritchie
Marshal
Posts: 73266
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know precious little about clients and servers, but you would want the maze, rat, etc in their own classes, which would not change whether you are running on one JVM or client and server. So they should be independent of one another and you would need separate classes.

Little rule of thumb: it is quite difficult to write too many classes. It is very easy to write too few classes.
 
christian scherlong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:I know precious little about clients and servers, but you would want the maze, rat, etc in their own classes, which would not change whether you are running on one JVM or client and server. So they should be independent of one another and you would need separate classes.

Little rule of thumb: it is quite difficult to write too many classes. It is very easy to write too few classes.



lol i like that ^^ and okay thanks ill see if i can get this thing running then ill let you guys know if i have any other questions.
 
Campbell Ritchie
Marshal
Posts: 73266
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic