dragongem (beta)

Show off your games, demos and other (playable) creations.
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

Re: dragongem (beta)

Post by farvardin »

I'd like 2 clients to connect together though internet or local network. When someone click on a client, it will display the result on the other as well, and the game could be turn based.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: dragongem (beta)

Post by bartbes »

So basically:
-Player chooses a gem
-The game at the player's side calculates the points and if he can continue
-Above results are sent to other player

This should be possible, only thing you might need to think about is who the server is.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: dragongem (beta)

Post by osuf oboys »

What does this parenthesis mean: "your opponent get 2 points (but can't win even if the score is 16)".

I think it should be possible to turn the computer player to act automatically instead of having to click each time. Adding an animation would be neat, i.e. you choose one of the gems, the bag moves up and a gem falls out. If it was right, you hear one sound and otherwise another.

Average score per gem.

Code: Select all

r = 3/4 * (1 + r) => r = 3
y = 2/4 * (2 + y) => y = 2
g = 1/4 * (5 + g) => g = 5 / 3
p = 1/4 * (12 + p) - 3 / 4 * 2 = 2.5
I computed using value iteration the optimal strategy for this game and it turns out that the yellow and green gems are worthless. More specifically, there are only 43 out of the 256 situations in which the purple gem is best and no situations in which the yellow and green should be used. If everyone plays perfectly, then red is chosen a total of 17.6 times per game and purple 1.9. The table below shows the optimal choice given that you are to act, you have "y" number of points left to win, and your opponent has "x" number of points left to left. In particular, the lower right corner is the starting situation.

Optimal strategy:

Code: Select all

 1 r r r r r r r r r r r r r r r r
 2 r r r r r r r r r r r r r r r r
 3 r r r r r r r r r r r r r r r r
 4 r r r r r r r r r r r r r r r r
 5 r r r r r r r r r r r r r r r r
 6 r r r r r r r r r r r r r r r r
 7 p r r r r r r r r r r r r r r r
 8 p p r r r r r r r r r r r r r r
 9 p p p p r r r r r r r r r r r r
 10 p p p p p p r r r r r p r r r r
 11 p p p p p p p p r r r p p r r r
 12 p p p p p p p p p p p p p r r r
 13 r r r r p p r r r r r r r r r r
 14 r r r r r r r r r r r r r p p r
 15 r r r r r r r r r r r r r r r r
 16 r r r p p r r r r r r r r r r r
I modified the values slightly to get a more uniform distribution: yellow gives 3 points and green 9. In this scenario, red is best for 121 situations, yellow for 62, green 63, and purple 10. If both players play optimally, then the expected number of times red is played per game is 3.3, yellow 4.4, green 4.0, and purple 0.5, and the first player has a 54% chance of winning. Against someone playing randomly, red is used on average 4.0 times, yellow 3.0, green 3.5, and purple 1.5. The chance for the first player to win against someone playing randomly is 62% and against someone always playing red 59%.

In short, one can summarize the optimal strategy of the modified version as:
1. Purple if you need 12 points to win and your opponent needs 1,2,3,4,9, or 10. If you need 11 and your opponent 1, 3, or 9. If you need 10 and your opponent 1.
2. Red if you need 1, 2, 4, 5, 13, 14, or 16 points to win.
3. Yellow if you need 3, 6, 7, or 15 points to win.
4. Green if you need 8 to 12 points to win.

Optimal strategy for modified rules:

Code: Select all

 1 r r r r r r r r r r r r r r r r
 2 r r r r r r r r r r r r r r r r
 3 y y y y y y y y y y y y y y y r
 4 y r y y r r r r r r r r r r r r
 5 y r r r r r r r r r r r r r r r
 6 y y y y y y y y y y y y y y r r
 7 g g g g y y y r r y y r r r r r
 8 g g g g g g g g g g g g y y y y
 9 g g g g g g g g g g g g g g g y
 10 p g g r r g r r g r g g g g g g
 11 p g p g g g r g p g g g g g g g
 12 p p p p g g g g p p g g g g g g
 13 r r r r r r r r r r r r r r r r
 14 r r r r r r r r r r r r r r r r
 15 y y y y y y y y y y y y y y y y
 16 y y r r r r r r r r y r r r r r
Winning chance for modified rules (%, +/- 1):

