Slot Machines Project

M

mcccuklev

Hello i build project Slot Machine this project was inspired by Tech with Tim here's his code from this project how he implement that --> https://github.com/techwithtim/Python-Slot-Machine/blob/main/main.py .I changed the code of the project on my way but something is same but most of the things i tried to change to check if i understand the project well.I am looking for maybe another way to implement the structure of code and tell me if i've done something wrong , what i should do better or to add something more.

Code:
import random
MAX_VALUE = 100
MIN_VALUE = 1
ROWS = 3
COLUMNS = 3

symbols_count = {
    "A":2,
    "B":4,
    "C":5,
    "E":3,
    "F":2
}

symbols_values = {
    "A":2,
    "B":4,
    "C":5,
    "E":3,
    "F":2
}
def check_winnings(columns,bet_lines,bet,balance):
    first_column = []
    second_column = []
    third_columns = []
    for element in columns:
        if len(first_column) < 3:
            first_column.append(element)
        elif len(second_column) < 3:
            second_column.append(element)
        elif len(third_columns) < 3:
            third_columns.append(element)
    check_duplicates_first = set(first_column) # we make sets because if there's three characters same it will return only one but remove the two duplicates
    check_duplicates_second = set(second_column)
    check_duplicates_third = set(third_columns)

    if len(check_duplicates_first) == 1:
        print("Winning line is --> line one --<")
        balance += bet_lines * bet
        print(f"You got it this time ,now you have {balance}$")
        playagain(balance)
    elif len(check_duplicates_second) == 1:
        print("Winning line is --> line two <--")
        balance += bet_lines * bet
        print(f"You got it this time ,now you have {balance}$")
        playagain(balance)
    elif len(check_duplicates_third) == 1:
        print("Winning line is --> line three --<")
        balance += bet_lines * bet
        print(f"You got it this time ,now you have {balance}$")
        playagain(balance)
    elif len(check_duplicates_first) > 1 or len(check_duplicates_second) > 1 or len(check_duplicates_third):
        get_sum = bet_lines * bet
        balance = balance - get_sum
        print(f"You didn't get it try again ,now you have {balance}$")
        playagain(balance)




def spin_slot_machine(symbols):
    all_symbols = []
    columns = []
    length_of_spin = 9
    for symbol,symbol_count in symbols.items():
        for i in range(symbol_count):
            all_symbols.append(symbol)
    for i in range(length_of_spin):
        get_random = random.choice(all_symbols)
        columns.append(get_random)
    return columns 
def print_slot_machine(columns):
    first_row = ' | '.join(columns[0:3])
    second_row = ' | '.join(columns[3:6])
    third_row = ' | '.join(columns[6:9])
    print(first_row)
    print(second_row)
    print(third_row)






def deposit():
    while True:
        deposit_money = input("How much money would you like to deposit?: $")
        if deposit_money.isdigit():
            deposit_money = int(deposit_money)
            if deposit_money > 0:
                break
            else:
                print("You should deposit more than 0$")
        print("Enter a digit")
    return deposit_money 
def bet_on_lines():
    while True:
        lines = input("On how many lines would you like to bet(1-3)?: ")
        if lines.isdigit():
            lines = int(lines)
            if lines >= 1 and lines <= 3:
                break
            else:
                print("Number of lines should be between 1-3")
        print("Enter a number of lines")
    return lines


def get_bet():
    while True:
        bet = input("How much money would you like to bet on one line(1$-100$): ")
        if bet.isdigit():
            bet = int(bet)
            if bet <= MAX_VALUE and bet >= MIN_VALUE:
                break
            else:
                print("Money should be between 1-100$")
        else:
            print("Enter a digit")
    return bet 


def spin():
    balance = deposit()
    lines_number = bet_on_lines()
    while True:
        bet_money = get_bet()
        total_bet = bet_money * lines_number 
        if total_bet > balance:
            print(f"Your balance is {balance}$.Balance shoudn't be less than betting money , bet less!")
        else:
            break
    print(f"You are betting {total_bet}$ on {lines_number} lines.")
    slot_machine = spin_slot_machine(symbols_count)
    print_slot_machine(slot_machine)
    check_winnings(slot_machine,lines_number,bet_money,balance)
