Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

879458 Posts in 32981 Topics- by 24367 Members - Latest Member: bastion_music

May 24, 2013, 06:17:18 AM
  Show Posts
Pages: [1] 2 3 ... 20
1  Community / Versus / Re: ARQA on: January 19, 2011, 01:11:47 PM
You can do this in-place in linear time, just find a random card that's not among the 'i' first cards, swap that with the i+1th card and don't touch it again.

I did a quick implementation in python, since it looks like pseudo-code. Most of the code is actually to generate the deck, but it's pretty sweet and should be clear.

This one actually shuffles a 52-card array, but the algorithm can be used to randomize any array regardless of type or size, in linear time. So just create your array with values 0-49, then shuffle it.

Code:
import random

class deck:
        def __init__(self):
                self.cards = []
                for i in range(14):
                        for j in ["Hearts", "Diamonds", "Clubs", "Spades"]:
                                if i == 0:
                                        token = 'A'
                                elif i == 11:
                                        token = 'J'
                                elif i == 12:
                                        token = 'Q'
                                elif i == 13:
                                        token = 'K'
                                else:
                                        token = str(i)

                                self.cards.append(token + " " + j)

        def shuffle(self):
                for i in range(len(self.cards)):
                        # swap a random card with the first card,
                        # and we have the first card figured out.
                        idx = random.randint(i, len(self.cards)-1) # random index between i and the last card
                        tmp = self.cards[idx]
                        self.cards[idx] = self.cards[i]
                        self.cards[i] = tmp
d = deck()
print(d.cards)

#shuffle deck
d.shuffle()
print(d.cards)

Relevant part (algorithm) for readability:

Code:
       def shuffle(self):
                for i in range(len(self.cards)):
                        # swap a random card with the first card,
                        # and we have the first card figured out.
                        idx = random.randint(i, len(self.cards)-1) # random index between i and the last card
                        tmp = self.cards[idx]
                        self.cards[idx] = self.cards[i]
                        self.cards[i] = tmp

Edit: I really wanna push this algorithm Embarrassed so here it is in C, if that helps, with 50 cards:
Code:
        int cards[50];
        size_t i;
        for(i = 0; i < 50; ++i)
                cards[i] = i;
        for(i = 50 - 1; i > 0; --i)
        {
                size_t idx = rand() % (i+1);
                int tmp = cards[i];
                cards[i] = cards[idx];
                cards[idx] = tmp;
        }
2  Community / Announcements / Re: The Obligatory Introduce Yourself Thread on: January 05, 2011, 01:42:38 AM
Hi! I'm a hobbist indie game developer from Ontario, Canada.

Now I'm looking for an indie game development community to join, and I think I just found one!

Nice arcade. We used to have a JAMMA arcade, an Egret II machine, here modded with Seimitsu sticks and Sanwa buttons. It was hell of fun, should've bought it before the guy who had it decided to sell it instead of storing it at my place. We used to play Espgaluda, one of my favourite shoot-'em-ups ever, with cookies as credits. So whenever you lost and played again (no continues!) you'd eat a cookie.

Was awesome and jolly good fun.

Welcome to the boards! Smiley
3  Developer / Art / Re: Mockups, or the "Please say this is going to be a game" thread on: January 04, 2011, 06:59:09 PM
I have never seen that movie so  Shrug

noob for not seeing Equilibrium  Lips Sealed
Embarrassed
No need to feel embarrassed, that movie sucked.

I disagree, the movie has very good points. But I guess I'm a sucker for dystopian movies.

Though, the ending was shit.
4  Developer / Art / Re: Art on: January 03, 2011, 01:11:04 AM
I just want to say that you all rock. Don't stop blowing my mind. Ever.



This is fucking awesome. I have a cropped version as wallpaper, and probably will for a while!
5  Developer / Art / Re: Art on: January 02, 2011, 07:21:41 PM
Tired of your shit dragon

is tired of your shit

