Mobile Operating Systems and Applications (CSCIE-65)

tenderlaΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

95 εμφανίσεις

Mobile Operating Systems and Applications (CSCIE


(Due by

About this
(mini) project

The purpose of this mini project is to get you

acquainted with Android
, with an application
simple enough for you to get the basic ideas, yet no
simple as an “hello World” app.

We will
demonstrate touch, file access,
and basic graphics/text layouts.

As usual, we try to make things
fun, so you’ll be implementing a game, a variation

on the classic battleship game, meant for a single

We expect this app to run on
Android, (either in tablet or on a phone)
Running in a simulator is just
fine, however, since this app does not require any orientation/motion events.




game is a board of n
n (n is configurable by
the user, but you can start off by setting it
to 10). In this board, somewhere, hides a fleet of battleships. The fleet size, too, is configurable, but
for a start you can use:


One Frigate: This is a ship occupying 4x1 squares of the board


Two Destroyers:
Each is a ship occupying 3x1 squares of the board


Three Cruise Ships: Each is a ship occupying 2x1 squares of the board


Four Battle Yacht: Each is a ship occupying 1x1 (that is, exactly a single) square of the board

What is guaranteed:


Ships run either hor
izontally or vertically. Not diagonically


Ships cannot touch each other. This means that a 1x1, for example, effectively occupies 3x3,
because it must be surrounded by water. That said, water may overlap.


Each row and each column has a number at its end, s
pecifying how many squares are
occupied by ships. This, of course, may be “0” (if no ships occupy) or even greater than 4 (if
two or more ships occupy the same row).

A working demo of the game can actually be found online

play it a bit, it’s kinda fun
Another good site is:
. The conceptis site also
enables you to login and get loads more puzzle setups, so you might want to try that.

Game play:

The player is presented with the game board, s
imilar to the HTML version. The board is a matrix,
with the numbers at each row and column. The ships are hidden, but a number of squares (1
4, again
varying with difficulty) may be revealed to the player. If revealed, they may be:

Open water

Whole ship (i
f the player is lucky and the square is occupied by a 1x1)

Corner (if the player is lucky and the square happens to be the corner of a 2x1,3x1 or 4x1).
Revealing a corner also reveals the direction of a ship.

Part of a ship (if the player isn’t that lucky,

and this is a 3x1 or 4x1). The direction (horizontal
or vertical) isn’t revealed.

A timer is started.
The player may touch any unrevealed square on the game board to populate it with
either water (first click), or part of a ship (second click) or clear it

(third click). Note that a pre
square CANNOT be cleared in this manner

(i.e. you will have to ignore the event)

The user can also click
and drag

dragging populates the adjacent squares (those dragged over) with whatever the first square

to the drag) was set to.

If the player populates too many ships in a row or column wherein the number of ship squares is less, he
is obviously wrong, and the corresponding row or column number (specifying the correct count of ship
squares) must be turned
to red/bold.

When the player has populated
all ships



that’s ships, not water

having to fill all the
water tiles is frustrating, as there’s more water than ships)
, the game ends, the timer is stopped, and the
fastest time makes for the
high score. Play a victory sound.


What you DO NOT need to do:

(but may get a bonus for)


and populate
the board randomly. The algorithm of how many squares need to be
revealed for a unique solution is deemed out of scope (basically, it requi
res randomizing a
board, then attempting to solve it, and placing the “hint” squares in point where the
solution deviates and is no longer unique). Instead, you can copy board designs from the
above URL (they have 10x10, 8x8 and 6x6

note the fleet size c
hanges accordingly. Make
sure that you copy at least two (2) board designs for each of the board sizes. Read: overall
six boards, please.


Make the board uber
fancy. Standard bitmaps will be just fine

and you’ll need four (water,
corner, part
ship, wh
ole ship).


What you DO need to do:

3.1 I
mplement three screens:


The game board

Consisting of the board, an icon to erase all user filled tiles, and resign.


The settings panel

Allowing to choose board size

(6x6, 8x8 or 10x10)

Toggle s
ound on/off


high score chart

Requirement is only for the top score (i.e fastest time) for each board config.

3.1.4 Startup image

(a.k.a splash screen)

Nuff said.

Board #




Game board loading

You don’t have to randomize board generation, but
we do expect you to be able to load
boards from a local file. This means your board file should adhere to a format we can


(comments added for clarity)

You can put the file anywhere you want. Just let us know where it is.




Play a victory sound snippet. Your choice of wav or mp3.

Also play a sinking sound if the
player resigns

Board 1 /* numbers should be 1,2,3,… */

10 ††† ††I*‱0砱0⁢o慲a‪I

4:1ⰱ,1,4† I*⁨ 物ron瑡氠W砱‪I

3:6ⰱ,6,3†I⨠ho物ron瑡W″砱 ⨯

3:8ⰳ,8,5† †I⨠ho物ron瑡W″x1‪I

2:1ⰶ,1,7† I*⁨ 物ron瑡氠W砱⨯

2:3ⰹ,4,9†  ⨠v敲瑩捡e′ 砱 ⨯†

2: 3ⰱⰴ,1††I⨠v敲瑩捡氠c砱 ⨯

… /* Put the last four somewhere */



Divide and conquer:
Start off with the game board, because that’s most important. Start
with an in memory game board (i.e. one that is

hard coded, rather than loaded from a file).
Even though loading from files is straightforward, unit test and make sure that your game
board logic works,

before moving to other boards.

Don’t procrastinate!
We’re giving you
three weeks(!)

for this. You sho
uld be able to fix the
basic framework

of the project in a week , maybe two.


Extra credit


Save the l
ist of top three fastest times, using
a high score file or


SQLite (which
we will demonstrate
in an upcoming lecture

for which the slides w
ill be provided sooner


Background music: Play some song, but leave another icon on the board to toggle music
on/off in case it gets annoying for the player.

You will need to do that with a background


Responding to tilting of device by providi
ng the inventory of ships when in landscape mode,
next to the board. If you’re doing that, might as well do it properly, and grey
out any ships
which the user has already positioned in full (or thinks she has).


Impress us:

By randomly generating

both boar
d and ship
s, for sizes up to 15x15 (which allows a
larger fleet). Note this has nothing to do with mobile programming, per se, as it only
affects the model, and neither view nor controller. Still, if you have extra time, you
might actually make a worthwhil
e app out of it

ALSO submitting this as an HTML5 app, packaged natively
. IF you decide to do this,
you get an automatic one week extension for the HTML5 part only, which you
should submit separately. The deadline for the native part will not be extended

this way.