def playagain(balance):
    while True:
        answer = input("Do you want to play again(Press Enter or q to quit): ")
        if answer != "" or balance == 0:
            print(f"You left with {balance}$, Good Bye!")
            break
        else:
            if int(balance) > 0:
                lines_number = bet_on_lines()
                bet_money = get_bet()
                slot_machine = spin_slot_machine(symbols_count)
                print_slot_machine(slot_machine)
                check_winnings(slot_machine,lines_number,bet_money,balance)
                break





spin()
 

Unreplied Threads

Create a Php application

  • Guda Gowthami
  • Main Forum
  • Replies: 0
Create a PHP application to insert and then retrieve the following employee details of a company from the database and display. (i) Employee ID (ii) First Name (iii) Last Name (iv) Age (v) Net Pay

Are confidentality agreements in memoirs lifetime?

I gave a talk in the most valued national conference of my field (Operations Research) during the first year of my MSc in 2018. I kept working hard, dedicating my life to research during the final year at a French CAC40 company Research and Development lab and signed for the following confidentiality note within my memoir:

Code:
This memoir is confidential. Therefore, any difusion of its content outside the Master
Parisien de Recherche Opérationnelle’s professorship or the DASSAULT SYSTEMES’
personnel is strictly forbidden. All information in this document is the exclusive
intellectual property of DASSAULT SYSTEMES. Any receiver of this document cannot
communicate its content without written authorization of DASSAULT SYSTEMES.
ENHANCED PRIVACY
DASSAULT SYSTEMES CONFIDENTIAL 2019
ANY REPLICATION, MODICIATION OR PUBLICATION IS STRICTLY FORBIDDEN
THIS REPORT MUST BE RETURNED TO THE COMPANY AFTER EVALUATION BY THE
JURY

At that moment of my scholarity, I had no idea how valuable my memoir was. I graduated from my MSc with honours, pursued in this very field during my thesis and I am still dedicating myself for operations research and to publish during my post-doc with the aim to be an assistant professor, hopefully.

Will I be allowed to publish my 2019 MSc memoir online at some point? Is the confidential note from 2019 expirable? We are more than 5 years later, I guess my ex-company published those results on international journals now, though I did not search it. Another side question: is it important to search the litterature for it?

No me funciona la paleta del ColorSchemeSeed en Flutter

Hola a penas estoy comenzando con Flutter y estoy tratando de hacer que mi AppBar coja el color primario dado un color con la propiedad ColorSchemeSeed sin embargo ponga el color que ponga siempre me sale un color similar al índigo por defecto como se muestra en la imagen

El AppBar toma un color distinto al del ColorSchemeSeed

El código que tengo hasta es el siguiente:

Code:
    import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    final colorApp = Theme.of(context).colorScheme;

    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
        useMaterial3: true,
      ),

      home: Scaffold(
        appBar: AppBar(
          title: const Text('AppBar'),
          backgroundColor: colorApp.primary,
        ),

        body: Center(
          child: Text(
            'Hola mundo',
            style: TextStyle(
              fontSize: 50,
              color: colorApp.primary,
            ),
          ),
        ),
      ),
    );
  }
}

Si alguien pudieses ayudarme se lo agradecería. Ya he hecho también FullRestat incluso desinstalar e instale la aplicación y nada

¿Como obtener el primer registro de una tabla?

Espero me puedan apoyar comunidad, estoy realizando la siguente consulta:

Code:
SELECT
 CB.Codigo as 'Codigo/UPC',
 CB.SubCuenta,
 CB.Cuenta
FROM InvD
JOIN Inv as I on I.ID = InvD.ID
JOIN CB on InvD.SubCuenta = CB.SubCuenta and InvD.Articulo = CB.Cuenta
WHERE I.FechaEmision >= '2023-05-01' and I.MovID = 'CHOQR6' and I.Mov = 'Recibo Traspaso'

En esta consulta de arroja 44 registros pero vienen duplicados, por que con el join hacia CB es donde me arroja:

Code:
select * from CB where Cuenta = '570338139CIW03' and CB.SubCuenta = 'C42T79'

