Anyone playing simulation games for bitcoins here?

As everyone knows the cryptocurrency mining simulation game Rollercoin has been around for almost 5 years and the profit is getting lower and lower due to the block reward being reduced while we invest too much money.

There is a new simulator 8 months old now – will list BMT tokens in 2022. Lots of preference for newbies. Especially, the furnace worker is 5 times cheaper than the Rollercoin game.

The most expensive miner in the store costs 0.5 btc and will payback in 3 months. Everyone join and enjoy. I have been withdrawing to Pay.eer regularly. Investment channel is really very profitable:

Register by the link get 3 free miners:

enter image description here

enter image description here

simulation – Looking for a multi-processor job scheduling strategy simulator

I hope this is the appropriate Stack Exchange site for questions like this.

Recently, a college student and I are looking for a robust software for simulating process scheduling in multi-processor environments, capable of generating statistics and supporting user-created strategies.

So far, we have been able to find several published articles whose conclusions were drawn from particular and/or at least questionable snippets of code. The software we have found so far that best present the desired characteristics are ALEA, AnimOS, and MOSS.

In the search for such piece of software, we also came across ones aimed at Multiprocessor Scheduling Simulators, which is not particularly our focus, but which are worth mentioning: SimSo, S.T.O.R.M, and YARTISS.

I would like to have suggestions from you so that we can continue with our research. We are looking for professional sized software, with revised implementations and adhering to the formal techniques described in the literature. Thanks in advance!

Simulation of tin penetration in the float glass process

Simulation of tin penetration in the float glass process 
The flat glass produced by the float glass process has a tin-rich surface due to the contact with molten tin. The penetration of tin into the glass surface is assumed to involve coupled diffusion of stannous (Sn2+) and stannic (Sn4+) ions. The diffusion coefficients of these ions were calculated using the modified Stocks–Einstein relation with the oxidation velocity of stannous ions depending on the oxygen activity in the glass. The ion diffusion was analyzed using a coupled diffusion simulation with a modified diffusion coefficient to compensate for the negative effect of the glass ribbon’s stretching or compressing in the glass forming process. Tin penetration simulations for both green glass and clear glass show an internal local tin concentration maximum in green glass which is quite different from that in clear glass. The local maximum in the profile is associated with the accumulation of stannic ions where the greatest oxygen activity gradient occurs. Since more float time is needed in the manufacture of thicker glass plate, the tin penetrates to a greater depth with the maximum deeper in the glass and the size of the maximum larger for thicker glass.
The float glass process, which was originally developed by Pilkington Brothers in 1959 (Haldimann et al., 2008), is the most common manufacturing process of flat glass sheets. More than 80–85% of the global production of float glass is used in the construction industry (Glass for Europe, 2015a). In the float glass process, the ingredients (silica, lime, soda, etc.) are first blended with cullet (recycled broken glass) and then heated in a furnace to around 1600°C to form molten glass. The molten glass is then fed onto the top of a molten tin bath. A flat glass ribbon of uniform thickness is produced by flowing molten glass on the tin bath under controlled heating. At the end of the tin bath, the glass is slowly cooled down, and is then fed into the annealing lehr for further controlled gradual cooling down. The thickness of the glass ribbon is controlled by changing the speed at which the glass ribbon moves into the annealing lehr. Typically, glass is cut to large sheets of 3 m × 6 m. Flat glass sheets of thickness 2–22 mm are commercially produced from this process. Usually, glass of thickness up to 12 mm is available in the market, and much thicker glass may be available on request. A schematic diagram of the production process of float glass is shown in Fig. 5.2.The float glass process was invented in the 1950s in response to a pressing need for an economical method to create flat glass for automotive as well as architectural applications. Existing flat glass production methods created glass with irregular surfaces; extensive grinding and polishing was needed for many applications. The float glass process involves floating a glass ribbon on a bath of molten tin and creates a smooth surface naturally. Floating is possible because the density of a typical soda-lime-silica glass (~2.3 g/cm3) is much less than that of tin (~6.5 g/cm3) at the process temperature. After cooling and annealing, glass sheets with uniform thicknesses in the ~1–25 mm range and flat surfaces are produced. The ultra clear float glass process is used to produce virtually all window glass as well as mirrors and other items that originate from flat glass. Since float glass is ordinarily soda-lime-silica, the reference temperatures and behavior of this glass are used in the discussion below.

