Interactive word puzzle with Visual Basic implementation
Boggle is a classic word game where players try to find as many words as possible in a grid of lettered dice. Words can be formed from adjacent letters (horizontally, vertically, or diagonally) without reusing the same tile.
This enhanced version allows you to play the game interactively in your browser. Shake the board to get new letters, select tiles to form words, and submit your words to score points. Longer words earn more points!
The game includes a timer for 3-minute sessions and tracks your score based on word length. Below the game, you'll find a complete VB.NET implementation of the Boggle game.
Below is a complete Visual Basic .NET implementation of the Boggle game. This code demonstrates key programming concepts including arrays, loops, event handling, and game logic.
Public Class BoggleGame Private board(4, 4) As Char Private score As Integer = 0 Private foundWords As New List(Of String) Private timer As New Timer() Private timeLeft As Integer = 180 ' 3 minutes Private Sub BoggleGame_Load(sender As Object, e As EventArgs) Handles MyBase.Load ShakeBoard() timer.Interval = 1000 timer.Start() End Sub Private Sub ShakeBoard() Dim rnd As New Random() Dim dice As String() = { "AACIOT", "ABILTY", "ABJMOQ", "ACDEMP", "ACELRS", "ADENVZ", "AHMORS", "BIFORX", "DENOSW", "DKNOTU", "EEFHIY", "EGKLUY", "EGINTV", "EHINPS", "ELPSTU", "GILRUW", "ABILTY", "ACDEMP", "EGINTV", "EHINPS", "ELPSTU", "GILRUW", "AACIOT", "ABJMOQ", "ACELRS" } For i As Integer = 0 To 4 For j As Integer = 0 To 4 ' Get random die and select a face Dim die As String = dice(i * 5 + j) board(i, j) = die(rnd.Next(die.Length)) ' Update the tile control tiles(i, j).Text = board(i, j).ToString() Next Next End Sub Private Sub SubmitWord() Dim word As String = txtWord.Text.Trim().ToUpper() If word.Length < 3 Then MessageBox.Show("Words must be at least 3 letters long!") Return End If If foundWords.Contains(word) Then MessageBox.Show("You already found that word!") Return End If If IsValidWord(word) Then foundWords.Add(word) ' Update score based on word length score += CalculateScore(word) lblScore.Text = score.ToString() lstFoundWords.Items.Add(word) txtWord.Clear() Else MessageBox.Show("Invalid word or not on board!") End If End Sub Private Function CalculateScore(word As String) As Integer Select Case word.Length Case 3, 4 : Return 1 Case 5 : Return 2 Case 6 : Return 3 Case 7 : Return 5 Case Else : Return 11 End Select End Function Private Function IsValidWord(word As String) As Boolean ' This function would check if the word exists in a dictionary ' and can be formed on the board using adjacent letters Return True ' Simplified for example End Function Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles timer.Tick timeLeft -= 1 Dim minutes As Integer = timeLeft \ 60 Dim seconds As Integer = timeLeft Mod 60 lblTimer.Text = $"{minutes}:{seconds.ToString("D2")}" If timeLeft <= 0 Then timer.Stop() MessageBox.Show("Time's up! Final score: " & score) End If End Sub End Class
Try implementing these improvements to the VB.NET Boggle game:
Boggle is a word game invented by Allan Turoff and originally distributed by Parker Brothers. The game is played using a plastic grid of lettered dice, in which players attempt to find words in sequences of adjacent letters.
The game has these key features:
This implementation demonstrates how to create a digital version of Boggle using Visual Basic programming concepts.