Qbasicnews.com February 18, 2020, 06:16:12 PM  Pages: 1  3 Author Topic: Greater & Less Than  (Read 8614 times)
na_th_an
*/-\*     Posts: 8244   « Reply #15 on: April 24, 2006, 06:17:16 PM »

This is a shuffling problem.

Steps:

1.- Create an array with 52 indexes, one for each value.
2.- Assign each value to its array index, so the array will be A(X) = X.
3.- Do a loop iterating a number of times, i.e. 26 times. The more times, the more "shuffled".
4.- Each loop just swap two array elements selected at random:

X = INT(RND*52)+1
Y = INT(RND*52)+1
AUX = A(Y)
A(Y) = A(X)
A(X) = AUX

(or use SWAP A(X), A(Y) which is a BASIC command, look for it in the help). Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
redcrab
New Member

Posts: 1   « Reply #16 on: April 24, 2006, 06:56:46 PM »

I think I got it ! .... I guess ... DOH ! this is same as Stylin... but i get something different for the card chooser... I take the given example
17,40,12,28,48 then 12 is maxi and 40 is mini then :

The tip is to search for min and max of ((value-1) mod 13)
EDIT : Stylin already found it ... :oops:

Code:
dim slot(5) as integer
' example choosen
slot(1) =17 : slot(2)= 40 : slot(3) = 12 : slot(4) = 28 : slot(5) = 48

' or  to choose 5 DIFFERENTS number (between 1-52)
' here is a special  quick shuffle algo
min = 0 : for i = 5 to 1 step -1 : min = int(rnd*(52-min+1)/i)+min+1 : slot(i) = min : next

' then search min max thanks to the given logic
minvalue = 100 : maxvalue = 0 : foundmin = 100 : foundmax = 0
for i = 1 to 5
v = (slot(i)-1) mod 13
if v < minvalue then
minvalue = v : foundmin = slot(i)
end if
if v > maxvalue  then
maxvalue = v : foundmax = slot(i)
end if
next i
print "max = " ; foundmax,"min=";foundmin
end

not tested but should work ...

Have fun ! Logged

stylin
Ancient QBer    Posts: 445 « Reply #17 on: April 24, 2006, 09:28:10 PM »

Quote from: "The_Names_Gin"
I took a different route by using DIM commands,

but now I get a duplicate error

1 = 1
14 = 1
27 = 1
40 = 1

Your diagram has the numbers 1, 14, 27 and 40 having equal priority. If you want 1 < 14 < 27 < 40 then there's no sense in using your diagram at all. (just compare the numbers directly) Logged

stylin:
Anonymous
Guest « Reply #18 on: April 25, 2006, 12:07:05 AM »

the stoner knows what's going on... funny.

Code:
Function priority( num As Integer ) As Integer

Dim As Integer res
'' 13 elements in a group in a deck of cards.
res = ( num Mod 13 )
If res = 0 Then res = 13
priority = res

End Function

Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer

a = 20
b = 35
c = 1
d = 52

? a; "'s priority is:"; priority( a )
? b; "'s priority is:"; priority( b )
? c; "'s priority is:"; priority( c )
? d; "'s priority is:"; priority( d )

Sleep Logged
The_Names_Gin
New Member

Posts: 21 « Reply #19 on: April 25, 2006, 01:02:20 AM »

The code comes in two parts, the first part is finished, because of this it will be dismissed, skipping the second part with a GOTO command.

The second will transform into the example below

1 = 13, 14 = 13, 27 = 13, 40 = 13
2 = 1, 15 = 1, 28 = 1, 41 = 1
3 = 2, 16 = 2, 29 = 2, 42 = 2
4 = 3, 17 = 3, 30 = 3, 43 = 3
5 = 4, 18 = 4, 31 = 4, 44 = 4
6 = 5, 19 = 5, 32 = 5, 45 = 5
7 = 6, 20 = 6, 33 = 6, 46 = 6
8 = 7, 21 = 7, 34 = 7, 47 = 7
9 = 8, 22 = 8, 35 = 8, 48 = 8
10 = 9, 23 = 9 36 = 9, 49 = 9
11 = 10, 24 = 10, 37 = 10, 50 = 10
12 = 11, 25 = 11, 38 = 11, 51 = 11
13 = 12, 26 = 12, 39 = 12, 52 = 12

What I need now is to solve each four set number groups to equal the final numbers that are set so that I no longer have the duplicate error during RUN TIMES. Logged
Anonymous
Guest « Reply #20 on: April 25, 2006, 01:23:55 AM »

Code:
Sub deck_Initialize( c() As Integer )

