Skip to content

Commit

Permalink
Some minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorvaldAagaard committed Oct 8, 2023
1 parent 2852e27 commit 0698863
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 17 deletions.
4 changes: 4 additions & 0 deletions demo/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,10 @@ class Auction {
for (const element of bids) {
this.paddedBids.push(element['bid'])
}
this.auctionString = ''
for (var i = 0; i < bids.length; i++) {
this.auctionString += bids[i]['bid'].replace("PASS", "P") + " "
}
}

render(element) {
Expand Down
10 changes: 5 additions & 5 deletions install/build.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:: These builds are for windows
pyinstaller ..\src\appserver.py --onefile --path=..\src --add-data ..\src\frontend;frontend
pyinstaller ..\src\game.py --onefile --path=..\src --add-binary C:\\Python311\\Lib\\site-packages\\endplay\\_dds\\dds.dll;.
pyinstaller ..\src\gameserver.py --onefile --path=..\src --add-binary C:\\Python311\\Lib\\site-packages\\endplay\\_dds\\dds.dll;.
pyinstaller ..\src\table_manager_client.py --onefile --path=..\src --add-binary C:\\Python311\\Lib\\site-packages\\endplay\\_dds\\dds.dll;.
pyinstaller ..\src\calculate_DCWER.py --onefile --path=..\src --add-binary C:\\Python311\\Lib\\site-packages\\endplay\\_dds\\dds.dll;.
pyinstaller ..\src\calculate_DDOLAR.py --onefile --path=..\src --add-binary C:\\Python311\\Lib\\site-packages\\endplay\\_dds\\dds.dll;.
pyinstaller ..\src\game.py --onefile --path=..\src --add-binary ..\bin\dds.dll;.
pyinstaller ..\src\gameserver.py --onefile --path=..\src --add-binary ..\bin\dds.dll;.
pyinstaller ..\src\table_manager_client.py --onefile --path=..\src --add-binary ..\bin\dds.dll;.
pyinstaller ..\src\calculate_DCWER.py --onefile --path=..\src --add-binary ..\bin\dds.dll;.
pyinstaller ..\src\calculate_DDOLAR.py --onefile --path=..\src --add-binary ..\bin\dds.dll;.
2 changes: 1 addition & 1 deletion install/table_manager_client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ block_cipher = None
a = Analysis(
['..\\src\\table_manager_client.py'],
pathex=['..\\src'],
binaries=[('C:\\\\Python311\\\\Lib\\\\site-packages\\\\endplay\\\\_dds\\\\dds.dll', '.')],
binaries=[('..\\bin\\dds.dll', '.')],
datas=[],
hiddenimports=[],
hookspath=[],
Expand Down
2 changes: 1 addition & 1 deletion scripts/training/bidding/bidding_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ def to_numeric(value, default=0):

with open(infnm, 'r') as file:
lines = file.readlines()
n = len(lines)
n = len(lines) // 2
create_binary(load_deals(lines), n, outdir, ns, ew)

15 changes: 9 additions & 6 deletions src/bba/BBA.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@

EPBot_PATH = os.path.join(BIN_FOLDER, EPBot_LIB)

# Load the .NET assembly
clr.AddReference(EPBot_PATH)

# Import the types and classes from the assembly
from EPBot86 import EPBot

#The error you're encountering suggests that the info_meaning property is not directly accessible as an attribute in the EPBot class. Instead, you should use the get_info_meaning and set_info_meaning methods that are automatically generated for properties with a getter and setter in .NET.


Expand Down Expand Up @@ -80,6 +74,15 @@ class BBABotBid:
]

def __init__(self, ns_system, ew_system, position, hand, vuln, dealer):
try:
# Load the .NET assembly and import the types and classes from the assembly
clr.AddReference(EPBot_PATH)
from EPBot86 import EPBot
except Exception as ex:
# Provide a message to the user if the assembly is not found
print("Error: Unable to load EPBot86.dll. Make sure the DLL is in the ./bin directory")
print("Make sure the dll is not blocked by OS (Select properties and click unblock)")
print('Error:', ex)
self.ns_system = ns_system
self.ew_system = ew_system
self.vuln = vuln
Expand Down
6 changes: 3 additions & 3 deletions src/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def __init__(self, models, factory, sampler, verbose):
self.verbose = verbose
self.play_only = False

def set_deal(self, board_number, deal_str, auction_str, ns, ew, play_only):
def set_deal(self, board_number, deal_str, auction_str, ns, ew, play_only = None):
self.board_number = board_number
self.deal_str = deal_str
self.hands = deal_str.split()
self.deal_data = DealData.from_deal_auction_string(self.deal_str, auction_str, ns, ew, 32)
self.deal_data_52 = DealData.from_deal_auction_string(self.deal_str, auction_str, ns, ew, 52)

auction_part = auction_str.split(' ')
if len(auction_part) > 2: play_only = True
if play_only == None and len(auction_part) > 2: play_only = True
if play_only:
self.auction = self.deal_data.auction
self.play_only = play_only
Expand Down Expand Up @@ -561,7 +561,7 @@ async def main():
rdeal = random_deal()

# example of to use a fixed deal
rdeal = ('K4.T9876532.54.6 Q.KQ.AKQT7.AJ853 972.A4.J83.KQT74 AJT8653.J.962.92', 'E N-S')
# rdeal = ('AQ9.543.6.AKJ876 762.A96.KQJ42.Q2 KJ83.KJ2.T753.T5 T54.QT87.A98.943', 'S Both')

driver.set_deal(None, *rdeal, ns, ew, False)
else:
Expand Down
9 changes: 9 additions & 0 deletions src/human.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from objects import Card, CardResp, BidResp


def is_numeric(value):
return isinstance(value, (int, float, complex))

def clear_screen():
print('\033[H\033[J')

Expand Down Expand Up @@ -198,6 +201,12 @@ async def async_play_card(self, trick_i, leader_i, current_trick52, players_stat

human_card = await self.get_card_input()

# If we just get a number it is a claim
# We need to validate the claim, so for now we just ignore the message

#if is_numeric(human_card):
# human_card = await self.get_card_input()

return CardResp(card=Card.from_code(human_card), candidates=candidates, samples=samples)


Expand Down
2 changes: 1 addition & 1 deletion src/pbn2ben.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def load(fin):
inside_auction_section = False
else:
# Convert bids
line = line.strip().replace('.','').replace("Pass","P").replace("Double","X").replace("Redouble","XX").replace('AP','P P P')
line = line.strip().replace('.','').replace("NT","N").replace("Pass","P").replace("Double","X").replace("Redouble","XX").replace('AP','P P P')
# Remove extra spaces
line = re.sub(r'\s+', ' ', line)
# Remove alerts
Expand Down

0 comments on commit 0698863

Please sign in to comment.