Need help with assignment. Combinatorics and Probability - Analyzing Poker In th
ID: 3759112 • Letter: N
Question
Need help with assignment.
Combinatorics and Probability - Analyzing Poker
In this assignment, you will apply what you have learned about combinatorics and probability to analyze the popular card game of poker.
Specifically, we will simulate a simplified two-player version of "Texas hold 'em" at the end of a round and calculate, given a player's cards and the community cards, the probabilities of the opponent's holding a hand of each possible type as well as the probability of victory.
Simplified rules of Texas hold 'em are provided below; you do not have to know anything more about poker to write this program. Some VBA skeleton code to find the best hand of five cards from the seven in a hand will be provided for you; the important part of this assignment is to learn to calculate (and implement in computer code) the probabilities. If you're writing in another language, this skeleton code may not be available.
Download skeleton code
The Assignment
That is, your program should calculate the probability that your opponent holds each type of hand, as well as the probability your hand is better than your opponent's.
Your program may simplify the usual rules of poker by assuming all hands of equal rank are equivalent, with no "high card" rules. Under this simplification, for example, any two "one pair" hands tie without regard to the rank of the cards, so a pair of aces would be the same as a pair of eights. You may implement the high card rules if they interest you or if you want to have a useful tool handy the next time you play poker, but they aren't required for this assignment. Likewise, we don't need you to implement betting or a GUI here to make a full poker app.
This is the skeleton code:
Explanation / Answer
read and write in from the spreadsheet in vba.net with example
example1:
Imports Microsoft.Office.Interop.Excel
using System;
using SpreadsheetGear1;
name Program{
class Program{
static void Main(string[] args){
Dim workbook1 = ExcelFile.Load("Workbook1.xls")
Dim worksheet1 = workbook.Worksheets.ActiveWorksheet
worksheet1.Cells("B5").Value = "Hello world!"
workbook1.Save("NewWorkbook1.xls")
}
}
}
example2
Imports Microsoft.Office.Interop.Excel
Module Module12
Sub Main12()
' Create the new Application.
Dim excel1 As Application = New Application
' Open the Excel spreadsheet.
Dim w1 As Workbook = excel1.Workbooks.Open("C:ile1.xls")
' Loopthe over all sheets.
For i As Integer = 1 To w1.Sheets.Count
' Get the sheet.
Dim sheet1 As Worksheet = w1.Sheets(i)
' Get the range.
Dim r1 As Range = sheet1.UsedRange
' Load all cells into 2d array.
Dim array1(,) As Object = r1.Value(XlRangeValueDataType.xlRangeValueDefault)
' Scan the cells.
If array1 IsNot Nothing Then
Console.WriteLine("Length: {0}", array1.Length)
' Get bounds of the array.
Dim bound01 As Integer = array1.GetUpperBound(0)
Dim bound11 As Integer = array1.GetUpperBound(1)
Console.WriteLine("Dimension 0: {0}", bound01)
Console.WriteLine("Dimension 1: {0}", bound11)
' Loop over all elements.
For j As Integer = 1 To bound0
For x As Integer = 1 To bound1
Dim s12 As String = array1(j, x)
Console.Write(s12)
Console.Write(" "c)
Next
Console.WriteLine()
Next
End If
Next
' Close.
w1.Close()
End Sub
End Module
exampl3:
DimobjEXCELConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=EXCLE_FILE_PATH;
Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
ExcelConnection.Open()
Dim excelobjQuery As String = "SELECT * FROM [ExcelSheet1$]" 'get values from excelsheet1, here you can change that your sheet name
Dim excelobjCMD As OleDbCommand = New OleDbCommand(objQuery,objEXCELCon)
Dim excelobjDR As OleDbDataReader
Dim SQLconnection As New SqlConnection()
Dim szCON1 As String = "Connection the string for database"
SQLconnection.ConnectionString = szCON1
SQLconnection.Open()
Using bulkCopy1 As SqlBulkCopy = New SqlBulkCopy(SQLConnection)
bulkCopy1.DestinationTableName = "TableToWriteToInSQLSERVER"
Try
objDR1= excelobjCMD.ExecuteReader
bulCopy1.WriteToServer(objDR1)
objDR1.Close()
SQLConnection.Close()
Catch ex1 As Exception
MsgBox(ex1.ToString)
End Try