ocamllabs / 2048-tutorial

OCaml tutorial based on the 2048 game
49 stars 12 forks source link

insert_random_square #15

Closed yallop closed 10 years ago

yallop commented 10 years ago

Rather inelegant implementation of

val insert_random_square : square -> board -> board option
(** [insert_random_square square board] is [board] with [square] inserted
    in a randomly-chosen empty spot or [None] if there was no such spot. *)

I've left insert_square in, in case it's useful to have something more deterministic for testing.

Let's leave the implementation of insert_random_square as a gameplay-enhancing extension exercise in the tutorial.

dbuenzli commented 10 years ago

Could you please intergrate it in the G2038.{new_board,game_move} functions ? That's the only function I'm really using for driving the logic.

yallop commented 10 years ago

See 7f7b6bf (untested).