News for hackers. Stuff that matters.
Re:Tetris Written in Go by drivers99 on Tuesday May 26, 2015 @06:43PM (#9608167)
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 by airplane on Tuesday May 26, 2015 @07:12PM (#9608279)
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.
Re:Tetris Written in Go by simonlc on Tuesday May 26, 2015 @07:05PM (#9608252)
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 by jjinux on Tuesday May 26, 2015 @07:01PM (#9608235)
Thanks for the tip ;)
Re:Tetris Written in Go by jjinux on Tuesday May 26, 2015 @07:09PM (#9608265)
Oh, and pull requests are welcome ;)
Re:Tetris Written in Go by _lce0 on Tuesday May 26, 2015 @08:50PM (#9608606)
well, that actually is a great piece of information to be aware of, the whole in-game strategy changes!
Re:Tetris Written in Go by laumars on Tuesday May 26, 2015 @08:01PM (#9608460)
What were your thoughts on termbox?

I've used it for a couple of projects now but I can't really get on with it. It feels so easy and straightforward at first but I often keep hitting silly annoyances that slow down debugging time or even causes fatal exceptions of its own (eg resizing a window).

So I'd be interested to hear another developers experiences with termbox

Re:Tetris Written in Go by beefsack on Tuesday May 26, 2015 @08:18PM (#9608510)
I've built a few things on top of it now: a "rich" text editor, a layout system, and a client to my plain-text board gaming service. The two main things that have caused me trouble are:

* Inability to customise colours on systems that support it. * Weak support for wide characters as termbox works directly on "cells", but can work around it with application logic. * It's quite easy to cause fatals, especially when working directly on the underlying buffer. Need to be quite careful.

The fact that it's native and cross platform is fantastic though, I'm a little worried that early design decisions will make it hard to rectify some of the warts though without large backwards-incompatible changes.

Re:Tetris Written in Go by laumars on Wednesday May 27, 2015 @04:35AM (#9610066)
The fatals were my main gripe as well. And to make matters worse, the crash report would be unreadable because it would dump in ncurses mode (which would also break my command prompt too)
Re:Tetris Written in Go by jjinux on Tuesday May 26, 2015 @10:50PM (#9609048)
My uses were pretty simple, but I enjoyed it.
Re:Tetris Written in Go by cespare on Tuesday May 26, 2015 @07:09PM (#9608264)
This was also one of my very first projects when I started writing Go a few years ago.

https://github.com/cespare/go-tetris

Re:Tetris Written in Go by jjinux on Tuesday May 26, 2015 @10:51PM (#9609055)
Seriously? That's funny.
Re:Tetris Written in Go by supercoder on Tuesday May 26, 2015 @08:32PM (#9608562)
Be careful calling it Tetris, the company that holds the rights I think pretty consistently goes after people who violate it's trademark and copyright.
Re:Tetris Written in Go by doodpants on Tuesday May 26, 2015 @10:11PM (#9608928)
There's a Tetris clone for Macintosh called Quinn, and at one point its website read:

"Quinn is an implementation of a popular falling-blocks game which, according to the Tetris Company, must not be named here."

Re:Tetris Written in Go by simonlc on Tuesday May 26, 2015 @09:30PM (#9608778)
They typically wont bother with small projects like this afaik. I've had a semi popular one going for a while with no contact from The Tetris Company.
Re:Tetris Written in Go by rockshassa on Tuesday May 26, 2015 @07:43PM (#9608388)
I've never tried to write a game before, but that seemed to me to be a surprisingly small amount of code.
Re:Tetris Written in Go by jjinux on Tuesday May 26, 2015 @10:52PM (#9609058)
Thanks. There are a bunch of other easy games to port: http://www.javascripter.net/games/index.htm
Re:Tetris Written in Go by srameshc on Tuesday May 26, 2015 @06:32PM (#9608117)
jjinux had been a strong proponent of Python, but happy to see some Go love lately.
Re:Tetris Written in Go by jjinux on Tuesday May 26, 2015 @07:01PM (#9608236)
I'm a polyglot ;)