Live data from Hacker News

Tetris Written in Go

jjinux.com

1–10 of 20 posts

Re: Tetris Written in Go

#3
The first thing I did when I learned python was to write a tetris game in it (using PyGame). So the first thing I did was look at the random piece generator in the go version. It just picks one at random:

    g.piece = 1 + rand.Int()%numTypes
However, the official tetris guidelines say that the 7 types of pieces should all be selected in a random order, as if taken from a bag. After all 7 pieces are picked, you can put all of the pieces back in the bag and select again in a random order. [1]

Of course, you don't HAVE to follow the official guidelines. I just thought it would be fun to compare.

[1] http://tetris.wikia.com/wiki/Random_Generator

Re: Tetris Written in Go

#4

The first thing I did when I learned python was to write a tetris game in it (using PyGame). So the first thing I did was look at the random piece generator in the go version. It just picks one at random: g.piece = 1 + rand.Int()%numTypes However, the official tetris guidelines say that the 7 types of pieces should all be selected in a random order, as if taken from a bag. After all 7 pieces are picked, you can put a…

Thanks for the tip ;)

Re: Tetris Written in Go

#6

The first thing I did when I learned python was to write a tetris game in it (using PyGame). So the first thing I did was look at the random piece generator in the go version. It just picks one at random: g.piece = 1 + rand.Int()%numTypes However, the official tetris guidelines say that the 7 types of pieces should all be selected in a random order, as if taken from a bag. After all 7 pieces are picked, you can put a…

I did the same thing, implementing all the guideline rules into my JS version of tetris here: http://simon.lc/tetr.js/

However over the years, even after the guideline was instituted, there have been many different types of randomizers used. Of course, the original having none, and many a long the way having bugs.

Re: Tetris Written in Go

#8

The first thing I did when I learned python was to write a tetris game in it (using PyGame). So the first thing I did was look at the random piece generator in the go version. It just picks one at random: g.piece = 1 + rand.Int()%numTypes However, the official tetris guidelines say that the 7 types of pieces should all be selected in a random order, as if taken from a bag. After all 7 pieces are picked, you can put a…

Oh, and pull requests are welcome ;)

Re: Tetris Written in Go

#9

The first thing I did when I learned python was to write a tetris game in it (using PyGame). So the first thing I did was look at the random piece generator in the go version. It just picks one at random: g.piece = 1 + rand.Int()%numTypes However, the official tetris guidelines say that the 7 types of pieces should all be selected in a random order, as if taken from a bag. After all 7 pieces are picked, you can put a…

Never knew this, but now that I think about it, I don't think I ever ran into a situation where I got 3 of the same pieces in a row in any Tetris game. Makes sense.
Post reply on HN