pdc_project/main.py
2025-05-20 20:04:09 +02:00

28 lines
No EOL
656 B
Python

import numpy as np
from transmitter import transmitter
from receiver import receiver
from channel import channel
# Define the alphabet
alphabet = (
'abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'0123456789 .'
)
# Example 40-character message
test_message = 'ERROR 404. Motivation not found. Retry .'
# Transmit
x = transmitter(test_message)
# Simulate channel
Y = channel(x)
# Receive
decoded_message = receiver(Y)
# Print results
print(f"Original message: {test_message}")
print(f"Decoded message: {decoded_message}")
print(f"Bit error rate: {(np.array(list(test_message)) != np.array(list(decoded_message))).mean():.4f}")