introducir la descripción de la imagen aquí

Los cuales son los mismo dos resultados que me da en mi consulta principal introducir la descripción de la imagen aquí

Y asi me va duplicando por cada registro cuando hay mas de uno en la tabla de CB, ¿Hay alguna manera de que me traiga el primer registro de cada uno ? Para no tener duplicados, se los agradecería mucho si pudieran ayudarme.

Yo trate de realizar una subconsulta en el join

Code:
select top 1 Codigo, Cuenta, SubCuenta from CB as Cod where CB.Codigo = Cod.Codigo and 
CB.Cuenta = Cod.Cuenta and Cod.SubCuenta = CB.SubCuenta

pero no tuve el resultado que quería.

Time periodic Euler flows

What are some examples of solutions to the incompressible Euler equation on the torus $u:\mathbb{R}\times \mathbb{T}^d\rightarrow \mathbb{R}$ (with $d\in \{2,3\}$) $$\partial_t u+u\cdot \nabla u +\nabla p=0,\ \text{div}\ u=0$$ with the property that their flow is time-periodic? In other words, if you look at solutions of $$\partial_t \phi(t,x) =u(t,\phi(t,x))$$ then $\phi$ is time-periodic.

In fact I don't need such a strong property, I'd be happy even if they were periodic only for initial data $\phi(0,x)=x$.

PIC32MZ not detecting when quadrature encoder is turned

  • MXVG
  • Physics
  • Replies: 0

My Problem​


I'm trying to interface a quadrature encoder, this one, to a PIC32MZ. I made a simple test to check the functionality of the encoder, but I cannot get the Input Capture peripheral of the PIC32 to detect the rising edges of encoder channel A or B pwm signals.

I'm using the Curiosity PIC32MZ EF 2.0 Development Board with MPLABX IDE and Harmony library.

Because I'm using MPLABX IDE with Harmony, assume all PIC32 periphals are configured correctly.



I have 2 Input Capture Peripherals, ICAP7 and ICAP8, connected to channels A and B of the encoder.

For each of the Input Captures the following settings have been applied:

  • Simple Capture Event mode every rising edge
  • 16 bit timer resource capture
  • Enable Capture Interrupt

The test I have tried to implement is depicted in the following diagram: enter image description here

Below is the code written on the PIC32 to implement the test:

Code:
ICAP7_Initialize(); //From library
ICAP7_Enable(); //From library

//Set LED Pin to Output
GPIO_RJ7_OutputEnable(); //From library

//Call encoderTurned on inturrupt
ICAP7_CallbackRegister(encoderTurned, (uintptr_t)NULL); //From Library

encoderTurned function:

Code:
void encoderTurned(uintptr_t context){

    GPIO_RJ7_Toggle(); //From library
}

JavaScript text editor component with line numbers and CR/LF indication?

In many text editors there are line numbers, and a possibility for visual line end indication; for instance in Scite, you can do View/End of Line, and you get something like this:

scite screenshot

As the screenshot image shows, Scite can correctly indicate on each line if the line ending is CRLF (\r\n), LF (\n) or CR (\r).

I would like the same functionality but for JavaScript - something that I can use for basis of further development for an online code editor; the crucial functionality being:

  • Shows line numbers for text (correctly when long lines are soft-wrapped by the editor)
  • Text and line numbers shown in monospace font by default (possibility to change monospace font is nice, but not crucial)
  • Possibility to indicate line endings CRLF (\r\n), LF (\n) or CR (\r) visually;
  • Preserves original line endings, regardless of what they are, when copy-pasting text
  • Possibility to react with a handler on keyboard key press, and process the existing text based on the text cursor position, before the character corresponding to the keyboard key is actually inserted in the text

I've tried looking up for some libraries or components online that can do all of this out of the box, but haven't found much; for instance, I've found https://quilljs.com/, but since it is a rich text editor, line numbering seems to be tricky, I've only found this discussion Is it possible to show line numbering next to editor? · Issue #2756 · slab/quill which seems to be unresolved.

So, is there a JavaScript library/component that has the above mentioned features out of the box?
Top