Figure 3.48 shows the basic layout of the clear float glass line. The glass furnace is a horizontal type, as described above. For a float line, the glass furnace is typically on the order of ~150 ft long by 30 ft wide and holds around 1200 tons of glass. To achieve good chemical homogeneity, the glass is heated to ~1550–1600°C in the furnace, but is then brought to about 1100–1200°C in the forehearth. From there, the glass flows through a channel over a refractory lipstone or spout onto the tin bath. As it flows, the glass has a temperature of about 1050°C and viscosity of about 1000 Paradical dots. A device, called a tweel, meters the flow of the molten glass.Imperfections include bubbles (or ‘seeds’) that may have a number of possible sources, the most common being gas evolved during firing. Bubbles may contain crystalline materials formed during cooling of the glass that may provide clues to the origin of the bubbles. Cords are linear features within the glass that may result either from imperfectly homogenized raw materials, dissolved refractories or devitrified material. Figure 360 shows the appearance of soda–lime–silica glass that exhibits bubbles and cords. ‘Stones’ are solid crystalline substances occurring in glass that are regarded as defects. They are usually derived either from the batch material, refractories, or devitrification. Figure 361 shows the appearance of soda–lime–silica glass that contains a devitrification ‘stone’. These may develop as the result of incomplete mixing of the molten glass constituents and/or too low a firing temperature. The ‘stone’ shown in Figure 361 contains an aggregation of tridymite crystals (see 362).
As the floating glass ribbon traverses down the length of the tin bath, its properties change dramatically. The glass enters as a viscous liquid and exits virtually a solid at a temperature very close to its glass transition temperature. The details of how the temperature changes and the viscosity builds are complicated. On one side, the free surface of the glass is exposed the atmosphere; heat can leave this surface by radiation or convection. Cooling and heating apparatuses are stationed above the glass ribbon down the length of the bath to allow adjustment of the ribbon temperature. On the other side, the glass is in contact with the tin bath, which can absorb some of the heat and transport it away from the ribbon. The tin bath is in constant motion due to the moving glass above it as well as the thermal convection currents. Unfortunately, no simple approximations can be made to make the modeling of the heat transfer.

The thickness of the tinted float glass sheet is adjusted by controlling flow onto the tin bath as well as by tension exerted along the length of the bath by rollers in the annealing lehr and sometimes by rollers in the bath unit itself. In the Pilkington design, the melt enters the bath and spreads out laterally to a thickness near the equilibrium value. If a sheet thicker than the equilibrium is required, then this spreading is constrained with physical barriers. If a sheet thinner than equilibrium is needed. then the glass ribbon is pulled in tension by rollers. In the PPG design, thickness is regulated by the tweel position and by tension from rollers in the lehr. The thermal profile allows the thinning deformation to take place effectively. A short distance away from the entry point, the temperature of the ribbon drops and the viscosity rises. Overhead coolers help this process. The glass viscosity is high enough so that knurled rollers contact the glass ribbon and pull it forward (and in some operations, laterally as well). Heaters are placed shortly downstream of these edge rollers to raise the temperature of the ribbon and create a deformable zone. This zone is followed by coolers that again lower the temperature and raise the viscosity. At exit from the lehr, the ribbon is virtually solid. The main deformation is due to the rollers in the lehr, which pull on the glass ribbon from the lehr to the edge rollers; extension takes place in the deformation zone. Example 3.15 considers the exit velocity of glass from the process.
For many years, however, the glass industry has been trying to solve a problem which affects almost every building in the world. How do you maintain the fundamental characteristics of glass, such as optical clarity and external esthetics without constant and costly maintenance? Whether the building is for commercial or residential use, the one constant requirement is for regular cleaning to be undertaken to ensure the glass maintains its optimum appearance.
The challenge for the glass industry is increased as a result of architects finding ever more resourceful and novel uses for glass. The use of glass in atria and overhead glazing can sometimes result in complex areas, which can make maintenance more difficult.
In addition to the esthetic issues it is a well-known phenomenon that if glass is not cleaned regularly then over a period of time the glass can weather, which makes it almost impossible to restore its esthetic properties. In extreme circumstances this can lead to the glass needing replacement.
The process of cleaning windows can also lead to safety and environmental issues. Window cleaning generally involves the use of portable ladders for cleaning windows on ground, first, and second floors. Figures for accidents reported to the Health and Safety Executive (HSE) and local authorities reveal that unfortunately between two and seven window cleaners have been killed every year in Great Britain and around 20–30 suffer major injuries due to falls involving ladders. From an environmental aspect window cleaning can involve the use of harsh chemicals. These are often washed off during the cleaning process and can ultimately lead to ground contamination.
Recently, self-cleaning coatings have been developed, which are designed to reduce the amount of maintenance required by working with the forces of nature to clean dirt from the glass. These coatings are based on a well-known metal oxide called titanium dioxide, which is regularly used in paints, toothpaste, and sunscreens.
Tin is an ideal bath material because it has the right set of physical properties. Tin melts at 232°C, has relatively low volatility, and does not boil until over 2000°C. Molten tin is denser than molten glass and is not miscible or reactive with molten glass. The gas atmosphere is controlled so that tin does not oxidize at a fast rate. Any oxide that does form is collected in a dross container on the bath.
Regulating the flow of the wired glass is important at this stage, both from the entry point and the lateral flow. The glass flow onto the tin bath is regulated by a gate, called a tweel, which is located in the canal between the forehearth and spout. The glass flows down the spout or lipstone onto the tin surface. There is some pressure driving this flow through the gap of the tweel. See Example 3.14. As the glass flows onto the tin bath, the thickness of the glass sheet depends on how that flow is controlled laterally and along the length of the bath. The first step to understanding thickness control is to examine the equilibrium thickness.

