Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Nick on December 26, 2012, 04:35:59 am

Title: [Lua] UNO (THE [card]game)
Post by: Nick on December 26, 2012, 04:35:59 am
Hi everyone

As you may have (or may not have) noticed I was gone for quite a while, about 6 months i guess. I came to visit now and then, but never actually reacted to something or made something new. But that's changed, 'cause I'm back in bussiness! I just had about enough of any calc related stuff for a while... but since I'm having exam stress right now, I needed something to relax, so I started a new program/game. You probably know it, it's the most famous/fun/hilarious/etc. cardgame existing, UNO!

I just started yesterday, but I suppose it's kinda finished, so I would ask you guys a favor to test it if you want. Any bugs/glitches/crashreporst may be posted here or in pm (thanks).
It's two version, a normal one and a small one. The images take up quite a lot of memory, so I made one with smaller images, and it runs slightly faster, but it's not as good looking as the normal one (the gameplay and code is exactly the same, just the images changed).

Here are some eye-candies:
(http://img.removedfromgame.com/imgs/scrn1.PNG) (http://img.removedfromgame.com/imgs/scrn2.PNG) (http://img.removedfromgame.com/imgs/scrn3.PNG)

the first one is from the normal version, the other ones are from the small version.

controls:
[r]eset
[.] move to next player (i did not let this go automatically because now you can follow what each player does --> you can think what cards are left)
[<][>] select card from own collection to lay down on pile
[enter] confirm card you want to lay down (there's a check to see if it is legit to lay that card, so no cheating should be possible)
[esc] another reset
[tab] take card from pack if you cannot lay down one that fits

edit: [enter] without any selection makes you skip, that is when you cannot lay any card that is legit.

also, the black bar indicates the player that is on the move.
And it has 3 AI's obviously, you are the one with the shown cards, the other ones pick their cards themselves.


Any questions, remarks, bugs, glitches may be posted :)

greetings,
Nick

P.S. it feels good to be back, i missed it :)

Found bugs/mistakes/glitches:
 - Number 0 as card not available
 - Ndless loop when only one Player (AI) left


It seems like some people have different rules than the standard ones, if so, note them, i'll try to add them to a settings dialog
 - 2 of exact the same cards can be laid down at the same time
 - If another player lays down a card, you can lay down exactly the same one if you have it (even if it's not your turn)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Hayleia on December 26, 2012, 04:39:31 am
Welcome back Nick, have some peanuts :P
Spoiler For peanuts:
!peanuts
Also, you come back with a great game here, congrats O.O
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 26, 2012, 04:56:39 am
Thanks for the peanuts Hayleia, i never really got one of those, but now i have :)

And thanks, it might look good, the code's dirty..but it works (I hope)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Lionel Debroux on December 26, 2012, 05:15:22 am
I've just posted a tip at http://tiplanet.org/forum/viewtopic.php?f=17&t=10982 , so as to reach the French-speaking community and bring you more testers :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 26, 2012, 05:18:17 am
Thanks for that Lionel, that might come in handy indeed.

Oh and btw, I know there's no start/end screen, but i'll look into that later, i just want to have the 'game-engine' done for now.
Title: Re: [Lua] UNO (THE [card]game)
Post by: TIfanx1999 on December 26, 2012, 05:48:18 am
Hey Nick, welcome back.  I don't have an Nspire to test, but it does look quite nice! :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Adriweb on December 26, 2012, 07:29:38 am
Wow, looks awesome :D

Will try very soon !
Title: Re: [Lua] UNO (THE [card]game)
Post by: ElementCoder on December 26, 2012, 01:42:49 pm
Nice work nick :) Will try this for sure.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 26, 2012, 03:41:57 pm
This is cool! Don't forget to add cards like the 4+ and color chosing :P
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 26, 2012, 03:47:22 pm
I added those, +4 looks like +4, +2 like +2, switch direction (or whatever you may call it) is §, change color is # and skip player is X
that way i could just use the ascii charset to display the cards (a lot easier and no special cards had to be made)
btw the right screenshot with the colors is when you lay down a colorchanger or a +4, so you can select the wanted color.

