Re: Problem With Our Code

0 views
Skip to first unread message
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Joseph Anthony Pasquale Holsten

unread,
Dec 13, 2009, 11:01:18 PM12/13/09
to ok...@googlegroups.com

On Dec 13, 2009, at 9:31 PM, James Edward Gray II wrote:

> On Dec 13, 2009, at 7:56 PM, Joseph A Holsten wrote:
>
>> James Edward Gray II wrote:
>>> We played with a battleship server at OK.rb this last week. A
>>> little programming challenge. It was fun.
>>
>> Did that code end up someplace? I checked github, no dice.
>
> Yes, it was posted to this list during our discussion:
>
> http://groups.google.com/group/okrb/browse_thread/thread/a2dffea7396b4f09

It seems I'm not awesome enough for google groups.

> Topic not found
> We're sorry, but we were unable to find the topic you were looking
for. Perhaps the URL you clicked on is out of date or broken?



This thread isn't showing up for me either. I'm going to stomp around,
wave a dead chicken, and try again tomorrow.

--

j

James Edward Gray II

unread,
Dec 14, 2009, 10:47:49 AM12/14/09
to OK Ruby Users
On Dec 13, 2009, at 10:01 PM, Joseph Anthony Pasquale Holsten wrote:

On Dec 13, 2009, at 9:31 PM, James Edward Gray II wrote:

On Dec 13, 2009, at 7:56 PM, Joseph A Holsten wrote:

James Edward Gray II wrote:
We played with a battleship server at OK.rb this last week.  A
little programming challenge.  It was fun.

Did that code end up someplace? I checked github, no dice.

Yes, it was posted to this list during our discussion:

http://groups.google.com/group/okrb/browse_thread/thread/a2dffea7396b4f09

It seems I'm not awesome enough for google groups.

Weird.  When I looked last night, it was all there in a nice thread.  Now I see one post.  That's handy.

Here's the relevant content, reposted from Alan:

Begin forwarded message:

From: Alan Baird <aba...@bairdsnet.net>
Date: December 10, 2009 10:32:53 PM CST
Subject: Re: Problem With Our Code

James -

Your fix gets the client working again.  I have attached a zipfile that has this fix in it as: battleship\client\ruby_sample\stupid_client_okrb.rb.  I have included the README for the client below so that should tell you how to run it.  However, it seems like the client still isn't quite learning where to fire because it seems to like to fire on places in the middle of nowhere instead of next to hits.  More room for optimization I guess.  It's even more interesting to run the client we finished tonight against itself.

Let me know if anyone has any questions about how to run this.

Thanks for letting us do this tonight, it was a lot of fun.

Alan


README

This is the standard battleship game, where each client places their ships on a grid, and then fires at the opponent. You fire as many shots as you have ships.

You start the game with between 1 and 10 ships, on a grid ranging from 5 to 20 per dimension, though there is no limitation that both dimensions are the same (meaning that the play area is a rectangle, not necessarily a square). Each ship ranges in size from 1 to 10.

When the game starts, the server will inform you of your number of ships, the size of each ship, and the size of the grid you will be working on. The server will then request the placement of the ships...

Look at the zipped attachment for more information.

To Run:

In the server folder, run:

python application.py

To Run viewer or human client:

You need to install PyQt, which can be found at: http://www.riverbankcomputing.co.uk/software/pyqt/download

To run the viewer:

python observer.py path_to_log_file

By default, an observer.log file is created in the server folder, so to see a replay of the last game, run:

python observer.py ../server/observer.log

FAQ (or questions I've been asked at all)

- Can I overlap ships?

No.  The server that is out on this page doesn't currently stop you from doing it, but it is against the rules, and is already checked for in the development version of the server.

- Is speed of processing important?

No.  As long as your program responds in a timely fashion, there is no bonus/punishment for taking a single millisecond vs. a whole second to calculate your response.

- There doesn't seem to be a message sent when a ship is destroyed.  Is that a mistake?

No. There is no message for when a ship is destroyed, only a message for whether it was a hit or miss.  It is up to your AI to make an educated guess as to whether it managed to sink something or not.

- So I have to write the client in Python?

No.  All communication uses standard in and standard out.  If anyone needs help getting a client setup for whatever language they want to use, let me know.

- What platform will this run on?

I'm running 32-bit Ubuntu Linux (9.10), so it would be nice that you aren't choosing something that won't run on Linux.  I could run everything inside of my Windows emulator if need be, but then I would have to say please be compatible with Windows instead.

So the official answer is you can choose any language, as long as you can get your client running on my machine.

- The server will be run on Python 3.1.1 or 2.6.4?

The server will be run on Python 2.6.4

- We might be given 10 ships all of size 2?  Are duplicate ship sizes possible?

Yes.  The server might tell you that this round all ships will be of size 2, or all of size 3, or a mixture of sizes.

- Can I run my program on a 100-core server and have my client connect to it for calculations?

Feel free.  As long as you can get it to communicate with the server on my computer using standard in/standard out, then I don't mind.  There is no penalty for your program being slower, so I'm not sure that there would be any use to this, but feel free.

- Do you plan on having any GUI rendering of the games?

Yes, there is a GUI (still in development) that replays the log file for  a graphical display.

- Why are some items separated by bars, and others by spaces?

I try to group attributes about a single object using spaces, and multiple objects are separated by bars.  So a coordinate will be separated by spaces, since the x and y are two attributes of a coordinate, while a list of ship sizes are separated by bars, since each size is an attribute of a different object.  I'm probably not 100% consistent with my methodology on this, but that's the idea.


--

You received this message because you are subscribed to the Google Groups "Oklahoma Ruby Users Group" group.
To post to this group, send email to ok...@googlegroups.com.
To unsubscribe from this group, send email to okrb+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/okrb?hl=en.
battleship.zip
Reply all
Reply to author
Forward
0 new messages