ARC
Well-known member
Not done yet, still have to add the suits to it, but you get the idea.
This is based off of a card trick I really enjoy, and it drives people crazy if you're good at it. takes a bit of practice to get it to look convincing though.
Anyways, you should test run it before actally looking at the code to see if you can figure it out.
**To the point, someone lemme know if this looks to be inefficiant in any way. Thanks!
(1 form, two buttons and 5 labels)
This is based off of a card trick I really enjoy, and it drives people crazy if you're good at it. takes a bit of practice to get it to look convincing though.
Anyways, you should test run it before actally looking at the code to see if you can figure it out.
**To the point, someone lemme know if this looks to be inefficiant in any way. Thanks!
(1 form, two buttons and 5 labels)
VB.NET:
Public Class Form1
Public x As Integer
Public y As Integer
Public a As Integer
Public b As Integer
Public c As Integer
Public XYDistance As Integer
Enum permutation
'list of all available permutations that
'values A, B, and C can exsist in --
'based on rank comparrisons between A, B
'and C.
LMH 'low/middle/high
LHM 'low/high/middle
MLH 'middle/low/high
MHL 'middle/high/low
HLM 'high/low/middle
HML 'high/middle/low
End Enum
Public Sub chooseY()
'Y is the first card to be chosen
Dim r As New Random
y = ((r.Next(1, 8) + r.Next(1, 8)) - 1)
End Sub
Public Sub chooseX()
'X is chosen secondly
Dim r As New Random
XYDistance = r.Next(1, 7)
If (y + XYDistance) > 13 Then
x = ((y + XYDistance) - 13)
Else
x = (y + XYDistance)
End If
End Sub
Public Sub chooseABC()
'chooses which permutation to use
'and then generates cards A B and
'C on the form.
Dim r As New Random
Select Case (XYDistance - 1)
Case permutation.LMH
a = r.Next(1, 12)
b = r.Next(a + 1, 13)
c = r.Next(b + 1, 14)
Case permutation.LHM
a = r.Next(1, 12)
b = r.Next(a + 2, 14)
c = r.Next(a + 1, b - 1)
Case permutation.MLH
a = r.Next(2, 13)
b = r.Next(1, a - 1)
c = r.Next(a + 1, 14)
Case permutation.MHL
a = r.Next(2, 13)
b = r.Next(a + 1, 14)
c = r.Next(1, a - 1)
Case permutation.HLM
a = r.Next(3, 14)
b = r.Next(1, a - 2)
c = r.Next(b + 1, a - 1)
Case permutation.HML
a = r.Next(3, 14)
b = r.Next(2, a - 1)
c = r.Next(1, b - 1)
End Select
End Sub
Public Sub ShowYABC()
'displays the numbers to their
'appropriate form labels.
Me.yLabel.Text = y.ToString
Me.aLabel.Text = a.ToString
Me.bLabel.Text = b.ToString
Me.cLabel.Text = c.ToString
End Sub
Public Sub ShowX()
'reveals the hidden X value
Me.xLabel.Text = x.ToString
End Sub
Private Sub showXButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles showXButton.Click
ShowX()
End Sub
Private Sub NewButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewButton.Click
'deals a new set of numbers, and hides the X value
chooseY()
chooseX()
chooseABC()
ShowYABC()
Me.xLabel.Text = "x"
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'I put the rules in a message box here, but it's too long for posting purposes.
'suffice it to say, 1-13 = Ace through King, and card suits arent relevent at this point.
End Sub
End Class