overview:
[1-9] standard
[§] switch direction
[# ] change color
[X] skip next player
[+4/+2] obvious
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 26, 2012, 03:53:47 pm
uno cards are 0-9 :P
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 26, 2012, 03:55:45 pm
darn, then i'll have to add the 0, i totally forgot about that one xp
and damned, that'll f*ck shit up.. i use the 0 as a not-legit card in my code, so that'll have to change :o
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 26, 2012, 03:57:07 pm
don't forget to make that when somebody lays +4 the next person can lay another +h or a +2 in the wished color and then the next person has to draw more cards etc :P
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 26, 2012, 03:59:22 pm
i read the rules, and these are the legit combinations:
+2 on every +2 and every card with same color
+4 on every card (including +4 and +2, color doesn't matter)

i check the last cards in the pile to see how many +4/+2's there are, and add as many cards as needed (or at leest it should do so)

what's +h ?
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 26, 2012, 04:02:04 pm
I meant +4, stupid typo >.>
And i thoguth the color of +2 matter for laying after a +4 O.O/me played it wrong all the years

And
Every card is in there twice, some special cards more awesome
And if you have one card twice you can lay both at the same time
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 02:15:27 am
Every card is in there twice, some special cards more awesome
And if you have one card twice you can lay both at the same time

is that a standard rule? or is that one you invented yourself? i didn't see such a thing in the manual, that's why i ask it (i could've read over it though)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Adriweb on December 27, 2012, 05:49:23 am
Every card is in there twice, some special cards more awesome
And if you have one card twice you can lay both at the same time

is that a standard rule? or is that one you invented yourself? i didn't see such a thing in the manual, that's why i ask it (i could've read over it though)

I've always played like that :P
So if it'snot written in the official rules it must be something going on among players quite widely :D
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 12:37:59 pm
Well, if it's not official, but widely used, then i should implement that too.
Right now there's only one card of each, so i must have read over that too, guess i'll have to reread the manual and take another look at my pack of cards :)

Thanks for the reaction so far.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Lionel Debroux on December 27, 2012, 12:40:13 pm
If there are some widespread deviations to the rules, then indeed, you should probably implement them, and make them disabled by default, but easily activable in a settings dialog :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 12:42:20 pm
yep, that's indeed the solution. I'll add that question to the first post.
If anyone has some more rules they want to see added, please tell me so!
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 27, 2012, 01:23:24 pm
Well, if it's not official, but widely used, then i should implement that too.
Right now there's only one card of each, so i must have read over that too, guess i'll have to reread the manual and take another look at my pack of cards :)

Thanks for the reaction so far.
I never read the manual :P
My parents explained it to me, without that rule, then I played with my cusins and they did that rule.
Some other rule that is wildley used but is impossible to implement is that if somebody else lies down a card and you have exactly the same one on your hand you can lay it down no matter if it is your turn, but you need to be quick enough before the next one lays his card.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 01:26:23 pm
Some other rule that is wildley used but is impossible to implement is that if somebody else lies down a card and you have exactly the same one on your hand you can lay it down no matter if it is your turn, but you need to be quick enough before the next one lays his card.

It's not impossible, it'd be just without the 'quick', since you tell the calc when the next player may lay down its card. I could add it, at least i think so :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: epic7 on December 27, 2012, 02:06:24 pm
Those are some tasty eye candies, nick!

And I'm not familiar with either of those rules, but what do I know, I haven't played this game in years :P
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 02:15:21 pm
Those are some tasty eye candies, nick!

And I'm not familiar with either of those rules, but what do I know, I haven't played this game in years :P

That seems to be a general problem, i guess it's not as popular as i supposed it was :) i played it a lot lately, that's why it came in mind.
And thanks for the compliment, but they should improve in short terms, because i plan to add the settings dialog anyway.
I also would like to change the color select dialog, which is rather dirty right now.
If anyone has an idea on how to make it more beautiful, please say so (sketch, drawing or just tell). Thanks!
Title: Re: [Lua] UNO (THE [card]game)
Post by: Chockosta on December 27, 2012, 02:44:35 pm
Wow, this games looks great !
Glad to see you back, by the way.

I've always played like Sorunome, too.
For the color select dialog, I would recommend displaying four empty cards, which represent each color...
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 02:47:41 pm
Wow, this games looks great !
actually, it's quit simple and the code's extremely dirty, i think i'll rewrite it from scratch when i have time.

Glad to see you back, by the way.
Thanks, i'm glad too :)

I've always played like Sorunome, too.
so that makes 3 out of 5, that a majority :)

For the color select dialog, I would recommend displaying four empty cards, which represent each color...

great idea, what if i display 4 colored cards as you say, and to show which one is selected, i draw the colorChange icon (#) or +4 on the selected one. That'll make sure you got the right card and color.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Chockosta on December 27, 2012, 02:50:11 pm
For the color select dialog, I would recommend displaying four empty cards, which represent each color...

great idea, what if i display 4 colored cards as you say, and to show which one is selected, i draw the colorChange icon (#) or +4 on the selected one. That'll make sure you got the right card and color.

This seems like a great idea :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 27, 2012, 05:18:05 pm
Maybe you could add options that toggle these extra rules.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 05:20:33 pm
Sorunome i think your own brain is f*cked by the brainf*cking brainf*ck intrepreters xp
j/k Lionel suggested that 10 posts ago :) i'll make a settings dialog to toggle all this stuff.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 27, 2012, 05:22:04 pm
activity is so high latley - it is almost impossible to read through dat many topics O.O
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 05:24:21 pm
activity is so high latley - it is almost impossible to read through dat many topics O.O
That's because I am back xp
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 27, 2012, 05:25:20 pm
activity is so high latley - it is almost impossible to read through dat many topics O.O
That's because I am back xp
not only that - it only took less than a day to get my reuben axe remake to more than one page of posts :crazy:
Title: Re: [Lua] UNO (THE [card]game)
Post by: lkj on December 27, 2012, 06:09:48 pm
Looking nice, although I was confused by the #, § and X because I read what they meant only after I had tested it :P

great idea, what if i display 4 colored cards as you say, and to show which one is selected, i draw the colorChange icon (#) or +4 on the selected one. That'll make sure you got the right card and color.
It would be more beautiful if you displayed the selected card bigger than the other ones, but that may take up too much space.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 06:13:04 pm
I will put that in the instructions in-game later. But was it too confusing, or was it still kinda self-explanatory?

and lua has image scaling, so it'd be easy to make the other ones smaller, that way i wouldn't have to add new image. Good idea :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 27, 2012, 06:14:56 pm
but is the image scaling still quick?
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 06:16:41 pm
yeah, decreasin the size is quite fast, increasing in something else.. most of it depends on the size of the image though, and these here are small enought to make it go fast enough so you won't really notice it.
Title: Re: [Lua] UNO (THE [card]game)
Post by: lkj on December 27, 2012, 06:24:43 pm
I will put that in the instructions in-game later. But was it too confusing, or was it still kinda self-explanatory?
I guess it would have been self-explanatory if I didn't know the original UNO cards or had known that you just display chars over the card sprites. But I assumed those cards were something new I didn't know yet. ;D
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 27, 2012, 06:38:48 pm
I will put that in the instructions in-game later. But was it too confusing, or was it still kinda self-explanatory?
I guess it would have been self-explanatory if I didn't know the original UNO cards or had known that you just display chars over the card sprites. But I assumed those cards were something new I didn't know yet. ;D

hmm, so that needs a change.. i'll think about it.
Did you run into any strange behaviour, bugs, glitches, points to improve?
Title: Re: [Lua] UNO (THE [card]game)
Post by: lkj on December 27, 2012, 07:49:23 pm
When you've won the game isn't finished, so you can let the AIs play on, and when only one of them is left, there seems to be some endless loop. The student software just stops to respond and I have to kill it in the taskmgr.

Nothing else, yet ;)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 28, 2012, 02:09:52 am
I knew about the end missing, i haven't made anything for that yet..
but i didn't know it crashed :o strange, thanks for noticing
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 28, 2012, 04:14:25 am
update.

i made the title screen, screenie below. Of course it is a lot more fluent irl, but because of the conversion from avi to gif it is very rough, bu still, enjoy!

(http://img.removedfromgame.com/imgs/clip0003_small.gif)

yesterday sorunome said it looks like it's made in the 90's. I actually based it on an image from the original uno card set, which is indeed from that time, but i kinda like it this way. Should I change it?

actually, it's based on this image:
(http://cdn.inthegame.nl/wp-content/uploads/2009/10/uno1.jpg)
Title: Re: [Lua] UNO (THE [card]game)
Post by: lkj on December 28, 2012, 11:57:22 am
Why don't you have to take a card from the stack if you can't lay down one? Is that really the official rules, because I've never played it that way?
Also I think the AI sometimes (or always?) doesn't take 4 cards when I lay down a 4+.

yesterday sorunome said it looks like it's made in the 90's. I actually based it on an image from the original uno card set, which is indeed from that time, but i kinda like it this way. Should I change it?
I like it the way it is :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 28, 2012, 12:00:40 pm
Why don't you have to take a card from the stack if you can't lay down one? Is that really the official rules, because I've never played it that way?
Because i simply forgot that.. you have to take one if you cannot lay one. Those are the bugs you don't see anymore arfter some hours of programming..

Also I think the AI sometimes (or always?) doesn't take 4 cards when I lay down a 4+.
certainly not always, but it seems rather random, which makes it more difficult. I looked into that, but i'll rewrite the checkpart, so that should be solved in the next version, thanks!
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on December 28, 2012, 02:53:31 pm
yesterday sorunome said it looks like it's made in the 90's. I actually based it on an image from the original uno card set, which is indeed from that time, but i kinda like it this way. Should I change it?
LOL, I'm good at guessing :P
IMO you should give it a more modern touch, thought :P
Title: Re: [Lua] UNO (THE [card]game)
Post by: Hot_Dog on December 28, 2012, 03:18:42 pm
I love UNO!  This is great!
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 28, 2012, 03:24:42 pm
IMO you should give it a more modern touch, thought :P
more something to this version then?
(http://a1341.phobos.apple.com/us/r1000/109/Purple/d9/ea/e8/mzl.nwxehuwl.320x480-75.jpg)

I love UNO!  This is great!
yay, finally one that still loves it :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 31, 2012, 05:37:38 am
Ok, i completely reworked the game, so i would like someone to test it for me.
I have tried to remove all the bugs, and it seems to be working well, but i did not add any setting yet, so none of the proposed rules is already implemented.

Thanks

edit: i did not add any color setting yet, but the picking of the +2 and +4 cards should work
Title: Re: [Lua] UNO (THE [card]game)
Post by: Adriweb on December 31, 2012, 07:51:01 am
Nice :D

Found some bugs :
- One random one at line 152 when I couldn't play but still press Enter on a card, and on the source code, the variable 'card' was nil. This also appeared when pressing enter during the card moving and it was supposed to be someone else's turn.
- Keep pressing enter (a number of times... :D) until it crashes : line 266 something is nil :   self.pack[#self.pack].isEvaluated = true
- line 348 somethign was nil for some reason when you press up or down right after starting a game :     if self.players[1].activeCard>#self.players[1].collection then
- Press [Esc] a number of times : nil value on line 303 :     local xDif = math.abs(self.movingCardPos[1]-self.defPos[1])

Other things :
- When in Full screen (I mean, computer view), the backgruond doesnt repeat in X.
- At some point (not sure how to reproduce), I couldn't [tab] to take a card?


Edit : all this was tested on TINCS 3.2
Title: Re: Re: [Lua] UNO (THE [card]game)
Post by: Nick on December 31, 2012, 08:23:25 am
I'll try to find the [enter] bugs asap, as I don't really know what causes it

For the [tab] key I know, now you just have to [enter] without any card selected, then you should get a new card.

And for the background is a simple explanation: laziness. I'll make it good when I have some time (not today anymore).

Also: 1000th post :)
Title: Re: [Lua] UNO (THE [card]game)
Post by: TheNlightenedOne on January 01, 2013, 04:50:48 pm
How does this look on classic Nspires? Are the colors hard to distinguish?
Title: Re: Re: [Lua] UNO (THE [card]game)
Post by: Nick on January 01, 2013, 04:55:34 pm
I actually never thought about that, i'll test it tomorrow, since o don't have my pc right now. I guess the only real problem might be the colors green and yellow, since they're quite the same..
Title: Re: [Lua] UNO (THE [card]game)
Post by: TheNlightenedOne on January 01, 2013, 04:58:25 pm
I can test it in a few minutes and report back. I'll edit my post with results.

EDIT: I can't tell if there's 3 or 4 colors distinguishable. I'd say it's not going to be easy to use on classics. :banghead: Oh well.
Title: Re: Re: [Lua] UNO (THE [card]game)
Post by: Nick on January 01, 2013, 05:04:17 pm
Thanks for that info. Did you test it on a real nspire or tincs? I'll have to find something to that, any ideas?
Title: Re: Re: Re: Re: [Lua] UNO (THE [card]game)
Post by: TheNlightenedOne on January 01, 2013, 10:40:45 pm
Thanks for that info. Did you test it on a real nspire or tincs? I'll have to find something to that, any ideas?
I tested it on a real Nspire.
Title: Re: [Lua] UNO (THE [card]game)
Post by: Sorunome on January 01, 2013, 10:58:47 pm
IMO you should give it a more modern touch, thought :P
more something to this version then?
Oh yeah, that's looking a lot better IMO! :D