Author Topic: Wheel of Fortune script, a beginners work in progress  (Read 9282 times)

zanthal

  • Guest
Wheel of Fortune script, a beginners work in progress
« on: December 18, 2009, 12:00:07 PM »
 I've never tried to tackle programming even as allegedly simple as VBASIC, and as such this thread at first will be me thinking out loud and planning how to form the functions for this game I have in mind.

 If anyone sees any errors in what I'm doing please feel free to critique, you won't hurt my feelings   :mrgreen:

So it all starts when someone in the chat room wants to play a game of Wheel of Fortune.  They type in:

!playwof nickofplayer1,nickofplayer2,nickofplayer3,nickofplayer4


The script greets with, "Hello, player1, 2, 3, 4!  The Wheel of Fortune game rules and instructions are as follows:
------
 Wheel of Fortune IRC game, description and rules:

 The IRC game is exactly like the game show on TV, except the scoring is different and there is no wheel to spin.  Each player is presented with a phrase, person, place, or thing puzzle to guess letters of and try to solve.  
 The maximum number of points per round is 100, this being awarded if the puzzle is guessed on the players first turn.  Every incorrect guess reduces that possible 100 by 10, and every turn the player chooses not to guess reduces that possible 100 by 1.  Thus it's to the advantage of the player to only guess if they feel confident they have the correct answer.  

To guess a letter, use !guessletter _

To guess the solution, use !solve ______
 
To pass your turn, use !pass
 
To see the score list, use !wofscores
------

