Tuesday, May 6, 2008

Tetris [C++/OpenGL/Cross-platform]


I stayed up literally all night doing this, starting at 6pm last night and going to sleep at 8am this morning only to wake back up again at 10am to go to class.

I have pre-compiled binaries for a variety of systems, most likely yours, but source is provided of course if you want to compile it yourself.

One small note on windows compilation, apparently there is not a cross platform way to sleep, in linux I used my own Sleep() function with a wait time of 50000, in windows simply include windows.h, comment out my sleep function, and change the wait time to 50. This only affects the animation when a row is dropped. If someone knows a better way to sleep, please let me know.

I am on campus right now, so I can only provide a win32 screenshot



win32: http://www.moparisthebest.com/projects/tetriswin32.exe
linux32: http://www.moparisthebest.com/projects/tetrislnx32
linux64: http://www.moparisthebest.com/projects/tetrislnx64

project with project description and make file:
http://www.moparisthebest.com/projects/tetris.tar.gz

only the source (.h and .cpp) files:
http://www.moparisthebest.com/projects/tetrissrc.zip

Have fun, and try to leave some feedback.

OpenAIM

http://dev.aol.com/aim/

I thought this is a really good move for AIM, neat I say. And just when I was thinking about making a bot to listen for aim messages on a dedicated server, now it'll be easy as hell.

[C++] Markov Chains Implementation

This is a 4th Order (I plan to make it N order when exams are over) implementation of markov chains. (think JMegaHAL) I wrote it as a semester project (last night, no sleep) for algorithms class. It can be used for a lot of cool things, I'd like to make an IRC bot out of it one day when I get time (haha). It is implemented as a class anyone can use in their own C++ programs, but a minimal driver is provided.

README:
Author: Travis Burtrum (moparisthebest)

I use no 3rd party libraries or system calls in this, only standard c++.
So if you have a c++ compiler (I use g++) then this should compile fine for you.

generic compiling:
./configure
make

compile using g++:
g++ markovchains.cpp -o markovchains

run as you would any app from the command line:
./markovchains

compile using mingw (for windows):
i586-mingw32msvc-g++ markovchains.cpp -o markovchains.exe

sample run (refer to test.txt for input):
./markovchains
commands:
'exit' exits the program
'load filename' loads all sentances in filename into the system (test.txt is provided)
any other input is loaded into the system, and a sentance is output based on the first word typed if possible
# load test.txt
name it charles barkely.
# my teachers name is john.
hello my name is bob.
# name
what is your name?
# name
my friends name is sam.
# name
my friends name is bob.
# name
hello my name is john.
# exit
Yes, it is licensed under the GPL.

Things that need done:
  • Implement saving/loading mechanism
  • Clean up code, try not to copy objects as much
  • Make it N order

If anyone could give me some feedback on my code it would be much appreciated, I am most interested in a better way to store the Quads in memory, the way I do it know requires a lot of extra memory because the Quads I use as keys are copied because I can't store them by pointer like I want since I need to look them up by value and not by memory location. I'm sure there is a better way to handle this somewhere, thanks much.

http://www.moparisthebest.com/downloads/markovchains.tar.gz