hw5 q3

31 views
Skip to first unread message

Dana Hurlbut

unread,
Mar 31, 2012, 3:24:17 PM3/31/12
to cs310_s12
I'm probably being really dense here, but what does "Starting from
TestGame.java..." mean in this context? Am I supposed to include a
test of DisplayTree in TestGame's main, or use TestGame.java in some
other way?

Betty O'Neil

unread,
Mar 31, 2012, 4:32:16 PM3/31/12
to Dana Hurlbut, cs310_s12
It just means start from that code and add to it, changing the
class name of course.

Dana Hurlbut

unread,
Apr 1, 2012, 7:09:04 PM4/1/12
to cs310_s12
Thank you! I have another question. In our notes from class 16,
towards the bottom, you give what the first few lines of the output of
DisplayTree1:

[] [] (1 next) (level 0)
[] [] (done) (level 1)
[1] [] (2 next) (level 1)
[1] [] (done) (level 1)
[1] [2] (1 next) (level 2)
[1] [2] (done) (level 3)
[1, 3] [2] (2 next) (level 4)

Is that last line correct? When I did it it only got down to level
3... when [1,3][2] is the state, it's not 2's turn next -- the game is
done. In other words, I thought those first few lines should look
like:

[] [](1 next), level 0
[] [](done), level 1
[1] [](2 next), level 1
[1] [](done), level 2
[1] [2](1 next), level 2
[1] [2](done), level 3
[1, 3] [2](done), level 3

Dana Hurlbut

unread,
Apr 1, 2012, 7:24:33 PM4/1/12
to cs310_s12
Sorry, one more question on hw5!

I'm trying to understand what to do in question 4. I think I'm not
quite sure what counts as a distinct game state. Should there just be
26 different game states (one for each line)? If you'd be able to post
an example of the first 5 or 10 output lines for DisplayTree2 that
would be really helpful. Thanks.

On Mar 31, 4:32 pm, "Betty O'Neil" <eon...@cs.umb.edu> wrote:

Betty O'Neil

unread,
Apr 1, 2012, 8:41:16 PM4/1/12
to Dana Hurlbut, cs310_s12
Dana--
Yes, you're right. Thanks for the report. I've fixed class 15's notes.
--Betty O.

Dana Hurlbut

unread,
Apr 1, 2012, 9:01:35 PM4/1/12
to cs310_s12
Thanks! So for part 4, would the correct first few lines of the output
be the following, or am I misunderstanding what's meant by distinct
game states?

[] [](1 next), level 0, G0
[] [](done), level 1, G1
[1] [](2 next), level 1, G2
[1] [](done), level 2, G3
[1] [2](1 next), level 2, G4
[1] [2](done), level 3, G5
[1, 3] [2](done), level 3, G6

Betty O'Neil

unread,
Apr 1, 2012, 9:35:13 PM4/1/12
to Dana Hurlbut, cs310_s12
No, your states named G1 and G5 are in fact equal by Game.equals.
I've added the first 7 lines of output for both DisplayTree1 and
DisplayTree2 to hw5.html, with the following for DisplayTree2:
[] [](1 next)(level 0): G0
[] [](done)(level 1): G1
[1] [](2 next)(level 1): G2
[1] [](done)(level 2): G3
[1] [2](1 next)(level 2): G4
[1] [2](done)(level 3): G1 <-- first repeated state
[1, 3] [2](done)(level 3): G5
G1 is the state where the game is over and player 2 won. It doesn't matter
to Game's equals method (Easy's equals) how the win was made.
The toString() display shows that the two G1 states were reached in
different ways. We see that two Game objects g1 and g2 can have g1.equals(g2),
but different toString() values, at least if the game is over. What matters
here is the equals result. See the Javadoc for equals.

Jing Shi

unread,
Apr 1, 2012, 10:15:06 PM4/1/12
to cs31...@googlegroups.com
Hi, Professor

I have a question. Are we supposed to deliver .java back to cs310/pa4/games  or cs310/hw5/games

Thanks

Betty O'Neil

unread,
Apr 1, 2012, 11:42:29 PM4/1/12
to Jing Shi, cs31...@googlegroups.com
Deliver your whole games project back to pa4/games, including the
.java files in the pa4/games/src/cs310 directory. Then it's
easy to test them there.
Reply all
Reply to author
Forward
0 new messages