Dim suits As Integer
Dim elements As Integer

Redim c( 1 To 52 )
For suits = 0 To 3

c( suits * 13 + 1 ) = 13

For elements = 1 To 12

c( suits * 13 + elements + 1 ) = elements

Next

Next

End Sub

Dim cards() As Integer
Dim i As Integer

deck_Initialize( cards() )

For i = 1 To 13

? i; ":"; cards( i ),
? i+13; ":"; cards( i + 13 ),
? i+26; ":"; cards( i + 26 ),
? i+39; ":"; cards( i + 39 )

Next

Sleep Logged
The_Names_Gin
New Member

Posts: 21 « Reply #21 on: April 26, 2006, 02:35:16 AM »

what is the correct way of doing this?

Code:

IF slot5% > slot1% AND slot5% > slot2% AND slot5% > slot3% AND slot5% > slot4% THEN
highexample\$ = held5\$

END IF Logged
Anonymous
Guest « Reply #22 on: April 26, 2006, 03:31:33 AM »

no idea. because that code has no context by itself. please post a full example of code. Logged
The_Names_Gin
New Member

Posts: 21 « Reply #23 on: April 26, 2006, 07:01:21 PM »

I prefer not to write the code here.

This new question is how can I write multiple operators to get the end result. Such as

slot1% = 10
slot2% = 7
slot3% = 5
slot4% = 4
slot5% = 1

This is where I'm having trouble with, writing the execution out.

IF slot1% > slot2% AND slot1% > slot3% AND slot1% > slot4% AND slot1% > slot5% THEN

...execute somthing

Am I writing it wrong, am I suppose to use buckets? or some comma's? If so where? Logged
stylin
Ancient QBer    Posts: 445 « Reply #24 on: April 26, 2006, 07:29:12 PM »

Quote from: "The_Names_Gin"
I prefer not to write the code here.

I prefer not to guess at what you have in mind.

Quote
Am I writing it wrong, am I suppose to use buckets? or some comma's? If so where?

It depends. Explain why you are doing what you are doing, what your needs are - efficiency, flexibility, etc. - and post your algorithm and we might be able to help you. The best solution to a problem is rarely able to surface in such a small section of code.

(you'll probably get better advice with more information; there is no best way to solve software problems) Logged

stylin:
Anonymous
Guest « Reply #25 on: April 27, 2006, 04:31:23 AM »

dude yeah. i'm sick oef people coming here and asking for us to help you, and acting like your code is something i've never seen. are you insulting me? are you saying your code is better than the code that i release for everyone to see??

you think i'm some robot who's designed to give you the answers? fuck that. you want something, you give something. the sooner you learn that, the sooner you stop looking like a fool.

and yeah, i've had a little to much to drink tonight, now you get a nice dose of reality. Logged
Z!re
*/-\*     Posts: 4599 « Reply #26 on: April 27, 2006, 08:01:08 AM »

Quote from: "cha0s"
dude yeah. i'm sick oef people coming here and asking for us to help you, and acting like your code is something i've never seen. are you insulting me? are you saying your code is better than the code that i release for everyone to see??

you think i'm some robot who's designed to give you the answers? fuck that. you want something, you give something. the sooner you learn that, the sooner you stop looking like a fool.

and yeah, i've had a little to much to drink tonight, now you get a nice dose of reality.
Yarr! I agree.. Logged
Deleter
Na_th_an     Posts: 1293   « Reply #27 on: April 27, 2006, 04:33:43 PM »

Unfortunately, the people who do that kind of thing are the same people who don't read a single post before posting, and ignore/insult anyone who tries to tell them anything other then the answer they want, even when the question they wrote sucks beyond belief. I'm not even sure if you made a sticked post called "READ THIS RIGHT FUCKING NOW IF YOU HAVENT BEFORE OR BE BANNED FOR FUCKING LIFE AND HAVE YOUR POSTS FUCKING DELETED" that they would read it.... :roll:

maybe we should put such a post on our forums  :laughing: Logged

Anonymous
Guest « Reply #28 on: April 27, 2006, 09:13:38 PM »

Quote from: "Z!re"
Yarr! I agree..

you only agree with me when i'm drunk and rowdy...  :mrgreen: Logged
Z!re
*/-\*     Posts: 4599 « Reply #29 on: April 27, 2006, 10:30:28 PM »

Quote from: "cha0s"
Quote from: "Z!re"
Yarr! I agree..

you only agree with me when i'm drunk and rowdy...  :mrgreen:
Ofcourse.. Logged
 Pages: 1  3