shaders – Faster Alternatives to Jacobi Pressure Solving in Navier Stokes Simulation

While Jacobi itself is quite simple it needs at least 10 iterations to produce acceptable results. However that results in a higher total time cost than the rest of the Navier Stokes Simulation together.

Are there any other ways to compute pressure with less steps? Since in my case it is purely visual I prefer performance over accuracy (as long as it looks acceptable)

example Jacobi Solver I am using:

float pN = tex2D(_Pressure, IN.uv + float2(0, _InverseSize.y)).x;
float pS = tex2D(_Pressure, IN.uv + float2(0, -_InverseSize.y)).x;
float pE = tex2D(_Pressure, IN.uv + float2(_InverseSize.x, 0)).x;
float pW = tex2D(_Pressure, IN.uv + float2(-_InverseSize.x, 0)).x;
float pC = tex2D(_Pressure, IN.uv).x;

float bN = tex2D(_Obstacles, IN.uv + float2(0, _InverseSize.y)).a;
float bS = tex2D(_Obstacles, IN.uv + float2(0, -_InverseSize.y)).a;
float bE = tex2D(_Obstacles, IN.uv + float2(_InverseSize.x, 0)).a;
float bW = tex2D(_Obstacles, IN.uv + float2(-_InverseSize.x, 0)).a;

if(bN > 0.5) pN = pC;
if(bS > 0.5) pS = pC;
if(bE > 0.5) pE = pC;
if(bW > 0.5) pW = pC;

float bC = tex2D(_Divergence, IN.uv).x;

float p = (pW + pE + pS + pN + _Alpha * bC) * _InverseBeta;

float2 uvmasks = min(IN.uv, 1.0 - IN.uv);
p = any(uvmasks <= _Border) ? 0.0 : p;

return p;

stochastic processes – Python Monte Carlo simulation for certainty equivalent

I am trying to compute certainty equivalent using monte carlo simulation.
I have the following dynamics


all the constants are given and pi_star is the optimal trading strategy given in the question, I am trying to compute certainty equivalent for different values of kappa and eta, the code runs fine but I know the results are not in the right range.

Can anyone spot anything that I might be doing wrong?

I am quite new to programming so sorry if the mistake is obvious.


import numpy as np

def MCforCE(r,mu,kappa,eta,rho,gamma,theta,T,n_steps,n_paths):
    sigma = np.zeros((n_paths,n_steps+1))
    S = np.zeros((n_paths,n_steps+1))
    X = np.zeros((n_paths,n_steps+1))
    dt = T/n_steps
    for j in range(0, n_steps):
        eps_1 = np.random.randn(n_paths,n_steps)
        eps_2 = np.random.randn(n_paths,n_steps)
        dW = np.zeros((n_paths,n_steps))
        dZ = np.zeros((n_paths,n_steps))        
        dW(:,j) = np.sqrt(dt) * eps_1(:,j)
        dZ(:,j) = rho*dW(:,j) + np.sqrt(1-rho**2)*np.sqrt(dt) * eps_2(:,j)
        for i in range(0, n_steps):
    return CE
