Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Qwerkey

Pages: [1] 2 3 ... 8
1
Programs / Map Projections (of the Earth): Any Experts?
« on: January 02, 2022, 01:39:05 pm »
I am thinking of starting a project to display a revolving 3D transparent Earth globe.  To do this, I'll input a 2D map of the Earth and map that onto a sphere with _MAPTRIANGLE(3D) - I still am completely ignorant of _GL methods.

My starting problem is that I don't know which the many map projections to use to give the global Earth image the correct topology.

Would you be able to suggest what would be the most apposite project for this perceived method?  I'll probably start with Mercator if there is no guidance.

2
Programs / Maximum Consecutive Same Heads/Tails in Coin Toss
« on: November 24, 2021, 12:41:38 pm »
When I created my coin toss graphics program https://www.qb64.org/forum/index.php?topic=4117.msg134684#msg134684 as a check that it was working correctly, there must not have been many consecutive same heads or tails (the program did seem OK in this respect).

But I wondered if you let QB64 run continuously with a 50/50 random, what would the maximum same consecutive be.  [Theoretically (?) if you do 50/50 for an infinite time you'd get a sequence sometime of infinite consecutive same].

So this simple program examines this.

Code: QB64: [Select]
  1. CONST False = 0, True = NOT False
  2. Count& = 0
  3. Cycle& = 0
  4. SameCount% = 0
  5. MaxSame% = 0
  6. IF RND < 0.5 THEN
  7.     Heads%% = True
  8.     Heads%% = False
  9. OldHeads%% = Heads%%
  10.  
  11.     IF RND < 0.5 THEN
  12.         Heads%% = True
  13.     ELSE
  14.         Heads%% = False
  15.     END IF
  16.     IF Heads%% = OldHeads%% THEN
  17.         SameCount% = SameCount% + 1
  18.         IF SameCount% > MaxSame% THEN MaxSame% = SameCount%
  19.     ELSE
  20.         SameCount% = 0
  21.         'IF Heads%% THEN
  22.         '    OldHeads%% = False
  23.         'ELSE
  24.         '    OldHeads%% = True
  25.         'END IF
  26.         OldHeads%% = NOT OldHeads%%
  27.         'IF RND < 0.5 THEN
  28.         '    Heads%% = True
  29.         '    OldHeads%% = True
  30.         'ELSE
  31.         '    Heads%% = False
  32.         '    OldHeads%% = False
  33.         'END IF
  34.     END IF
  35.     Count& = Count& + 1
  36.     IF Count& / 10000000 = Count& \ 10000000 THEN
  37.         Count& = 0
  38.         PRINT MaxSame%
  39.         RANDOMIZE (TIMER)
  40.     END IF
  41.     Cycle& = Cycle& + 1
  42.     IF Cycle& > 2147483646 THEN END
  43. PRINT Cycle&
  44.  

The program runs freely and occasionally prints the maximum number of same consecutive "heads or tails".  On my laptop this number is 24, seemingly never exceeded.  The likelihood of getting 24 same consecutive heads or tails is low (~ 1 in 16 million, but the program is doing billions of cycles).  Occasionally, one might expect the maximum of 24 to be exceeded.

I think that I must be doing something stupid with the code.

3
QB64 Discussion / Call for Library Submissions
« on: August 18, 2021, 03:32:43 pm »
Dear Members,

If you have a Project (in Programs) which you would like to consider for submission into the Library (either Games or Samples and Utilities Gallery), then please contact me (@Qwerkey) or @Junior Librarian or @bplus at this site.  Alternatively, you may contact me at the QB64 Discord Server where any subsequent discussions about the submission will take place.  Similarly, if you have written a useful guide for methods in QB64, then submit this for the Articles section.

If you wish to recommend someone else's work which you have been impressed by then by all means contact us.

Thanks, Qwerkey (Richard)

This post will appear in Discussions at regular intervals so that a wide cross-section of the membership will be aware of this facility.

4
Programs / Coin Toss Graphics Program (_MAPTRIANGLE(3D) Demonstration)
« on: August 14, 2021, 06:03:34 am »
I wanted to create a program to demonstrate the wide applicability of the QB64 _MAPTRIANGLE procedure for creating impressive graphics applications.  _MAPTRIANGLE, most especially _MAPTRIANGLE(3D), is another amazing and supremely useful QB64 coding technique, and can be easily implemented by the novice coder.  I include myself very much within this group (not so much a QB64 novice as a low-skill member - most of the techniques of QB64 and virtually all of the discussions at this website are way above my understanding).

Whilst QB64 allows the creation of 'real' 3D graphics applications with the use of _GL methods (wonderfully demonstrated here by Ashish in particular), I do not have the faintest understanding of the technique - a survey of the _GL commands in wiki is just incomprehensible.  But I have used _MAPTRIANGLE(3D) in the past, and so could any of our members.

The idea of creating a Coin-tossing simulation seemed a good basis to demonstrate _MAPTRIANGLE(3D) abilities.  A search of the website suggests that this has not been attempted in the past, so this looked to be a good project with the goal of simulating a 50-50 Heads-Tails toss of a spinning coin.

To simulate a coin-tossing, the basic starting points were:

  • A thin cylindrical 'solid' body with two different faces.

    The body describes a 3D path where it moves under a constant downward gravitational acceleration.

    In travelling such a path, the body spins upon an axis through a fixed diagonal.

    Upon hitting a solid flat surface the coin settles to lay flat - which way it falls determined by the angle at which it hit that surface.

    A degree of randomness in the flight so that there is a 50-50 chance of falling on each face.

To give a good representation of a coin shape in 3D, the graphics image was constructed in the following manner.  Websites scanned for attractive images of the two faces of a coin in flat right-angle view.  The milled edge was created in code to give cyclic lighter-darker regions (which looks pretty realistic).

The flat faces are mapped into the _MAPTRIANGLE(3D) space by cutting the faces into radial triangular segments.  The coding to do this was reasonably simply and was achieved in pretty short time.  This is the beauty of _MAPTRIANGLE(3D).

The motion of the coin in the 3D space was easy to code.  The starting assumptions were:

  • The coin travels in a straight line (the x- axis of the _MAPTRIANGLE(3D) space) with constant speed.

    After being launched from the starting position, the coin spins at a constant rotation.

    The initial upward (_MAPTRIANGLE(3D) space y-axis) varies at each toss.  This sets the (random) time of flight.

The _MAPTRIANGLE(3D) view is rotated in the y-axis (vertical) to give a perspective view of the coin travel.


Getting the equations correct for the coin rotation and the horizontal and vertical motions was a doddle, of course.  The complicated part was in working out the appropriate equations for the landing of the coin and its subsequent fall to the landing surface.  The coin is going to land on one of four edge corners (front and rear faces meeting the edge 'up' and 'down').  In fact this is the simplest of trigonometry, working out triangle geometry, but it took me ten times longer doing this to get it correct for all conditions than it did to code the graphics - again this demonstrates the user-friendliness of _MAPTRIANGLE(3D).


The first video shows the running program with consecutive tails and heads.  The graphics are pretty convincing, with realistic coin rotation, movement, landing and settling.  When the coin has landed it falls to the nearest horizontal angle.  The coin has no inertial mass even though it has gravitational mass.  The coin rotation rate (and overall speed) is a compromise between showing the full movement and the time taken for a tossing event.  With a faster display speed the spinning would hardly be noticeable, but even so a single event takes much longer than a real coin would.  Even so, the rotation is rather difficult to appreciate and even appears unnatural at times (somewhat distorted by the perspective of the 3D space).  The second video shows the process happening at a slowed-down rate and it is clear that the coin truly spins as in reality.




To run the program, download and extract the zip file.  Place the folder "Flippin' Coin" in your QB64 folder and load the Coin Toss bas file.

https://www.dropbox.com/s/4navhbwrta780e4/Flippin%27%20Coin.zip?dl=1

Press the Spacebar to initiate a toss.  The coin will land either heads up or tails up (this you would expect!).  Depending upon which of the four edge corners the coin lands on, it will either settle backwards as in the video (this is by far the usual case) or forwards.  You may have as many goes as you wish.  Esc to Quit.


Data gathering was performed using a calculation-only program (no graphics) over 2000 cycles and it was found that the heads-tails ratio was 50-50 to within 1% - pretty good!  Because of the simple assumptions and idealised mathematical model there may be a slight bias for one particular face (if there was, it was tails).


The display could be enhanced with more appealing additional graphics, and I had intended to add an animated launch spigot, but as-is the program does its job of showing _MAPTRIANGLE(3D)'s capabilities.

5
QB64 Discussion / Division Does Not Take Longer Than Multiplication?
« on: August 13, 2021, 07:31:34 am »
I'm just finishing a program involving lots of pi/2 equations.  It came into my head that a processor would take longer to do a division than it would a multiplication.  So I did a comparison with a billion calculations (_PI/2 cf 0.5*_PI, and division takes no longer than multiplication.  So my intuitive knowledge is hopeless, it seems! [ I suppose that a "division" process is required to get the value of 0.5].

And interesting (?) but unimportant piece of knowledge.

6
Dear all members, there have been some changes to the QB64 Librarians, who comprise:

STAxTxIC ("Librarian")
Qwerkey - Library Cataloguer
bplus - Library consultant

The Library was set up by STAxTxIC, and he has had assistance from Qwerkey and bplus.  STAxTxIC has been completely busy with his non-QB64 activities for some time, and is effectively unavailable for Library work.  Qwerkey has had a year away from QB64 (medical condition), so the Library has been looked after by bplus.

I am pleased to say that I am back at QB64.  My skills in the Library are cataloguing (entering & editing Library posts), and I shall be the primary contact for your Library submission requests.  bplus's skills would be wasted on the purely administrative activity of cataloguing and he is at present very busy not only with his high-level QB64 activity but also with other priorities.

So please, if you wish to submit your programs for consideration for the Library, please Message me (@Qwerkey) or @Junior Librarian.  Thank you.

.cc
@bplus

7
InForm Discussion / Strange Behaviour of RemoveItem
« on: June 29, 2021, 05:44:04 am »
I am (at least I hope that I am) writing a simple InForm program to make a prioritisable ToDo List.

When the RemoveItem function is activated, the remaining items in the ListBox coalesce into the first item position.  If the program is exited and restarted, the remaining items are in the correct positions.  See video.

I am writing this simple program to get back into the basics of QB64, and I suspect that this is user incompetence.

The relevant program line is:
Code: QB64: [Select]
  1. RemoveItem ToDoListBX, Control(ToDoListBX).Value


8
QB64 Discussion / Odd Behaviour of InForm First Project Save
« on: June 27, 2021, 07:51:50 am »
When you first try to save an Inform Project, it will not allow you to change the Save Folder.  Instead when you select a Folder from those available on the List, the file name is changed to that of the Folder.  See video.
I am using the latest version of InForm and have not seen this behaviour before.
If, after saving the .frm and .bas and manually moving to the Project Folder, the .frm is opened with the UIEditor, then subsequent updates are correctly saved.



9
Blackjack

Author: @bplus @johnno56
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=1406.0
Version: BJ v2020-07-11 (updated)
Tags: [Graphics], [2D], [Audio]

Description:
Interactive graphical game of Blackjack.  Place bets, Hit, Stay or Double-Down.



Update: I have attached a more enjoyable game of Blackjack that isn't such a drainer of your chips. In fact, with a decent strategy you can do better than dealer PLUS there is the occasional 50 X's bet Bonus Jackpot for getting the special Logo Blackjack: An Ace of Hearts followed by a Jack of Spades. - bplus

10
Games / 486 by Jared Hoffa
« on: July 04, 2020, 01:00:22 pm »
486

Author: @runningonjava
Source:  486 the game
URL: https://486thegame.com/
Version: 1.0
Tags: [RPG], [Graphics], [3D], [Audio]

Description:
Boot up MS-DOS, slap on that cassette and get ready to c:\486.exe

486(pronounced four eighty-six ) is a retro-styled permadeath arcade RPG that throws you into an unfriendly city and lets you figure out how to get the Global High Score.  Fight, drink, dance, lift, become an athlete, play darts, fight robots, rob, steal, and smoke weed all as a square.


Controls:
Arrow Keys - Move Player
Esc – Menu

 
486 Screenshot Fight Bot.jpg


 
486 Screenshot Inventory.jpg


 
486 Screenshot Score.jpg




11
Games / QB64 Mahjong by Qwerkey
« on: July 04, 2020, 05:44:01 am »
QB64 Mahjong

Author: @Qwerkey
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=632.0
Version: 03/07/20
Tags: [Skill], [InForm], [Graphics], [2D], [Audio]

Description:
This is a Mahjong Solitaire program.  This version has been produced with InForm.  You will find that the tile images are unique (and one set is QB64-specific).  This project shows that incorporating InForm into a project is extremely easy, and it can give your projects a very professional-looking finish.

 
MahjongScreenshot.png


QB64 Tiles.png

12
STxAxTIC has set a problem to solve for a point being inside or outside of a triangle.  This program (I believe) solves that.  It works by checking whether three created angles add up to 360degrees - see original post:
https://www.qb64.org/forum/index.php?topic=2714.0
When you run the program, first click in the work area three times to define a triangle.  Then as you move about the work area, the display label will show whether the cursor is inside or outside of the triangle.  Click Restart to produce a different triangle.
 
InsideOutsideTriangle.png


13
Games / Dragon Warrior 64 [RPG as Nintendo Game] by Cobalt
« on: June 09, 2020, 12:15:32 pm »
Dragon Warrior 64

Author: @Cobalt
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=2159.30
Version: 2021-08-26 (as Author's QB64 Forum post above)
Tags: [RPG], [Graphics], [Audio]

Description:
QB64 version of Nintendo Dragon Quest (Dragon Warrior).  The time has come to go on your quest to find and defeat the evil DragonLord.  I hope that you have fun playing this game.

DEFAULT Controls:
It does have a better feel when playing with a Joypad but it is not required.
  • Start button = A (upper case)
  • A Button = Space bar (accept selection)
  • B Button = Enter (cancel action\ selection)
  • Arrow keys for movement

Dragon Warrior 64 Title Screenshot.png

Dragon Warrior 64 GamePlay1 Screenshot.png

Dragon Warrior 64 GamePlay2 Screenshot.png

 
                                                                                                                                         (300 downloads previously)

14
Utilities / NumType FUNCTION by Steve McNeill
« on: June 07, 2020, 11:10:42 am »
NumType (The Overengineered 'Is it a number?') FUNCTION.

Author: @SMcNeill
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=949.msg101479#msg101479
Version: January 06, 2019
Tags: [Function]

Description:
I bring you the glorious FUNCTION NumType!

Pass it a string and watch as it not only decides IF it's a number for you, but what TYPE of number you gave it!  It detects bits, bytes, integers, singles, floats, offsets...  Signed and unsigned!

It works with &H, &B, &O values.

You can set your string a suffix like 123&& and see if it's a valid _INTEGER64...

It generates error messages, so you can see WHY it's not a number!


Code: QB64: [Select]
  1. CONST limit = 16
  2.  
  3. DIM test(limit) AS STRING
  4.  
  5. DATA "123a.3","-123.456","--234","1.23E15","123","dogfood","678.965","54678","-987134","1E15"
  6. DATA "&HFF","&B1001111","&O17","&HFF&&","&B12000222","1.E-12"
  7.  
  8. FOR i = 1 TO limit
  9.     READ test(i)
  10.  
  11.  
  12. FOR i = 1 TO limit
  13.     PRINT "TEST #"; i; ": "; test(i) + " "
  14.     result = NumType(test(i))
  15.     IF result = 0 THEN PRINT "INVALID: "; NumErr$
  16.     IF result AND 1 THEN PRINT "Valid Unsigned Bit.  ";
  17.     IF result AND 2 THEN PRINT "Valid Unsigned Byte.  ";
  18.     IF result AND 4 THEN PRINT "Valid Unsigned Integer.  ";
  19.     IF result AND 8 THEN PRINT "Valid Unsigned Long.  ";
  20.     IF result AND 16 THEN PRINT "Valid Unsigned Integer64.  ";
  21.     IF result AND 32 THEN PRINT "Valid Unsigned Bit.  ";
  22.     IF result AND 64 THEN PRINT "Valid Signed Byte.  ";
  23.     IF result AND 128 THEN PRINT "Valid Signed Integer.  ";
  24.     IF result AND 256 THEN PRINT "Valid Signed Long.  ";
  25.     IF result AND 512 THEN PRINT "Valid Signed Integer64.  ";
  26.     IF result AND 1024 THEN PRINT "Valid Single.  ";
  27.     IF result AND 2048 THEN PRINT "Valid Double.  ";
  28.     IF result AND 4096 THEN PRINT "Valid Float.  ";
  29.     IF result AND 8192 THEN PRINT "Valid Unsigned Offset.  ";
  30.     IF result AND 16384 THEN PRINT "Valid Signed Offset.  ";
  31.     PRINT
  32.     PRINT
  33.     SLEEP
  34.  
  35. FUNCTION NumType~% (text$)
  36.     SHARED NumErr$
  37.     temp$ = UCASE$(_TRIM$(text$))
  38.     NumErr$ = "": NumType = 0
  39.  
  40.     'First look for manually assigned types
  41.     r1$ = RIGHT$(temp$, 1): r = 1
  42.     r2$ = LEFT$(RIGHT$(temp$, 2), 1)
  43.     SELECT CASE r1$
  44.         CASE "`"
  45.             TestFor = 1 'bit
  46.         CASE "%"
  47.             IF r2$ = "%" THEN
  48.                 r = 2
  49.                 TestFor = 2 'byte
  50.             ELSE
  51.                 TestFor = 3 'integer
  52.             END IF
  53.         CASE "&" 'long, int64, offset
  54.             IF r2$ = "&" THEN
  55.                 r = 2
  56.                 TestFor = 5 'int64
  57.             ELSEIF r2$ = "%" THEN
  58.                 r = 2
  59.                 TestFor = 9 'offset
  60.             ELSE
  61.                 TestFor = 4 'long
  62.             END IF
  63.         CASE "!" 'single
  64.             TestFor = 6
  65.         CASE "#" 'double, float
  66.             IF r2$ = "#" THEN
  67.                 r = 2
  68.                 TestFor = 8 'float
  69.             ELSE
  70.                 TestFor = 7 'double
  71.             END IF
  72.         CASE ELSE 'there's no set type
  73.             TestFor = 0
  74.             r = 0
  75.     END SELECT
  76.  
  77.  
  78.     temp$ = LEFT$(temp$, LEN(temp$) - r) 'strip off the type symbol
  79.     SELECT CASE TestFor
  80.         CASE 1 TO 5, 9
  81.             r$ = RIGHT$(temp$, 1)
  82.             IF r$ = "~" THEN Unsigned = -1: temp$ = LEFT$(temp$, LEN(temp$) - 1)
  83.     END SELECT
  84.  
  85.     'check for valid prefixes
  86.  
  87.     l$ = LEFT$(temp$, 2)
  88.     SELECT CASE l$
  89.         CASE "&H"
  90.             temp$ = MID$(temp$, 3)
  91.             FOR i = 1 TO LEN(temp$)
  92.                 t$ = MID$(temp$, i, 1)
  93.                 SELECT CASE t$
  94.                     CASE "0" TO "9", "A" TO "F" 'valid
  95.                     CASE ELSE
  96.                         NumErr$ = NumErr$ + "Invalid Character (" + t$ + ") encountered.  "
  97.                 END SELECT
  98.             NEXT
  99.             IF NumErr$ <> "" THEN EXIT FUNCTION
  100.             GOTO evaluateintegers
  101.         CASE "&B"
  102.             temp$ = MID$(temp$, 3)
  103.             FOR i = 1 TO LEN(temp$)
  104.                 t$ = MID$(temp$, i, 1)
  105.                 SELECT CASE t$
  106.                     CASE "0", "1" 'only valid bit characters
  107.                     CASE ELSE
  108.                         NumErr$ = NumErr$ + "Invalid Character (" + t$ + ") encountered.  "
  109.                 END SELECT
  110.             NEXT
  111.             IF NumErr$ <> "" THEN EXIT FUNCTION
  112.             GOTO evaluateintegers
  113.         CASE "&O"
  114.             temp$ = MID$(temp$, 3)
  115.             FOR i = 1 TO LEN(temp$)
  116.                 t$ = MID$(temp$, i, 1)
  117.                 SELECT CASE t$
  118.                     CASE "0" TO "7" 'only valid oct characters
  119.                     CASE ELSE
  120.                         NumErr$ = NumErr$ + "Invalid Character (" + t$ + ") encountered.  "
  121.                 END SELECT
  122.             NEXT
  123.             IF NumErr$ <> "" THEN EXIT FUNCTION
  124.             GOTO evaluateintegers
  125.     END SELECT
  126.  
  127.  
  128.     'Test for easy integers
  129.     'First check for positive/negative values; flag for invalid cases of multiple negation.
  130.     IF MID$(temp$, 1, 1) = "-" THEN
  131.         negative = -1: temp$ = MID$(temp$, 2) 'strip off the initial negative
  132.     ELSEIF MID$(temp$, 1, 1) = "+" THEN
  133.         temp$ = MID$(temp$, 2) 'strip off the initial positive
  134.     END IF
  135.  
  136.     FOR i = 1 TO LEN(temp$)
  137.         IF MID$(temp$, i, 1) = "-" THEN minus = minus + 1
  138.         IF MID$(temp$, i, 1) = "+" THEN plus = plus + 1
  139.         IF MID$(temp$, i, 1) = "." THEN period = period + 1 'Go ahead and check for multiple periods while we're at it.
  140.         IF MID$(temp$, i, 1) = "E" OR MID$(temp$, i, 1) = "D" THEN
  141.             Exponent = Exponent + 1
  142.             IF MID$(temp$, i + 1, 1) = "-" OR MID$(temp$, i + 1, 1) = "+1" THEN ExponentSign = -1
  143.         END IF
  144.     NEXT
  145.  
  146.     IF period = 0 AND Exponent = 0 THEN 'we should only have integers to process
  147.         FOR i = 1 TO LEN(temp$)
  148.             t$ = MID$(temp$, i, 1)
  149.             IF t$ < "0" OR t$ > "9" THEN NumErr$ = NumErr$ + "Invalid Character (" + t$ + ") encountered.  ": EXIT FUNCTION
  150.         NEXT
  151.         GOTO evaluateintegers
  152.     END IF
  153.  
  154.     'At this point forward, we should only have REAL numbers to process
  155.  
  156.     IF Exponent > 1 THEN NumErr$ = NumErr$ + "Multiple E/D exponent characters in string.  ": EXIT FUNCTION
  157.  
  158.     IF ExponentSign = 0 THEN
  159.         IF minus THEN NumErr$ = NumErr$ + "Multiple negative signs (-) encountered.  ": EXIT FUNCTION
  160.         IF plus THEN NumErr$ = NumErr$ + "Multiple negative signs (-) encountered.  ": EXIT FUNCTION
  161.     ELSE
  162.         IF minus > 1 THEN NumErr$ = NumErr$ + "Multiple negative signs (-) encountered.  ": EXIT FUNCTION
  163.         IF plus > 1 THEN NumErr$ = NumErr$ + "Multiple negative signs (-) encountered.  ": EXIT FUNCTION
  164.     END IF
  165.  
  166.     IF period > 1 THEN NumErr$ = NumErr$ + "Multiple decimal points (.) encountered.  ": EXIT FUNCTION
  167.  
  168.     IF Exponent AND period THEN
  169.         e = INSTR(temp$, "E")
  170.         IF e = 0 THEN e = INSTR(temp$, "D")
  171.         p = INSTR(temp$, ".")
  172.         IF p > e THEN NumErr$ = NumErr$ + "Decimal points (.) AFTER E/D exponent encountered.  ": EXIT FUNCTION
  173.     END IF
  174.  
  175.  
  176.     FOR i = 1 TO LEN(temp$)
  177.         t$ = MID$(temp$, i, 1)
  178.         SELECT CASE t$
  179.             CASE "0" TO "9", "-", "+", ".", "D", "E" 'we should have validated all these characters earlier
  180.             CASE ELSE 'so anything else is invalid
  181.                 NumErr$ = NumErr$ + "Invalid Character (" + t$ + ") encountered.  ": EXIT FUNCTION
  182.         END SELECT
  183.     NEXT
  184.  
  185.     IF NumErr$ <> "" THEN EXIT FUNCTION
  186.  
  187.  
  188.     'We should've passed all the error checking by this point -- I think...
  189.  
  190.  
  191.     evaluateintegers:
  192.     t## = VAL(text$)
  193.  
  194.     'first compare for all types
  195.     IF INT(t##) = t## THEN
  196.         IF t## = -1 OR t## = 0 THEN NumType = NumType OR 32 'signed bit
  197.         IF t## >= -128 AND t## <= 127 THEN NumType = NumType OR 64 'signed byte
  198.         IF t## >= -32768 AND t## <= 32767 THEN NumType = NumType OR 128 'signed integer
  199.         IF t## >= -2147483648 AND t## <= 2147483647 THEN NumType = NumType OR 256 'signed long
  200.         IF t## >= -9223372036854775808 AND t## <= 9223372036854775807 THEN
  201.             NumType = NumType OR 512 'signed integer64
  202.             NumType = NumType OR 16384 'signed offset
  203.         END IF
  204.         IF t## = 1 OR t## = 0 THEN NumType = NumType OR 1 'unsigned bit
  205.         IF t## >= 0 AND t## <= 255 THEN NumType = NumType OR 2 'unsigned byte
  206.         IF t## >= 0 AND t## <= 65535 THEN NumType = NumType OR 4 'unsigned integer
  207.         IF t## >= 0 AND t## <= 4294967295 THEN NumType = NumType OR 8 'unsigned long
  208.         IF t## >= 0 AND t## <= 18446744073709551615 THEN
  209.             NumType = NumType OR 16 'unsigned integer64
  210.             NumType = NumType OR 8192 'unsigned offset
  211.         END IF
  212.     END IF
  213.  
  214.     IF t## >= -2.802597D45 AND t## <= 3.402823D+38 THEN
  215.         NumType = NumType OR 1024 'single
  216.     END IF
  217.     IF t## >= -4.490656458412465E324 AND t## <= 1.797693134862310E+308 THEN NumType = NumType OR 2048 'double
  218.     IF t## >= -1.18E4932 AND t## <= 1.18E+4932 THEN NumType = NumType OR 4096 'float
  219.  
  220.     IF r THEN 'we have specific suffix; only decide if the value is valid for it
  221.         NumType = 0
  222.         IF NOT Unsigned THEN 'unsigned
  223.             SELECT CASE TestFor
  224.                 CASE 1
  225.                     IF t## = -1 OR t## = 0 THEN NumType = 32 'signed bit
  226.                 CASE 2
  227.                     IF t## >= -128 AND t## <= 127 THEN NumType = 64 'signed byte
  228.                 CASE 3
  229.                     IF t## >= -32768 AND t## <= 32767 THEN NumType = 128 'signed integer
  230.                 CASE 4
  231.                     IF t## >= -2147483648 AND t## <= 2147483647 THEN NumType = 256 'signed long
  232.                 CASE 5, 9
  233.                     IF t## >= -9223372036854775808 AND t## <= 9223372036854775807 THEN
  234.                         IF TestFor = 5 THEN
  235.                             NumType = 512 'signed integer64
  236.                         ELSE
  237.                             NumType = 16384 'signed offset
  238.                         END IF
  239.                     END IF
  240.                 CASE 6
  241.                     IF t## >= -2.802597E-45 AND t## <= 3.402823E+38 THEN NumType = 1024 'single
  242.                 CASE 7
  243.                     IF t## >= -4.490656458412465E-324 AND t## <= 1.797693134862310E+308 THEN NumType = 2048 'double
  244.                 CASE 9
  245.                     IF t## >= -1.18E-4932 AND t## <= 1.18E+4932 THEN NumType = 4096 'float
  246.             END SELECT
  247.         ELSE
  248.             SELECT CASE TestFor
  249.                 CASE 1
  250.                     IF t## = 0 OR t## = 1 THEN NumType = 1 'unsigned bit
  251.                 CASE 2
  252.                     IF t## >= 0 AND t## <= 255 THEN NumType = 2 'unsigned byte
  253.                 CASE 3
  254.                     IF t## >= 0 AND t## <= 65535 THEN NumType = 4 'unsigned integer
  255.                 CASE 4
  256.                     IF t## >= 0 AND t## <= 4294967295 THEN NumType = 8 'unsigned long
  257.                 CASE 5, 9
  258.                     IF t## >= 0 AND t## <= 18446744073709551615 THEN
  259.                         IF TestFor = 5 THEN
  260.                             NumType = 16 'unsigned integer64
  261.                         ELSE
  262.                             NumType = 8192 'unsigned offset
  263.                         END IF
  264.                     END IF
  265.             END SELECT
  266.         END IF
  267.         IF NumType = 0 THEN NumErr$ = "Invalid Suffix.  "
  268.     END IF
  269.  
  270.  


15
Games / Chess by Richard Frost
« on: June 05, 2020, 04:46:40 am »
Chess

Author: @Richard Frost
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=2437.msg138267#msg138267
Version: Go to author's Project Post (URL above) for latest version and update status
Tags: [Graphics], [2D], [AI], [Skill]

Author's Description:
Chess Program that plays legally.  Crappy endgame, since the rules I've given it are simple.  Pretty challenging for midgame thought.  Most of the code is for graphics - the pieces themselves, the plasma effect, etc., and for configuration and showing the thinking, file playback, etc.   Hard to believe a chess program  was done in under 1K, twice!

Controls:
Mouse and Keyboard


Chess Screenshot.JPG


We recommend checking for the latest version in author's Project Post (mem.h has to be copied to the QB64 folder).

  


 

Pages: [1] 2 3 ... 8