Sign in to follow this  
Followers 0
xxfxx

Jeopardy

6 posts in this topic

i am working on Jeopary tool full of all the answers i am stuck tho as i cant figure out where to go from hear. please any ideas as its been a few years since i was in autoit 101

main script

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.8.1
    Author:      XxFxX
    Version:        1.00

    Script Function:
    Jeopardy tool to help with the questions.

#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Questions.au3>
#include <Answers.au3>



Opt("GUIOnEventMode", 1)
SplashImageOn("", "C:\AUTOIT\Jeopardy_tool\jeopardy192.jpg", "-1", "-1", "-1", "-1", 3)
SoundPlay("j.mp3", 0)
Sleep(5000)
SplashOff()



Global $Jeopardy = GUICreate("Jeopardy", 521, 465)
GUISetBkColor(0x000080)
Global $AnswersLabel = GUICtrlCreateLabel("Answer List", 16, 8, 170, 38, $WS_BORDER)
GUICtrlSetFont($AnswersLabel, 22, 800, 0, "Gyparody Hv")
GUICtrlSetColor($AnswersLabel, 0xFFFF00)
GUICtrlCreatePic("C:\AUTOIT\Jeopardy_tool\jeopardy192.jpg", 200, 0, 300, 276)
Global $QuestionsLabel = GUICtrlCreateLabel("Question", 224, 280, 100, 33)
GUICtrlSetFont($QuestionsLabel, 18, 400, 0, "Gyparody Rg")
GUICtrlSetColor($QuestionsLabel, 0xFFFF00)
Global $AnswersList = GUICtrlCreateList($Answers, 8, 48, 177, 253)
Global $QuestionsList = GUICtrlCreateList($Questions, 8, 328, 489, 97)


GUISetState(@SW_SHOW)



While 1
    Sleep(100)
WEnd

Questions.au3

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.8.1
    Author:      XxFxX
    Version:        1.00

    Script Function:
    Jeopardy tool to help with the questions.

#ce ----------------------------------------------------------------------------

$Q1 = What is the capital of Yukon Territory?
;---answer is on Answers.au3  $A1
$Q2 = Which is the heaviest?
;---answer is on Answers.au3  $A2

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.8.1
    Author:      XxFxX
    Version:        1.00

    Script Function:
    Jeopardy tool to help with the questions.

#ce ----------------------------------------------------------------------------

$Q1 = YellowKnife
;---Question is on Questions.au3  $Q1
$Q2 = Gold
;---Question is on Questions.au3  $Q2

jeopardy_tool.au3

Answers.au3

Questions.au3

Share this post


Link to post
Share on other sites



I dont know what a Jeopardy is

Then too this might get you start :)

Here is the Link


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

This could be a fun game. I have some questions. How are you going to set up the game? In Jeopardy, you are given the answer and you are supposed phrase your answer as a question. Are you going to do that? Also, I assume you are going to give the user some choices for the answer, so you must have 3 or 4 answers for each question, which you do not currently have.

I'm working on an example of how I would approach it. I will post in a while.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

OK, I have some working code. This is only an example of how I might go about this program. I hope it give you some ideas. The program is straightforward. It asks a question and gives you 3 possible answers. The user selects one and presses submit button. The program checks the selected answer to the correct one and gives messagebox whether it is correct or not.

I wrote the question/answer file as one text file. The program picks a line at random and reads it. The line contains the following:

Question | Ans 1 | Ans 2 | Ans 3 | Correct Answer

I used stringsplit to create a 5 row array and use the first 4 for the question/answers. The fifth is returned as the correct answer.

Here's the program code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <file.au3>
#include <array.au3>

$Form1 = GUICreate("Form1", 532, 333, 193, 125)
$Label1 = GUICtrlCreateLabel("Jeopardy", 16, 16, 112, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("", 24, 72, 468, 49)
$Listbox = GUICtrlCreateList("", 32, 152, 465, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN), 0)
$Button1 = GUICtrlCreateButton("New Question", 248, 280, 107, 25, 0)
$Button2 = GUICtrlCreateButton("Submit Answer", 384, 280, 115, 25, 0)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $ans
$answer = AskQuestion($ans)
Case $Button2
$chosenAnswer = GUICtrlRead($Listbox)
If $chosenAnswer = $answer Then
MsgBox(0, "", "You got it right!")
$answer = AskQuestion($ans)
ElseIf $chosenAnswer = "" Then
MsgBox (0, "", "You did not select an answer.")
Else
MsgBox(0, "", "You got it wrong. The correct answer is: " & $answer)
$answer = AskQuestion($ans)
EndIf

EndSwitch
WEnd

Func AskQuestion($ans)
GUICtrlSetData($Label2, "")
GUICtrlSetData($Listbox, "")
GUICtrlSetData($Listbox, "")
$quesListLineCount = _FileCountLines("QuestionsAnswers.txt")
$randLine = Random(1, $quesListLineCount, 1)
$ques = FileReadLine("QuestionsAnswers.txt", $randLine)
$quesArray = StringSplit($ques, "|", 2)
GUICtrlSetData($Label2, $quesArray[0])
GUICtrlSetData($Listbox, $quesArray[1] & "|" & $quesArray[2] & "|" & $quesArray[3])
Return($quesArray[4])
EndFunc