Code: Select all

 1 80 84 86 89 91 92 92 92 92 94 94 94 94 94 95 96 96 97 98
 2 64 70 73 78 82 84 85 85 85 88 89 89 89 89 91 93 93 95 96
 3 57 63 67 71 76 78 80 80 80 83 85 85 85 85 87 89 90 92 93
 4 46 53 57 63 68 71 74 74 74 77 80 81 81 81 83 85 87 89 90
 5 37 44 49 55 61 64 68 68 68 72 75 76 76 76 79 82 84 86 88
 6 33 40 44 50 56 59 63 64 64 68 71 73 73 73 76 78 80 83 85
 7 31 36 40 45 50 54 58 59 59 63 67 69 69 69 72 75 77 80 82
 8 31 36 40 45 49 52 56 57 57 60 63 66 66 66 69 72 74 77 79
 9 31 36 40 45 49 52 56 57 57 60 63 64 64 64 67 69 71 74 76
 10 25 30 34 39 44 47 51 53 53 56 59 60 61 62 63 66 68 71 73
 11 25 26 30 34 39 42 47 49 50 53 56 57 58 60 61 64 66 69 71
 12 25 25 30 33 37 40 44 46 49 51 53 55 57 59 59 61 64 66 69
 13 25 25 30 33 36 40 43 45 48 51 52 55 56 57 58 59 62 64 66
 14 25 25 30 33 36 40 43 45 48 51 52 54 55 56 57 58 59 62 64
 15 20 21 25 29 32 36 39 42 45 47 49 51 53 54 55 56 58 60 62
 16 16 18 22 25 29 32 35 38 41 44 46 48 50 51 53 55 56 58 60
 17 14 16 20 23 26 30 33 36 39 41 43 45 47 49 51 53 54 56 58
 18 11 13 17 20 23 27 30 33 36 38 40 42 44 46 48 50 52 54 56
 19 09 11 14 18 21 24 27 30 33 35 37 40 42 44 46 48 50 52 54
By changing the number of points necessary to 19 and the value of purple to 14, then the distribution becomes fairly even: red in 136 situations, yellow in 78, green in 79, and purple in 68. For optimal play: 6.2 uses of red, 1.3 of yellow, 1.8 of green, and 2.7 of purple. Winning chance against a random strategy: 60%.

Another version: 5 jewels, red (80% / 1p), blue (80% / 2p, opp. gets 6 if you fail), yellow (60% / 3p), green (40% / 7p), and purple (40% / 8p, opp. gets 1 if you fail). Now red is used in 58 situations, blue 26, yellow 72, green 58, and purple 34 (green is however dominant for two optimal players). The benefit of this version is that the winning chance against any one-color strategy is at least 61% and against random 63%.

Some other ways to make the optimal strategy more complicated and dominating.

You could make it so that there's a known number of each gem in the bag and which are not replaced when drawn. When a gem is displayed from the bag, it remains on the game board, visible to the player. When one of each gem has been placed on the game board, then all gems are shuffled back into the game and something happens (e.g. the player who drew it loses some points, or gets thrice the reward for that particular round).

Alternatively, if your guess is wrong, the gem goes into the bag, although then there should probably be counters for the players.

The gems could remain on your side and affect the game (either those played, or those hit). For instance: every yellow gem increases the score of every hit besides red by 1, purple destroys a random of your opponent's gems, etc.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
farvardin
Party member
Posts: 167
Joined: Sat Jun 28, 2008 6:46 pm

Re: dragongem (beta)

Post by farvardin »

What does this parenthesis mean: "your opponent get 2 points (but can't win even if the score is 16)".
I'm afraid it's just a mistake. Read: your opponent gets up to 2 points (but can't reach 16 this way).

Thank you for the cool study on statistics. I could feel the green gem was just a big fraud, and the yellow one didn't look very advantageous either, but it's great you explained all this.

Remember the rules where copied from a DOS game, it has probably some flaws to help the player winning.

I'll make an improved version with options to include your suggestions.
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: dragongem (beta)

Post by osuf oboys »

farvardin wrote:
What does this parenthesis mean: "your opponent get 2 points (but can't win even if the score is 16)".
I'm afraid it's just a mistake. Read: your opponent gets up to 2 points (but can't reach 16 this way).

Thank you for the cool study on statistics. I could feel the green gem was just a big fraud, and the yellow one didn't look very advantageous either, but it's great you explained all this.

Remember the rules where copied from a DOS game, it has probably some flaws to help the player winning.

I'll make an improved version with options to include your suggestions.
Okay, that makes purple slightly better.

I have attached the program I used for testing strategies in case you are interested. You need to change the file extension from .txt to .rb (.rb files not allowed?) and have Ruby installed to run it (http://www.ruby-lang.org/en/). It's fairly simple, just edit the line "CHOICES = [...]" and run it.
Attachments
dragongem2.txt
dragongem2.rb
(3.12 KiB) Downloaded 143 times
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests