Sep 25, 2008

Uno - C# Console

While learning how to code in C# (my first language), I recreated the game of Uno in console output. The game would progress though four human controlled characters, and had all the cards of a normal deck. The card shuffling system was most intriguing to create, but I probably had more fun explaining it to my class mates and teacher.

I had begun work on an soft AI for my application. Alas, like a poem, I abandoned the project for new ideas. The basis for the AI was an array equal to the number of cards in hand, each set to that number times two. It would then consider each card combination, and subtract one from both cards for each similarity the two cards shared (color and number).

After it had this array of varying numbers, it was to consider its opponents and how many cards they had in hand. It would multiply Draw 2's, skips, and reverses by a set amount if the next person to play had the fewest cards in hand. Two players away having the lowest cards in hand would reduce the value of skip cards.

Finally, any illegal moves were multiplied by 0. The highest value was chosen, or a random card in the case of a tie. On all zeros, a card draw was needed.

1 comment:

SFJ Business Solutions Training said...
This comment has been removed by a blog administrator.