The QuestionsAnswers.txt text file (name it QuestionsAnswers.txt)

The capital of Yukon Territory|Yukon Valley|YellowKnife|Darnell|YellowKnife
The heaviest precious metal|Silver|Platinum|Gold|Gold
The highest mountain on Earth|Mount Everest|Mount St. Helen|Mount Alaska|Mount Everest
Largest group of lakes in America|Lake Wylie|The Great Lakes|Lake Ohama|The Great Lakes

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

If you want to encrypt the questions & answers, you can use this tool:

#include <file.au3>
#include <String.au3>
$lineCount = _FileCountLines("QuestionsAnswers.txt")

For $i = 1 to $lineCount Step 1
$line = FileReadLine("QuestionsAnswers.txt", $i)
$eLine = _StringEncrypt(1, $line, "password")
FileWrite("QuestionsAnswers_encrypted.txt", $eLine & @CRLF)
Next

It takes your QuestionsAnswers.txt and writes a new one called QuestionsAnswers_encrypted.txt. This code below reads the encrypted version and decrypts the questions & answers in memory.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <file.au3>
#include <array.au3>
#include <string.au3>

$Form1 = GUICreate("Form1", 532, 333, 193, 125)
$Label1 = GUICtrlCreateLabel("Jeopardy", 16, 16, 112, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("", 24, 72, 468, 49)
$Listbox = GUICtrlCreateList("", 32, 152, 465, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN), 0)
$Button1 = GUICtrlCreateButton("New Question", 248, 280, 107, 25, 0)
$Button2 = GUICtrlCreateButton("Submit Answer", 384, 280, 115, 25, 0)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $ans
$answer = AskQuestion($ans)
Case $Button2
$chosenAnswer = GUICtrlRead($Listbox)
If $chosenAnswer = $answer Then
MsgBox(0, "", "You got it right!")
$answer = AskQuestion($ans)
ElseIf $chosenAnswer = "" Then
MsgBox (0, "", "You did not select an answer.")
Else
MsgBox(0, "", "You got it wrong. The correct answer is: " & $answer)
$answer = AskQuestion($ans)
EndIf

EndSwitch
WEnd

Func AskQuestion($ans)
GUICtrlSetData($Label2, "")
GUICtrlSetData($Listbox, "")
GUICtrlSetData($Listbox, "")
$quesListLineCount = _FileCountLines("QuestionsAnswers_encrypted.txt")
$randLine = Random(1, $quesListLineCount, 1)
$ques = FileReadLine("QuestionsAnswers_encrypted.txt", $randLine)
$ques = _StringEncrypt(0, $ques, "password")
$quesArray = StringSplit($ques, "|", 2)
GUICtrlSetData($Label2, $quesArray[0])
GUICtrlSetData($Listbox, $quesArray[1] & "|" & $quesArray[2] & "|" & $quesArray[3])
Return($quesArray[4])
EndFunc#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <file.au3>
#include <array.au3>
#include <string.au3>

$Form1 = GUICreate("Form1", 532, 333, 193, 125)
$Label1 = GUICtrlCreateLabel("Jeopardy", 16, 16, 112, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("", 24, 72, 468, 49)
$Listbox = GUICtrlCreateList("", 32, 152, 465, 89, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN), 0)
$Button1 = GUICtrlCreateButton("New Question", 248, 280, 107, 25, 0)
$Button2 = GUICtrlCreateButton("Submit Answer", 384, 280, 115, 25, 0)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Local $ans
$answer = AskQuestion($ans)
Case $Button2
$chosenAnswer = GUICtrlRead($Listbox)
If $chosenAnswer = $answer Then
MsgBox(0, "", "You got it right!")
$answer = AskQuestion($ans)
ElseIf $chosenAnswer = "" Then
MsgBox (0, "", "You did not select an answer.")
Else
MsgBox(0, "", "You got it wrong. The correct answer is: " & $answer)
$answer = AskQuestion($ans)
EndIf

EndSwitch
WEnd

Func AskQuestion($ans)
GUICtrlSetData($Label2, "")
GUICtrlSetData($Listbox, "")
GUICtrlSetData($Listbox, "")
$quesListLineCount = _FileCountLines("QuestionsAnswers_encrypted.txt")
$randLine = Random(1, $quesListLineCount, 1)
$ques = FileReadLine("QuestionsAnswers_encrypted.txt", $randLine)
$ques = _StringEncrypt(0, $ques, "password")
$quesArray = StringSplit($ques, "|", 2)
GUICtrlSetData($Label2, $quesArray[0])
GUICtrlSetData($Listbox, $quesArray[1] & "|" & $quesArray[2] & "|" & $quesArray[3])
Return($quesArray[4])
EndFunc

RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

I dont know what a Jeopardy is

Its a long running game show in the US.

http://en.wikipedia.org/wiki/Jeopardy!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0