Share via


Visual Basic 2017: Numbers Game

 

Overview

This is the Numbers Game as played on the UK Channel Four tv game show CountDown. The game is simple, you select 6 random numbers, and attempt to reach a random target by adding, subtracting, multiplying, and dividing those numbers.

The numbers used are four large numbers... 100, 75, 50, 25, and twenty small numbers... two each of the numbers 1 to 10.

You can randomly choose from 0 to 4 large numbers, with the remaining numbers being small numbers. When you select your sixth random number, a random target number will be chosen (from 101 to 999), the countdown clock will begin, and you have thirty seconds to find a solution that equals the target number. Your solution must consist of any of your chosen numbers, the arithmetic operators +, -, /, *, and brackets. You only need to use as many of the six numbers as you need. It's not obligatory to use all of the numbers.

During the thirty-second countdown, the application will attempt to solve the equation. If a solution exists, it will be found within the thirty-second duration (Exceptional cases might take slightly longer). If you think you've found a solution, you can stop the clock and the PC solution will appear as soon as it is available.

This is a difficult game to beat, but it is possible if you're quick with mental arithmetic.

 

The Numbers Class



      Public Class  Numbers
              
                 Private large As New  List(Of Integer) From {25, 50, 75, 100}  
                 Private small As New  List(Of Integer) From {1, 2, 3, 4, 5,  
                 6, 7, 8, 9, 10,      
                 1, 2, 3, 4, 5,      
                 6, 7, 8, 9, 10}      
              
                 Public Sub  New(r As Random)  
                     large = large.OrderBy(      Function      (x) r.NextDouble).ToList      
                     small = small.OrderBy(      Function      (x) r.NextDouble).ToList      
                 End Sub  
              
                 Public Function  drawSmall() As  Integer  
                     Dim x As Integer  = small(0)  
                     small.RemoveAt(0)      
                     Return x  
                 End Function  
              
                 Public Function  drawLarge() As  LargeDrawn  
                     Dim x As Integer  = large(0)  
                     large.RemoveAt(0)      
                     Dim isLastNumber As Boolean  = large.Count = 0  
                     Return New  LargeDrawn With  {.x = x, .last = isLastNumber}  
                 End Function  
              
      End Class

Conclusion

Computers are ideal for manipulating numbers. An advanced arithmetical number manipulating program is only as good as the instructions it is given, although advances in AI technology might change that in the future...

 

Downloads

Download from MSDN Samples Gallery...

 
Full article and download here...

VB.Net - WordSearch
VB.Net - Vertex
VB.Net - Perspective
VB.Net - MasterMind
VB.Net - OOP BlackJack
VB.Net - HangMan
Console BlackJack - VB.Net | C#
TicTacToe - VB.Net | C#
OOP Conway's Game of Life - VB.Net | C#
OOP Sudoku - VB.Net | C#
OctoWords 
VB.Net | C# 
OOP Buttons Guessing Game VB.Net | C#
OOP Tangram Shapes Game VB.Net | C#
VB.Net - Three-card Monte
VB.Net - Split Decisions
VB.Net - Pascal's Pyramid
VB.Net - Random Maze Games
(Office) Wordsearch Creator
VB.Net - Event Driven Programming - LockWords Game
C# - Crack the Lock
VB.Net - Totris