I think tired-of-your-shit dragon should look more grumpy/fierce. But when I look at his left eye (my right side) he just feels tired (but not of anyone's shit). I can feel the fierceness in him when not looking at that left eye.
6  Developer / Art / Re: Mockups, or the "Please say this is going to be a game" thread on: December 22, 2010, 02:23:50 AM
a ninja game where you have to climb up the tower of babel to assassinate god.

Fuck yes.
7  Player / General / Videogame Music in Context on: December 13, 2010, 04:35:25 PM
Browsing around Kickstarter I found this really interesting project about video-game music that totally needs help funding. As I'm typing, with five days left, the project is about 70-75% funded. I couldn't find this previously covered. If this sounds too much like an ad, it's because I truly want to see this funded. So here we go.

The project, called Videogame Music in Context, is actually composed of three DVDs and an album release with both the soundtrack and a remix CD of the free indie game Hydorah. The first two DVDs are interviews; one with interviews with commercial Japanese video-game composers and one with independent game music composers. The final DVD is a Tour DVD with live performances with, among others, chip musician Nullsleep from their 2010 tour.

The commercial-game interview DVD features Nobuo Uematsu (Final Fantasy), Akira Yamaoka (Silent Hill) and many others as well. Some more famous than others. I really love the calm and philosophic style of these, judging from its trailer.

For the indie one I'm really excited about seeing Daisuke Amaya (Cave Story) on an interview. Not only for Cave Story, but he seems like a really nice person from the interview he did with Nicalis. Personally I'm particularly interested in seeing Shinji Hosoe as well, he did a really beautiful arrange version of a song from one of my favorite games ever, Espgaluda. There's a trailer for this one as well. For more composers, see the Kickstarter page.

I'm really excited about this and would be sad to see it not happen. I don't think something like this has been done with artists from Japan, and especially not to this extent. If you think this sounds as interesting as I do, please check out their Kickstarter page for more information. Pledge rewards include the physical Hydorah soundtrack release as well as all of these DVDs. I hope you'll decide to help them out as well!

Edit:

Interview with Hydorah composer Gryzor87 on IndieGames.
8  Developer / Art / Re: Mockups, or the "Please say this is going to be a game" thread on: October 24, 2010, 05:25:56 AM
Hope I'm not spamming this thread. Last edit, added more standard wall tiles and some highlights on the top tiles, I'm quite content... Thanks for the advice Relix! Still any CC?

I think the stone tiles look too cluttered, too much focus goes on the foreground/background decoration tiles, and not enough on the player panda. The contrast is too sharp so the whole image looks "busy" instead of what you want the player to focus on.
9  Developer / Creative / Re: So what are you working on? on: June 12, 2010, 10:22:41 AM
Work in progress of something looooooooong overdue for a fellow TIGer.



Ah you posted that! <3 Sorry I'm just reading up on my tigsources. I got it, it looks nice sitting in my window for now!
10  Community / Get Togethers / Re: TIGJam UK3! on: June 09, 2010, 12:30:33 AM
Thanks to everyone who attended, I had a great time! Smiley

I guess there wasn't enough of an introduction, at least for us who arrived late.. I think everyone should wear name/nick/company-tags so you can figure out who everyone is. It's also a good conversation starter: "Hey I played your 'game x', I love it!"

11  Community / Get Togethers / Re: Hostel accommodation for TIGJam UK3 on: June 03, 2010, 06:31:26 AM
That's fine, you two are now booked for just one night Sat-Sun.
Thanks a lot! Smiley
12  Community / Get Togethers / Re: Hostel accommodation for TIGJam UK3 on: May 27, 2010, 01:52:54 PM
Hey! We just ordered tickets, and we're gonna arrive saturday morning.

Could you call them and see if you could unbook us for friday-saturday? We're still interested in saturday-sunday.

We'll of course still pay you for that night if you can't unbook it, but it'd be nice if you could give it a try. Smiley
13  Community / Get Togethers / Re: TIGJam UK3! on: May 21, 2010, 04:30:45 PM
I think (dunno) we'll arrive past midnight, how long are you guys gonna stroll around? (:
14  Community / Get Togethers / Re: Hostel accommodation for TIGJam UK3 on: May 17, 2010, 03:11:37 PM
I think we're two nights, maybe three. I'm sending a mail and hopefully I'll get back to you soon. Sorry for the slow replies. We haven't booked flights yet and I'm not sure if he can get off work earlier than friday, or stay longer than sunday.. etc. <3
15  Community / Get Togethers / Re: TIGJam UK3! on: May 12, 2010, 09:47:59 AM
Does anyone know if Stansted or Gatwick is cooler? How much is transfer from there to Camb? We're trying to plan the trip. (:

Edit: And plan the trip = find cheapest travel path
Pages: [1] 2 3 ... 20
Theme orange-lt created by panic