(note:  the score list will display a list of all players who have ever been recorded as playing, the number of rounds they've participated in, and their total score will be displayed in this format:

Wheel of Fortune all time scores:  player1, SCORE# points in #ofROUNDS rounds | player2, SCORE# points in #ofROUNDS rounds | and so on ...)



GAME START:


 The script should then ask each player if they're ready to play.  If they all reply 'yes' then the game begins.

 The script pulls a random word, phrase, name, place, thing, etc from a list entitled 'wof.txt' in the scripts directory.  The format in the text file will be:

phrase:OUT OF THE BLUE
place:ON TOP OF THE WORLD
thing:BICYCLE BUILT FOR TWO

 ... and the list can be added to or changed of course.

 (for the example below I'm using the phrase OUT OF THE BLUE)

 The script outputs to the chatroom:
 
  "Wheel of Fortune Round ROUND# is about to begin!   The phrase is  _ _ _   _ _   _ _ _   _ _ _ _      ***good luck*** !"
 
  "Player1, it's your turn, you have one minute to guess a letter, solve the puzzle, or pass your turn, or you will forfeit your turn and 10 points."
 
 The script asks each player in turn to either guess a letter, solve the puzzle, or pass on the puzzle solving attempt.  Every turn a player must at least pick a letter, try and guess the answer to the puzzle or pass the

attempt.

(At this point, the script waits for the player to respond.  They have 60 seconds before a time limit warning appears that says they have 10 seconds left to make their entry or lose their turn and 10 possible points, and

after that 10 seconds it is carried out)

 If Player1 entered:

!guessletter G

 the script would output:

 "I'm sorry, the letter 'G' is not in the puzzle" and continues to the next player.

 If Player1 entered:

!guessletter T

 The script would output:

 "There are 2 T's !"

 "The phrase is  _ _ T   _ _   T _ _   _ _ _ _  ..."

 "Player1, would you like to solve the puzzle?  You may solve or pass your turn, you have one minute."

(At this point, the script waits for the player to respond.  They have 60 seconds before a time limit warning appears that says they have 10 seconds left to make their entry or lose their turn and 10 possible points, and

after that 10 seconds it is carried out)

 Player1 would then respond with either:

 !solve insert puzzle guess here

 or

 !pass

 If the guess is correct, the script records all player's names as having participated in 1 round and also adds the winning players score to his/her all time total.  The record keeps a running total of players, the # of rounds they've played, and their total score overall.  The script then announces to the winning player that the solution is correct, displays the solution, announces the round is over and thanks each of the players for playing by name, announces the winner player by name, and announces his round score and all time score.

 If the guess is incorrect, the script announces a loss of 10 possible points for the round,  and Player1's current score, and the script moves on to Player2 outputing:  

"Player2, the phrase is _ _ T   _ _   T _ _   _ _ _ _  ...   ***good luck*** !" and the game progresses as above.

 If Player1 responds with !noguess then the script announces a loss of 2 possible points for the round and Player1's current score, and the script moves on to Player2 outputing:  

"Player2, the phrase is _ _ T   _ _   T _ _   _ _ _ _   ...   ***good luck*** !" and the game progresses as above.

The round continues in this fashion through the players in the order they were given in the !playwof command, until the puzzle is solved.  

It IS possible a player could solve the puzzle and lose points in the round, assuming it was a very difficult puzzle and 10+ rounds and guesses were needed (surely a rare occurance).

It IS possible for all of the letters to be guessed and the solution displayed.  For ease of coding I think it is probably best that the player still be required at that point to !solve the puzzle with the proper command, even if they just picked the last letter in it and the solution is being displayed by the script.
« Last Edit: December 18, 2009, 12:01:56 PM by zanthal »

zanthal

  • Guest
Re: Wheel of Fortune script, a beginners work in progress
« Reply #1 on: December 18, 2009, 12:25:24 PM »

 A few tidbits I'm aware of, I know I need to identify the commands, define and fetch variables (a random puzzle from the text file needs to be fetched and defined and then the current puzzle needs to be defined).

 To start though:

 
Quote
So it all starts when someone in the chat room wants to play a game of Wheel of Fortune.  They type in:

!playwof nickofplayer1,nickofplayer2,nickofplayer3,nickofplayer4

At this point I know the script will need to verify that the players are actually in the room before it asks if they want to play, and to have a respond ready if they are not all found.


I'm still trying to get a grip on procedures ... do the procedures need to be in order of execution for the script to function properly, or do they just all need to be defined in the script and then a separate part of the script refers to each Sub procedure as needed by name? 
« Last Edit: December 18, 2009, 12:28:35 PM by zanthal »

zanthal

  • Guest
Re: Wheel of Fortune script, a beginners work in progress
« Reply #2 on: December 18, 2009, 12:37:24 PM »

 So I find myself with each question I have leading to more questions.

 I'm referring to Morio's Hangman script to try and get the answers.  I've noticed to play his Hangman game, you use two commands.  !playhangman  to start the game  and  !guess   to guess the word.  Inside the script however only the command !playhangman can be found.  The characters !guess aren't even in the script.

 It also appears the entire game of Hangman is run by two Procedures and two Functions.  I wonder if it creative coding that made it that easy to do.  I look at all the different things I want my WOF script to do and figure it will take many more Procedures to accomplish.


zanthal

  • Guest
Re: Wheel of Fortune script, a beginners work in progress
« Reply #3 on: December 18, 2009, 01:15:47 PM »

My first question ... the procedures.  The script does several main things, and then also other minor things as part of those.  I'm using Morio's Hangman as an example and my thinking is the code should include (and I expect to be mistaken):


Dim Hangman,HMChannel,TotalGuesses,GuessesLeft
Set Hangman = CreateObject("Scripting.Dictionary")
Set GuessesLeft = CreateObject("Scripting.Dictionary")
 'the above is copied verbatim from the Hangman script.  I'm plugging this in here because I don't
 'understand what the object Scripting.Dictionary is, what this Dim reference is, and why objects are
 'only created for Hangman and GuessesLeft, and HMChannel and TotalGuesses are left unreferred to
 'until later. 


 
If GetIniFile then WriteIniFile
 'code here to create the WOF.ini file that will save scores during the game, record them at the
 'end of the game, and supply other procedures with data needed such as current game scores,
 'end of game scores, and also for answering the !wofscores command
 

Sub ONTEXT(Message,Channel,PlayerNickname,Host,ServerNumber)
 'this procedure will discern the responses the script gives to players commands.
 'it will answer the commands after they are made and then either refer to other Procedures or
 'possibly end the script, in the case that not all players are found after using the !playwof command
 'for example

Sub PLAYWOF(Action,Guess,Destination)
 'what is in parentheses above is verbatim copied from the Hangman script. 
 'what I think I understand here is various states of the game are handled in this
 'procedure.  If the game just started, how are the commands handled.  When a command
 'is made, the data is defined and used where and how.



zanthal

  • Guest
Re: Wheel of Fortune script, a beginners work in progress
« Reply #4 on: December 18, 2009, 01:39:35 PM »


 Something I need to know I can't seem to get straight:

 1)  What parts of the script will need to be handled as Subs and which ones will have to be handled as Functions?  I understand from the Basics Tutorial what the difference is, but not how it would be applied or why.


zanthal

  • Guest
Re: Wheel of Fortune script, a beginners work in progress
« Reply #5 on: December 18, 2009, 02:15:09 PM »


Dim WOFChannel,ScoreChangePass,ScoreChangeIncorrect,ScoreChangeTimeout

and have functions that report values for each players score as they change from turn to turn, with a ScoreChangePass subtracting 1 point from current score.  ScoreChangeIncorrect subtracts 10, and so does ScoreChangeTimeout.

I think two INI files will be necessary.  One to start all players with 100 points at the beginning of a round and record the progress during the round, and one to record who's played, how many rounds they've played, and their scores.



Will variables be needed to handle individual players as I've shown above?  I don't see any way around it.  The game won't work well if just anyone can play and shout out letter guesses.  The participating players have to be defined beforehand and go turn-by-turn in order.  Would it be best to handle an indeterminate number of players by somehow coding it to require at least 2 but no more than say, 6 players? 

 




Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: Wheel of Fortune script, a beginners work in progress
« Reply #6 on: December 19, 2009, 01:04:01 AM »
Whoa you have a lot of questions, you might wanna find some tutorial about vbscripting. This would be a good place to start.

I thought I'd answer a few of those questions for you (not in any particular order)

about the '!guess' command. It is in the ONTEXT sub:
Code: [Select]
If Hangman.Exists(Channel & ":" & ServerNumber) then
If Left(Message,7) = "!guess " And Len(Message) > 7 then
Guess = LCase(Mid(Message,8))
If Len(Guess) > 1 then
PlayHangman "word",Guess,Channel & ":" & ServerNumber
Else
PlayHangman "letter",Guess,Channel & ":" & ServerNumber
End If
End If
End If

Dim is just a way to declare variables. Remember to declare global variables outside of any subs or functions.

The difference with subs and functions is that functions can be used to return a value, whereas subs can not.

In the hangman script the only funcion is the one that splits the word before displaying it, which means it add spaces between every character. This is better than actually saving the spaces in the word, since that would make checking for the correct word more difficult.

You might wanna make a command to start the game, and then let other users use a commdn to join if they want, that would in my opinion be better than declaring the players at the beginning. For stuff like handling players/turns etc you might wanna check out the UNO script in the download section.

You will only need one ini file, because the info is stored iniside the file like this
Code: [Select]
[section]
name1=value1
name2=value2
.
.
.
[section2]
name1=value1
name2=value2
.
.
.

In the spirit of the original Wheel Of Fortune, you could make the users actually spin the wheel, thus adding a chance to lose your money or turn or get a bonus etc. You might actually skip the point/money system until you have the script working without it, just make it so that it's easy to implement later.

You might also want to come up with a better way to display the highscore list, because the one you have right now would produce very long lines, and many networks have a limit on how long lines you can send (You could make a function to split the lines, but then there's a risk of getting killed for flooding)

about the scripting dictionary object. Here you can find pretty much all the information you will need
« Last Edit: December 19, 2009, 02:39:21 AM by Morio »
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

zanthal

  • Guest
Re: Wheel of Fortune script, a beginners work in progress
« Reply #7 on: December 20, 2009, 01:25:27 AM »

 Having a Wheel and make the game close to the original would be preferred but I've already bitten off a pretty big chunk to chew here.