L
Luc The Perverse
I have a bit of a dilema (sp?) that I can't figure out. I just finished Day
13 in Learn Java in 21 days, and I know I am never going to learn any of
this stuff if I don't get my feet wet a little with a projec that I make.
Here is my layout:
class StandardMaze inherits abstract class Discrete2DMaze with a function
for drawing the maze and enabling pacman style loop around.
Then I have JMPanel extends JPanel which draws the maze
(JMPanel contains a Discrete2DMaze object passed in from elsewhere)
class Walkable2DMaze extends JMPanel implements Runnable
This is designed to let someone, or an AI go through the maze in an
interactive animated manner. But I would also like to have a mode in which
there is no display and I could run thousands of tests on various AI's. So
I will need to attach a class with a link to the maze for going through the
maze.
I don't know yet how to capture the keystrokes, but I think I can figure
that out on my own.
Here are my questions:
1. What is the proper way to "attach" an AI? I'm envisioning something
like
abstract class AI{
abstract Command WhatToDoNext(Surroundings WhatYouSee);
}
I haven't decided what goes in the Command or Surroundings classes yet
though. Setting it up like this will make latency from animation a virtual
non issue.
(As a matter of semantics, can you think of a better classname than AI,
since theoretically I could set up a text based maze game, and it would be
up to a person what to do next.)
2. How do I get "Command"s into the queue in a safe manner? Even though
the AI will not queue commands in the above format, I would like the key
listener to be able to queue commands while an animation is running.
A thread safe object queue class with two functions AddToTail and GetHead
would be great (You know . . when I put it like that, I am starting to
think it probably already exists.)
13 in Learn Java in 21 days, and I know I am never going to learn any of
this stuff if I don't get my feet wet a little with a projec that I make.
Here is my layout:
class StandardMaze inherits abstract class Discrete2DMaze with a function
for drawing the maze and enabling pacman style loop around.
Then I have JMPanel extends JPanel which draws the maze
(JMPanel contains a Discrete2DMaze object passed in from elsewhere)
class Walkable2DMaze extends JMPanel implements Runnable
This is designed to let someone, or an AI go through the maze in an
interactive animated manner. But I would also like to have a mode in which
there is no display and I could run thousands of tests on various AI's. So
I will need to attach a class with a link to the maze for going through the
maze.
I don't know yet how to capture the keystrokes, but I think I can figure
that out on my own.
Here are my questions:
1. What is the proper way to "attach" an AI? I'm envisioning something
like
abstract class AI{
abstract Command WhatToDoNext(Surroundings WhatYouSee);
}
I haven't decided what goes in the Command or Surroundings classes yet
though. Setting it up like this will make latency from animation a virtual
non issue.
(As a matter of semantics, can you think of a better classname than AI,
since theoretically I could set up a text based maze game, and it would be
up to a person what to do next.)
2. How do I get "Command"s into the queue in a safe manner? Even though
the AI will not queue commands in the above format, I would like the key
listener to be able to queue commands while an animation is running.
A thread safe object queue class with two functions AddToTail and GetHead
would be great (You know . . when I put it like that, I am starting to
think it probably already exists.)