x_pi = MCforCE(0.01,0.05,1,3,-0.5,0.8,0.2,1,365,1000)


simulation – Setting a long vector of summary statistics in easyABC R package

I’m running simulations based in R with easyABC.

These simulations rope in several different programmes (dadi, SPLATCHE3 – a demographic simulator) through the input script, all of which are not producing errors and do create the correct output files. It contains 4 individuals to be simulated.

As part of the easyABC rejection algorithm I must set a vector prior summary statistics for the algorithm to test its own results against. In toy models, I have set 4 summary statistics, one for each individual, i.e:

sum_stat_obs = c(8, 8, 6, 4)

Now for the real model, I want to set a vector of summary statistics that is much longer (the summary statistic chosen is the site frequency spectrum), i.e:

sum_stat_obs = c(0.002,0.0003,0.000566,0.007,0.0002,0.0005,0.0002,0.0005,0.0007,0.0008,0.0009,0.0005,0.0003,0.0005,0.00022,0.00055,0.000099)

However when I run the command:

abc_sim2 = ABC_rejection(
  model = binary_model('~/'),
  prior = prior, #the model priors
  nb_simul = 13000, #number of simulations
  summary_stat_target = sum_stat_obs, #summary statistics
  tol = 0.5 #how many simulations should be saved
# verbose = T

It runs the simulations, gets to the end of however many I run, and produces the error:

Error in abc(summary_stat_target, rejection$param, rejection$stats, tol,  : 
Number of summary statistics in 'target' has to be the same as in 'sumstat'

When I switched it back to 4 sum_stat_obs, this error was not produced, so I think it is linked to the targeted number of individuals simulated. The argument ‘target’ is not accessible in the above command.

Further, the ‘abc’ package is called in this error, even though it was not called in the original command. The packages ‘easyABC’ and ‘abc’ can be used in conjunction with one another, however.

Is there any way to get round this error so I can have the longer vector of sum_stat_obs WITHOUT increasing the number of individuals simulated?

2d – Drawing multiple simulation ticks in a single render frame

I have a 2D fixed-timestep simulation (a bunch of moving sprites) that ticks several times per render frame.

I would like to render the state of each tick, so that all the ticks between render frames A and A+1 contribute to the image at A+1: a discrete approximation of motion blur. I assumed this would be trivial, but so far I’m pretty stumped!

My current approach is: given N sim ticks, draw the sprites at each tick with alpha = 1/N. However, so far this feels like it’s not the correct approach, and I was hoping someone here could point me in the right direction.

I’ve tried alpha compositing (ie equivalent to (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)), but this doesn’t work: the sprites all become somewhat transparent, because by definition if you alpha-composite N images which have alpha < 1, you’ll always get some background colour blended into the result.

Then I tried additive blending (ie (GL_ONE, GL_ONE)): this produces the correct result in isolation (ie a stationary sprite is drawn fully opaque, since it gets drawn N times with 1/N alpha; a moving sprite is opaque where all its ticks overlap, and transparent at the edges where only some ticks overlap), however if there’s anything behind the sprites (which there will be – ie sprites moving through each other, a parallax background, etc.) then the additive blend ruins this by making everything over-bright.

Am I missing something basic?? This seems like it should be pretty straightforward, but so far all I can think of is that I would need to composite things in multiple steps: for each sprite, use additive blending to render it into a buffer, then alpha-composite that buffer with the rest of the scene.

Is that really the best I can do? It seems ugly and complicated; why shouldn’t I be able to draw the background image, along with everything else in the scene, N times with 1/N alpha?

Everything I’ve found via google is for pixel shaders which approximate motion blur per-object via multisampling. In my case, I already have the scene multi-sampled, I just don’t understand how to correctly blend all the samples together!

Anyway, any tips or pointers are greatly appreciated! Thanks. : )

research – Evidence of phishing simulation effectiveness?

research – Evidence of phishing simulation effectiveness? – Information Security Stack Exchange

python – Fantasy Football (Soccer) Simulation

What my program does

My program does simulation for fantasy football. Its inputs are teams and teams results in a particular match and its outputs are how many points each team earned in each match according to given scoring rules.

Here is an example of a team:

team1 = (
    calculate_points.Player(p_id=204597, full_name='Jordan Pickford', club='ENG', 
                              position='goalkeeper', is_captain=True, 
                              is_vice_captain=False, points=0.0),          
    calculate_points.Player(p_id=213442, full_name='Luke Shaw', club='ENG', 
                              position='defender', is_captain=False, 
                              is_vice_captain=True, points=0.0), 
    calculate_points.Player(p_id=204614, full_name='Harry Maguire', club='ENG', 
                              position='defender', is_captain=False, 
                              is_vice_captain=False, points=0.0), 
    calculate_points.Player(p_id=204615, full_name='Mason Mount', club='ENG', 
                              position='midfielder', is_captain=False, 
                              is_vice_captain=False, points=0.0), 
    calculate_points.Player(p_id=204617, full_name='Harry Kane', club='ENG',
                              position='forward', is_captain=False, 
                              is_vice_captain=False, points=0.0),

And an example of a team result:

team_result1 = calculate_points.TeamResult(
    scored_goals=('Harry Kane'), 
    made_assist=('Kalvin Phillips'), 
    played60=('Jordan Pickford', 'Luke Shaw', 'John Stones', 'Harry Maguire',  
               'Kieran Trippier', 'Kyle Walker', 'Kalvin Phillips', 
               'Raheem Sterling', 'Declan Rice', 'Harry Kane'), 
    finished_game=('Jordan Pickford', 'Luke Shaw', 'John Stones', 'Harry Maguire', 
                    'Kieran Trippier', 'Kyle Walker', 'Kalvin Phillips', 
                    'Mason Mount', 'Harry Kane'), 
    got_booked=('Kyle Walker'), 
    made_shots_on_tg=('Harry Kane', 'Harry Kane', 'Raheem Sterling', 
                       'Mason Mount', 'Harry Kane'), 

What kind of feedback I would like to get

The heart of the program is get_team_points() function which calculates how many points a team earned in a given match by adding points earned by each player in the team.

To be able to perform high-throughput simulations it has to work as fast as possible. With that in mind I’m looking for a way to achieve that.

Since I don’t have any limitations of what can be used to do that, I’m open to any suggestions including refactoring existing code, using third-party libraries, writing C/C++ extensions or even rewriting the program in another language.

Any other feedback beyond performance is also appreciated.

What I have already tried

  • reducing the size of TeamResult object, I tried to use list of players ids instead of their fullnames.
  • eliminating some function calls, I tried removing functions for calculating player points per position, such as calculate_goalkeeper_points(), calculate_defender_points(), calculate_midfielder_points() and calculate_forward_points() in order to do that in a single function for all the players.
  • using Cython for making calculate_team_points() function precompiled and importing it as C extension.

Though these steps didn’t gain any significant speed up.

My code, including a few unit tests

from dataclasses import dataclass
from typing import List


class Scoring:
    Represents football scoring.
    defender_goal: int=6
    midfielder_goal: int=5
    forward_goal: int=4
    assist: int=3
    defender_shot_on_tg: float=0.6
    midfielder_or_forward_shot_on_tg: float=0.4
    goalkeeper_save: float=0.5
    pos_impact: float=0.3
    neg_impact: float=-pos_impact
    yellow_card: int=-1
    defender_or_goalkeeper_clean_sheet: int=4
    midfielder_clean_sheet: int=1
    played60: int=2
    midfielder_or_forward_finished_game: int=1
scoring = Scoring()    

PlayerId = int
PlayerName = str
PlayerClub = str
PlayerPosition = str
Points = float

class Player:
    Represents a player in Fantasy Football.
    p_id: PlayerId
    full_name: PlayerName
    club: PlayerClub
    position: PlayerPosition
    is_captain: bool=False
    is_vice_captain: bool=False
    points: Points=0.0
Team = List(Player)
Teams = List(Team)    
class TeamResult:
    Represents the result of a particular team with its name, goals scored,
    goals conceded, players who scored goals and made assists and the number of
    saves made by the goalkeeper.
    team: PlayerClub
    goals_for: int
    goals_against: int
    scored_goals: List(PlayerName)
    made_assist: List(PlayerName)
    played60: List(PlayerName)
    finished_game: List(PlayerName)
    got_booked: List(PlayerName)
    made_shots_on_tg: List(PlayerName)
    saves: int

TeamResults = List(TeamResult)    

def get_team_points(team: Team, team_result: TeamResult) -> Points:
    Returns how many points the given team earned with the given team result.
    team = calculate_team_points(team, team_result)
    team = apply_captaincy(team)
    return sum(p.points for p in team)

def calculate_team_points(team: Team, team_result: TeamResult) -> Team:
    Assigns earned points for each player in the team.
    points_factory = {
        'goalkeeper': calculate_goalkeeper_points,
        'defender': calculate_defender_points,
        'midfielder': calculate_midfielder_points,
        'forward': calculate_forward_points,
    for player in team:
        player.points = points_factory(player.position)(player, team_result)
    return team

def calculate_goalkeeper_points(goalkeeper: Player, team_result: TeamResult) -> Points:
    Returns points earned by a goalkeeper.
    got_booked = scoring.yellow_card if goalkeeper.full_name in team_result.got_booked else 0
    goals_conceded = scoring.defender_or_goalkeeper_clean_sheet if team_result.goals_against == 0 else team_result.goals_against // 2 * -1
    impact = calculate_impact(team_result)
    saves = team_result.saves * scoring.goalkeeper_save
    playing_time = scoring.played60
    return sum((goals_conceded, impact, saves, playing_time, got_booked))

def calculate_defender_points(defender: Player, team_result: TeamResult) -> Points:
    Returns points earned by a defender.
    got_booked = scoring.yellow_card if defender.full_name in team_result.got_booked else 0
    goals_conceded = scoring.defender_or_goalkeeper_clean_sheet if team_result.goals_against == 0 else team_result.goals_against // 2 * -1
    impact = calculate_impact(team_result)
    playing_time = scoring.played60
    goals = team_result.scored_goals.count(defender.full_name) * scoring.defender_goal
    assists = team_result.made_assist.count(defender.full_name) * scoring.assist
    shots_on_tg = ((team_result.made_shots_on_tg.count(defender.full_name) - 
                   team_result.scored_goals.count(defender.full_name)) * scoring.defender_shot_on_tg)
    return sum((goals_conceded, impact, playing_time, goals, assists, 
                got_booked, shots_on_tg))

def calculate_midfielder_points(midfielder: Player, team_result: TeamResult) -> Points:
    Returns points earned by a midfielder.
    got_booked = scoring.yellow_card if midfielder.full_name in team_result.got_booked else 0
    clean_sheet = scoring.midfielder_clean_sheet if team_result.goals_against == 0 else 0
    impact = calculate_impact(team_result)
    playing_time = scoring.midfielder_or_forward_finished_game + scoring.played60 if midfielder.full_name in team_result.finished_game else scoring.played60
    goals = team_result.scored_goals.count(midfielder.full_name) * scoring.midfielder_goal
    assists = team_result.made_assist.count(midfielder.full_name) * scoring.assist
    shots_on_tg = ((team_result.made_shots_on_tg.count(midfielder.full_name) - 
                   team_result.scored_goals.count(midfielder.full_name)) * scoring.midfielder_or_forward_shot_on_tg)    
    return sum((clean_sheet, impact, playing_time, goals, assists, got_booked, 

def calculate_forward_points(forward: Player, team_result: TeamResult) -> Points:
    Returns points earned by a forward.
    got_booked = scoring.yellow_card if forward.full_name in team_result.got_booked else 0
    impact = calculate_impact(team_result)
    playing_time = scoring.midfielder_or_forward_finished_game + scoring.played60 if forward.full_name in team_result.finished_game else scoring.played60
    goals = team_result.scored_goals.count(forward.full_name) * scoring.forward_goal
    assists = team_result.made_assist.count(forward.full_name) * scoring.assist
    shots_on_tg = ((team_result.made_shots_on_tg.count(forward.full_name) - 
                   team_result.scored_goals.count(forward.full_name)) * scoring.midfielder_or_forward_shot_on_tg)    
    return sum((impact, playing_time, goals, assists, got_booked, shots_on_tg))

def calculate_impact(team_result: TeamResult) -> Points:
    Calculates impact for a team based on whether it won, lost or drew.
    if team_result.goals_for > team_result.goals_against:
        return scoring.pos_impact
    elif team_result.goals_for < team_result.goals_against:
        return scoring.neg_impact
    return 0

def apply_captaincy(team: Team) -> Team:
    Multiplies points of captain and vice_captain.
    for player in team:
        if player.is_captain:
            player.points *= CAPTAIN_BONUS
        elif player.is_vice_captain:
            player.points *= VICE_CAPTAIN_BONUS
    return team

import unittest
import calculate_points

team1 = (
    calculate_points.Player(p_id=204597, full_name='Jordan Pickford', club='ENG', 
                              position='goalkeeper', is_captain=True, 
                              is_vice_captain=False, points=0.0),          
    calculate_points.Player(p_id=213442, full_name='Luke Shaw', club='ENG', 
                              position='defender', is_captain=False, 
                              is_vice_captain=True, points=0.0), 
    calculate_points.Player(p_id=204614, full_name='Harry Maguire', club='ENG', 
                              position='defender', is_captain=False, 
                              is_vice_captain=False, points=0.0), 
    calculate_points.Player(p_id=204615, full_name='Mason Mount', club='ENG', 
                              position='midfielder', is_captain=False, 
                              is_vice_captain=False, points=0.0), 
    calculate_points.Player(p_id=204617, full_name='Harry Kane', club='ENG',
                              position='forward',  is_captain=False, 
                              is_vice_captain=False, points=0.0),

team_result1 = calculate_points.TeamResult(
    scored_goals=('Harry Kane'), 
    made_assist=('Kalvin Phillips'), 
    played60=('Jordan Pickford', 'Luke Shaw', 'John Stones', 'Harry Maguire',  
               'Kieran Trippier', 'Kyle Walker', 'Kalvin Phillips', 
               'Raheem Sterling', 'Declan Rice', 'Harry Kane'), 
    finished_game=('Jordan Pickford', 'Luke Shaw', 'John Stones', 'Harry Maguire', 
                    'Kieran Trippier', 'Kyle Walker', 'Kalvin Phillips', 
                    'Mason Mount', 'Harry Kane'), 
    got_booked=('Kyle Walker'), 
    made_shots_on_tg=('Harry Kane', 'Harry Kane', 'Raheem Sterling', 
                       'Mason Mount', 'Harry Kane'), 

team_result2 = calculate_points.TeamResult(
    scored_goals=('Raheem Sterling', 'Mason Mount'), 
    made_assist=('Substitutes', 'Luke Shaw'), 
    played60=('Jordan Pickford', 'Luke Shaw', 'John Stones', 'Harry Maguire', 
              'Kieran Trippier', 'Kyle Walker', 'Kalvin Phillips', 
              'Raheem Sterling', 'Mason Mount', 'Harry Kane'), 
    finished_game=('Jordan Pickford', 'Luke Shaw', 'John Stones', 
                   'Harry Maguire', 'Kieran Trippier', 'Kyle Walker', 
                   'Raheem Sterling'), 
    got_booked=('Jordan Pickford'), 
    made_shots_on_tg=('Harry Kane', 'Mason Mount', 'Mason Mount', 
                      'Substitutes', 'Harry Kane'), saves=2)

team_result3 = calculate_points.TeamResult(
    played60=('Jordan Pickford', 'Luke Shaw', 'John Stones', 'Harry Maguire', 
              'Kieran Trippier', 'Kyle Walker', 'Kalvin Phillips', 
              'Declan Rice', 'Harry Kane'), 
    finished_game=('Jordan Pickford', 'Luke Shaw', 'John Stones', 
                   'Harry Maguire', 'Kieran Trippier', 'Kyle Walker', 
                   'Kalvin Phillips', 'Declan Rice', 'Harry Kane'), 
    got_booked=('Luke Shaw', 'John Stones', 'Raheem Sterling', 'Mason Mount'), 
    made_shots_on_tg=('Harry Kane'), saves=2)

class TestGetTeamPoints(unittest.TestCase):
    def test_won_game_with_cleansheet(self):
        self.assertAlmostEqual(calculate_points.get_team_points(team1, team_result1), 44.15)
    def test_won_game_with_conceded_goal(self):
        self.assertAlmostEqual(calculate_points.get_team_points(team1, team_result2), 25.65)
    def test_lost_game_with_no_goals_scored(self):
        self.assertAlmostEqual(calculate_points.get_team_points(team1, team_result3), 7.45)
if __name__ == '__main__':

python – Simple enemy movement simulation on Tkinter

Kind of a noob at Python here, and this is one of my first “big”(big for a beginner like me) project that I undertook with Tkinter and Pynput. Basically, this code will simulate an enemy’s movement pattern based on some conditions that I made(you will be able to see the different “phases” being printed out on the console). You can then control the player using the arrow keys.

I would like some advice on what I should improve on for future projects. Should I add more comments? Is the code structured well? etc.

import math
import tkinter as tk
from pynput import keyboard
class Application:
    def __init__(self, master, height = 800, width = 800, updatesPerSecond = 10, safeCircle = True):
        self.height = height
        self.width = width
        self.root = master
        self.updatesPerSecond = updatesPerSecond
        self.player = Player()
        self.enemy = Enemy()
        self.safeCircle = safeCircle
        self.canvas = tk.Canvas(self.root, height = self.height, width = self.width)
        self.player_rectangle = self.canvas.create_rectangle(self.player.x-self.player.hLength, self.player.y-self.player.hLength, self.player.x+self.player.hLength, self.player.y+self.player.hLength)
        self.enemy_rectangle = self.canvas.create_rectangle(self.enemy.x-self.player.hLength, self.enemy.y-self.player.hLength, self.enemy.x+self.player.hLength, self.enemy.y+self.player.hLength)
        if self.safeCircle:
            self.safe_circle = self.canvas.create_oval(self.player.x-self.enemy.safe_distance, self.player.y-self.enemy.safe_distance, self.player.x+self.enemy.safe_distance, self.player.y+self.enemy.safe_distance)
        self.keypress_list = ()
        self.listener = keyboard.Listener(on_press = self.on_press, on_release = self.on_release)
    def player_movement(self):
        if "down" in self.keypress_list:
        if "up" in self.keypress_list:
        if "left" in self.keypress_list:
        if "right" in self.keypress_list:
        self.player.boundary_check(self.height, self.width)
        self.canvas.coords(self.player_rectangle, self.player.x-self.player.hLength, self.player.y-self.player.hLength, self.player.x+self.player.hLength, self.player.y+self.player.hLength)
        if self.safeCircle:
            self.canvas.coords(self.safe_circle, self.player.x-self.enemy.safe_distance, self.player.y-self.enemy.safe_distance, self.player.x+self.enemy.safe_distance, self.player.y+self.enemy.safe_distance)
        self.root.after(1000//self.updatesPerSecond, self.player_movement)
    def enemy_movement(self):
        self.enemy.boundary_check(self.height, self.width)
        self.canvas.coords(self.enemy_rectangle, self.enemy.x-self.enemy.length/2, self.enemy.y-self.enemy.length/2, self.enemy.x+self.enemy.length/2, self.enemy.y+self.enemy.length/2)
        self.root.after(1000//self.updatesPerSecond, self.enemy_movement)
    def key_test(self, key):
    def on_press(self, key):
        key = self.key_test(key)
        if not key in self.keypress_list:
    def on_release(self, key):
        key = self.key_test(key)

class SimObject:
    def __init__(self, x, y, speed, length):
        self.x = x
        self.y = y
        self.speed = speed
        self.length = length
        self.hLength = self.length/2
    def boundary_check(self, height, width):
        if self.x - self.hLength < 0:
            self.x = self.hLength
        if self.y - self.hLength < 0:
            self.y = self.hLength
        if self.x + self.hLength > width:
            self.x = width - self.hLength
        if self.y + self.hLength > height:
            self.y = height - self.hLength
    def update_x(self, offset):
    def update_y(self, offset):

class Player(SimObject):
    def __init__(self, x = 400, y = 400, speed = 10, length = 20):
        super().__init__(x, y, speed, length)

class Enemy(SimObject):
    def __init__(self, x = 10, y = 10, speed = 5, length = 20, safe_distance = 100):
        super().__init__(x, y, speed, length)
        self.safe_distance = safe_distance
        self.last_phase = -1
    def update_phase(self, n):
        phase_list=(f"{i} Phase" for i in ("Orbit", "Rush", "Run"))
        if self.last_phase!=n:
            self.last_phase = n
    def update_pos(self, player):
        if abs(dist-self.safe_distance)<=self.speed:#near the orbit
        elif dist>self.safe_distance:#far from orbit
        elif dist<self.safe_distance:#far inside of orbit

root = tk.Tk()
root.title("Enemy Movement Test")
application = Application(root)

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies