rummikub specification ingmar v.d. steen archiwum.wiz.pl

18
Rummikub specification Ingmar v.d. Steen archiwum.wiz .pl

Upload: lawrence-griffin

Post on 30-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Rummikub specification

Ingmar v.d. Steen

archiwum.wiz.pl

Page 2: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Rummi…what? (1/5)

• Each stone is numbered: {1…13}• Each stone has a colour: {black,red,blue,green}

• 104 stones: every stone has a twin

• 2 players• Every player starts with 14 stones on his board

Page 3: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Rummi…what? (2/5)

• Playboard: A collection of sequences and families of the stones

• Sequence:A collection >=3 of stones which have the same colour and are consecutive, e.g.: 6 7 8 9

• Family:A collection >=3 of stones which have different colours and have the same number, e.g.: 8 8 8

Page 4: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Rummi…what? (3/5)• GOAL OF GAME:

be the first with no stones left on your board by making combinations on the playboard by:

Adding:Add one or more stones from your board to the playboard,e.g.:

playboard = {{4 5 6}…}board = {7 8 10 1…}

playboard’ = {{4 5 6 7 8}…}board’ = {10 1…}

Page 5: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Rummi…what? (4/5)• GOAL OF GAME:

be the first with no stones left on your board by making combinations on the playboard by:

Combining:Remove some stones of the playboard and combine these with stones you are going to add, e.g.:

playboard = {{8 9 10},…} board = {11 8 8 13}

playboard’ = {{9 10 11},{8 8 8}}board’ = {13}

Page 6: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Rummi…what? (5/5)

• If we cannot add or combine:

Pick a new stone from the collection of stones that is not on the two boards or on the playboard.

Subsequently, the player loses his turn.

Page 7: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Types• NumberNumber == { x : N | 0 < x < 14 }

• ColourColour == {black, red, green, blue}

• StonesStones == Number X Colour

• All_StonesAll_Stones == Stones U Stones

• TurnTurn ::= Alice | Bob

• Every stone has an unique STONE_ID and every sequence/family in the playfield a FIELD_ID

SelectionsSelections == STONE_ID X FIELD_ID

Page 8: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Sequence schema

• Sequenceseq : P All_Stones

#seq >= 3

same colour:same colour: s1,s2 seq : get_Colour s1 = get_Colour s2

consecutive:consecutive:

#seq – 1 =

get_Max_Number seq – get_Min_Number seq

Page 9: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Family schema

• Familyfam : P All_Stones

#fam >= 3

same number:same number: s1,s2 fam : get_Number s1 = get_Number s2

different colour:different colour:

s1,s2 fam : get_Colour s1 = get_Colour s2 s1 = s2

Page 10: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Game schema • RummiGame

boardAlice : P All_StonesboardBob : P All_Stonespot : P All_StonesplayField : FIELD_ID P All_Stones currentPlayer : Turn

During the game, the playField can only consists of During the game, the playField can only consists of sequences and/or families:sequences and/or families:

i : FIELD_ID : #(playField i) > 0

s: Sequence : s.seq = playField i \/ f: Family : f.fam = playField i

Page 11: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Init Game schema

• InitRummiGameRummiGame’turn? : Turn

currentPlayer’ = turn?# boardAlice’ = 14 # boardBob’ = 14# pot ‘ = 76

ID_Stones boardAlice’ ∩ ID_Stones boardBob’ ∩ ID_Stones pot’ ∩ = empty set

Page 12: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Alice-adds schema (1/2)• AliceAdds

delta RummiGameaddSelection? : P Selections

stones to be added on the playField should be present on your board:stones to be added on the playField should be present on your board:

s : addSelection : (get_STONE_ID s) (ID_Stones boardAlice)

no empty addSelection:no empty addSelection:#addSelection > 0

switch players:switch players:currentPlayer = AlicecurrentPlayer’ = Bob

remove the selected stones from boardAlice:boardAlice’ = boardAlice \ {ID_Stone s | (s,_) addSelection}

Page 13: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Alice-adds schema (2/2)• Add the selected stones to playField:Add the selected stones to playField:

playField’ = playField (+) union_Mapping { f |-> (playField f) U {ID_Stone s} | (s,f) addSelection }

• union_Mapping details:

E.g. addSelection = {(id10(1) ,id1),(id11(5),id1)}

playField: {id1 -> {2 3 4},...}

{ id1 -> {1 2 3 4},…,id1 -> {2 3 4 5} }

after union_Mapping it should become: { id1 -> {1,2,3,4,5} , …}

Page 14: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Alice-combines schema (1/3)

• AliceCombinesdelta RummiGameremoveSelection? : P Selections

(stones to be removed of the playField should be present in the stones to be removed of the playField should be present in the playField:playField:

s : removeSelection : i : FIELD_ID : (ID_Stone s (playField i))

/\

no empty removeSelection:#removeSelection > 0

Page 15: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Alice-combines schema (2/3)

• /\remove the selected stones from playField:remove the selected stones from playField:playField’ = playField (+)intersection_Mapping { f -> (playField f) \ {ID_STONE s} | (s,f) removeSelection }

/\add the selected stones to boardAlice:add the selected stones to boardAlice:boardAlice’ = boardAlice U {ID_Stone s | (s,_) removeSelection}

)

Page 16: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Alice-combines schema (3/3)

• Removed pieced should instantly be added again to the playField Removed pieced should instantly be added again to the playField and not only adding what we removed:and not only adding what we removed:

a : AliceAddsStones : {get_STONE_ID s | (s,_) <- removeSelection}

{get_STONE_ID s | (s,_) <- a.addSelection}

Page 17: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Alice-takes schema

• AliceTakesStonedelta RummiGameaddSelection? : STONE_ID

We only take stones from the pot:We only take stones from the pot:(ID_Stone addSelection) pot Remove a stone from the pot:Remove a stone from the pot:pot’ = pot / {ID_Stone addSelection}

Put it on the board of Alice:Put it on the board of Alice:boardAlice’ = boardAlice U {ID_Stone addSelection}

Page 18: Rummikub specification Ingmar v.d. Steen archiwum.wiz.pl

Aiding functions• ID_Stone :: STONE_ID ID_Stone :: STONE_ID All_Stones All_Stones

Every stone has an unique identity

ID_Stones :: P All_Stones ID_Stones :: P All_Stones [ID] [ID]Given a subset of stones we yield all the IDs.

get_Colour :: All_Stones get_Colour :: All_Stones Colour ColourFor all s1 : Number, s2 : Colour : get_Colour (s1,s2) = s2 get_Number :: All_Stones get_Number :: All_Stones Number NumberFor all s1 : Number, s2 : Colour : get_Number (s1,s2) = s1

get_STONE_ID :: Selections get_STONE_ID :: Selections STONE_ID STONE_IDFor all s1 : STONE_ID, s2 : FIELD_ID : get_STONE_ID(s1,s2) = s1

get_Max_Number :: P All_Stones get_Max_Number :: P All_Stones Number NumberFor all x,y : y = get_Max_Number x iff y = max {get_Number (c1,c2) | (c1,c2)<-- x}

get_Min_Number :: P All_Stones get_Min_Number :: P All_Stones Number Numberby analogy