#voice-chat-text-0
1 messages Β· Page 508 of 1
I can't explain it in a short way
imma import os
read through this
most of functionality provided through os module is provided in a more user-friendly way through other modules
it's extremely unfortunate that so many tutorials erroneously recommend learning the os module
Peachy 30.
also... what would i need to import if i wnat python to write in a .txt?
nothing
wot
just open(filepath)
!e
with open(".txt", "w") as f:
f.write("test")
:warning: Your 3.13 eval job has completed with return code 0.
[No output]
!e
from pathlib import Path
Path(".txt").write_text("test")
:warning: Your 3.13 eval job has completed with return code 0.
[No output]
Morning
@quaint anvil π
Hi
i... probably gonna follow youtube tutorials for 3 days till i can talk
and stream
and then
@tacit crane SFP?
Next year's growth
get addmited into a mental hospital because i follwed outdated videos
make sure you dont end up in tutorial hell...
hard to get out of
what is tutorial hell?
(i tried coedacademy.... they are uh... practically mone grab to get any of the interactive good lessons)
@peak depot civ6 district specifically for cats
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Hello
@red obsidian π
imma be afk for a bit, brb
it's just one of those things where the more you see it being used the more you realise just how wrong it is
@scarlet halo minesweeper
I don't think either
that's the point
I hope it is permissible to share the invite link to chess game on chess.com?
Can I?
yes it is
Unrated 10 minute chess.com game with me
https://link.chess.com/play/qu44M8
(you can search if it's been done before)
smoked meat holds longer, so by smoking you conservervate your lungs
Feel free to join.
@vocal basin You have 1000+ blitz rating on chess.com?
lichess
Ah I see
I'm almost exactly median by rating there
1000 in blitz is 90 percentile
π
You ain't median
it's curios π
most of my games on both sites are bullet not blitz or rapid
on lichess I have just above 1500 iirc
Bullet rating 1000 is much impressive, because I can't play bullet it is too fast
and that's top 49%
Oh I see
Chat I think my pc died
reboot
Yeah I will
Impressive to be honest.
I don't know how do you all play on bulets so fast?
same as with minesweeper
Because I can't even think so fast, whole game in under 60 seconds is stressful
discipline yourself to ignore the time pressure
the only way is to repeat it over and over
My eternal enemy
Follow for music, memes & unexpected fun! πΉ#catreaction #funnycats #catshorts
Ah I see
https://link.chess.com/play/2gyMdI
Let's play bullet?
1+1
GG
You played well
who won
(I didn't see that it was 1+1 not 1+0)
sorry it took me so long to get back
If you want we can play 1+0
She was easy on me, so I won on time
and now i gotta shut down for a few min to clean my laptop
1+0
GG
You are indeed fast
I blunder many times
Thankyou @vocal basin playing with you was fun!
@unique wyvern
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
bounds={
'up': 0,
'down': len(matrix)-1,
'left': 0,
'right': len(matrix[0])-1,
}
tighten={
'up': +1,
'down': -1,
'left': +1,
'right': -1,
}
def in_bounds(p):
if bounds['up'] <= p.real <= bounds['down'] and \
bounds['left'] <= p.imag <= bounds['right']:
return True
return False
spiral_order=[]
pos=complex(0,0)
inc={
'down': complex(+1,0),
'up': complex(-1,0),
'left': complex(0,-1),
'right': complex(0,+1),
}
bearing="right"
bearings=["right","down","left","up"]
b_idx=0
while True:
i,j=int(pos.real),int(pos.imag)
spiral_order.append(matrix[i][j])
pos_new=pos+inc[bearing]
#print(spiral_order)
if not in_bounds(pos_new):
bprev=bearings[(b_idx-1)%len(bearings)]
b_idx=(b_idx+1)%len(bearings)
bearing=bearings[b_idx]
pos_new=pos+inc[bearing]
if not in_bounds(pos_new):
#print(bearing,bprev,pos_new,bounds)
break
bounds[bprev]+=tighten[bprev]
pos=pos_new
return spiral_order
@unique wyvern I should've implemented my own vec2. you were right.
It is specific to salt-die?
if you want to talk about it, feel free to do so
Could you give me context about it?
I'm curious to know
Now I've understood
π€«
@wise loom Could I share my solution?
I mean sure
def spiralOrder(matrix):
res = []
m, n = len(matrix), len(matrix[0])
top, bottom, left, right = 0, m - 1, 0, n - 1
while left <= right and top <= bottom:
for i in range(left, right + 1):
res.append(matrix[top][i])
top += 1
for i in range(top, bottom + 1):
res.append(matrix[i][right])
right -= 1
if top <= bottom:
for i in range(right, left - 1, -1):
res.append(matrix[bottom][i])
bottom -= 1
if left <= right:
for i in range(bottom, top - 1, -1):
res.append(matrix[i][left])
left += 1
return res
@scarlet halo I guess you mean webgl?
it is just library
you solved it just now?
Not really.
I practiced the same question long ago
So this is my answer
Hey all, hope your all well
@opaque mulch have all code as as stored procedures
@opaque mulch are you using an ORM?
or do you have proper control over SQLs happening?
from datetime import datetime, timezone
from sqlmodel import Field, SQLModel
class EconomyModel(SQLModel, table=True):
id: int = Field(primary_key=True, unique=True, nullable=False)
balance: float = Field(default=0)
last_claim: datetime = Field(
default_factory=lambda: datetime.fromtimestamp(1, tz=timezone.utc)
)
famous tweet slightly compressed
"slightly"
there is a famous joke that you can identify his tweets even with this quality
because of emojis
doing good thank you, just on python
this seems to be an ORM which doesn't like to be called an ORM
I played it a couple of times
but not really a game for me
@vocal basin what would be the best way to encrypt some data with a passphrase in rust?
I really should try playing Avorion again at some point
!d PyNaCl
No documentation found for the requested symbol.
!pypi pynacl
this
slightly discontinued but still usable
https://docs.rs/sodiumoxide
Rust bindings to the sodium library.
overall process:
you generate a key with a KDF of some sort
then use that to symmetrically encrypt the data
KDFs are hashes
usually targeted specifically towards smaller inputs
π
guys
I am new here to learn python at first ? should i can do to learn python fast and easy ways
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
fast and easy is kind of an opposite of learning
I think people who have years in programming (including me) tend to forget just how difficult primitive concepts like a variable are
!e
a = b = [1, 2, 3]
c = d = (1, 2, 3)
a += [4,]
c += (4,)
print(b)
print(d)
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | [1, 2, 3, 4]
002 | (1, 2, 3)
like this is so confusing
@vocal basin how many years you spent on programming
@primal shadow the fact that b is modified is already confusing
(to a beginner)
@primal shadow += has two separate meanings
one is + and re-assign
the other is to mutate in place
in Rust, those two are the same thing
but Python doesn't have proper mutability semantics
@somber heath one does .extend, the other does = ... + ...
!e
a = [1, 2, 3]
c = (1, 2, 3)
a += (4,)
c += (4,)
print(a)
print(c)
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | [1, 2, 3, 4]
002 | (1, 2, 3, 4)
see also how both work with ()
!e
a = [1, 2, 3]
c = (1, 2, 3)
a += (4,)
c += (4,)
print(a)
print(b)
print(c)
print(d)
:x: Your 3.13 eval job has completed with return code 1.
001 | [1, 2, 3, 4]
002 | Traceback (most recent call last):
003 | File [35m"/home/main.py"[0m, line [35m6[0m, in [35m<module>[0m
004 | print([1;31mb[0m)
005 | [1;31m^[0m
006 | [1;35mNameError[0m: [35mname 'b' is not defined[0m
oh right
!e
[1, 2, 3] + (4,)
:x: Your 3.13 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File [35m"/home/main.py"[0m, line [35m1[0m, in [35m<module>[0m
003 | [31m[1, 2, 3] [0m[1;31m+[0m[31m (4,)[0m
004 | [31m~~~~~~~~~~[0m[1;31m^[0m[31m~~~~~[0m
005 | [1;35mTypeError[0m: [35mcan only concatenate list (not "tuple") to list[0m
wrong code snippet lol
!epy a = b = [1, 2, 3] c = d = (1, 2, 3) a += [4,] c += (4,) print(a) print(b) print(c) print(d)
thx
!epy a = b = [1, 2, 3] c = d = (1, 2, 3) a += [4,] c += (4,) print(a) print(b) print(c) print(d)
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | [1, 2, 3, 4]
002 | [1, 2, 3, 4]
003 | (1, 2, 3, 4)
004 | (1, 2, 3)
there you go
the whole object being shared and having an identity is such a far from simple concept
when I was starting with Python this was part of the course
whereas some tutorials/courses completely ignore it
I think C++'s default may in some parts be even more intuitive
since they do have value semantics
C++ is filled with standard and compiler bugs but at least there is a goal of having some uniform set of properties for all types
general idea being: everything should behave as much as possible like an int with regards to non-arithmetical stuff
Rust and C might even be more intuitive at times compared to shared-reference languages
@scarlet halo be a menace, scare them away
please some body show me the path of my life i have nothing to loose i am dropout college guys who just chilling in random things today i fell like i have to do something God create me to do something in this world . I must learn something to change my life So i choose programming world that's why i choose my first language python Guys i ready to change my life .
or the RoR tutorial
or both
"might"
they will, they do
I think Russia technically has laws that require ID verification for social networks
keyword technically
lmao I didn't even know this game had "anti-*" politics
(first time reading through custom faction menu in Endless Space 2)
oh, I forgot that religion is completely useless in this game
there is no religion win
it's just a political tool
so real
is there a fast way to render this in py
im using plt.scatter() and setting colour attributes lmao
so not ideal
is there a way to speed this up
i want to display the distorted image but it's shit
you need to do it in reverse
based on the output coordinate, figure out the source pixel
then do the mesh thingy
but i need to do the forward transform to find the output coord?
reverse it
find how to do so
you need to compute input coord from output coord
which might mean multiple inputs
im not sure if im understanding you correctly:
i have an image (undistorted), let's say with a pixel coordinate (x,y)
but i dont know what the output coord (X, Y) is without doing f(x,y) first, which is the "normal" way of mapping it
and youre saying that i need to reverse it? so say for output (distorted) coord (X,Y), find what (x,y) it corresponds to? but wouldn't that be the input though
how can i reverse it
what is f in this case?
you need to make f_inv such that all(f(in_) == out for in_ in f_inv(out))
import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
from image import process_input_image
R = 200
cy = np.linspace(-R, R, 500)
cx = -np.sqrt((R**2) - cy**2)
# load image
image_path = "popcat.jpg"
# image_path = "transparent.png"
img_h, img_w, real_img = process_input_image(image_path)
Xs = []
Ys = []
Cs = []
translate_x = 100 # number of pixels to translate from origin (x direction)
translate_y = 30 # number of pixels to translate from origin (y direction)
for i, px in enumerate(real_img.reshape(-1, 3) / 255.0):
x, y = (i % img_w) + translate_x, (img_h - (i // img_h)) + translate_y
if x == 0:
x = 0.00001
elif y == 0:
y = 0.00001
theta = np.arctan2(y, np.sqrt(R**2 - y**2))
m = np.tan(2 * theta)
X = -(m * np.sqrt(R**2 - y**2) - y) / (y / x + m)
Y = y / x * X # basically RHS of -y/x * ... is X, so reuse result
Xs.append(X)
Ys.append(Y)
Cs.append(px)
basically this
theta = np.arctan2(y, np.sqrt(R**2 - y**2))
m = np.tan(2 * theta)
X = -(m * np.sqrt(R**2 - y**2) - y) / (y / x + m)
Y = y / x * X # basically RHS of -y/x * ... is X, so reuse result
this is the actual transform step
as you can see with X,Y being defined and mapped from x,y
can you explicitly express the transform as a standalone function
wdym, i can extract method from the code?
mathematically it's this
R is the radius of the mirror
def f(theta, R, x, y):
theta = np.arctan2(y, np.sqrt(R**2 - y**2))
m = np.tan(2 * theta)
X = -(m * np.sqrt(R**2 - y**2) - y) / (y / x + m)
Y = y / x * X # basically RHS of -y/x * ... is X, so reuse result
return X, Y
hey there everyone....
you can do this without trigonometry afaik
theta = np.arctan2(y, np.sqrt(R**2 - y**2))
m = np.tan(2 * theta)
.wa s tan(2*x)
tan(2 x)
tan(2 x)
@frozen owl first, simplify m calculation to not include trig functions
you already have the value of tan(theta)
from which you can directly calculate tan(2 * theta)
simplify the function until it's trivially invertible
I think once you simplify you will get rid of np.sqrt(R**2 - y**2)
i suppose i have tan alr, so to get tan(2*theta) maybe this then?
(either because it gets multiplied with it or divided by it, see X = ... line)
ah, no
(y / x + m) part will get it
but that's already fewer sqrts to deal with
wait let me try and get rid of m first
tan_theta = y/np.sqrt(R**2 - y**2)
# theta = np.arctan2(y, np.sqrt(R**2 - y**2))
# m = np.tan(2 * theta)
# double angle formula for tan
m = (2 * tan_theta) / (1 - tan_theta ** 2)
now i want to get rid of the R and sqrts
@somber heath is arxiv a social network?
@peak depot Wikipedia is quite useful for many technical stuff
because hard to search otherwise
both as an aggregator and as something where people actually write something readable based on weird sources
@vocal basin i guess ive now turned this into 2 lines now, not any easier to invert
X = -(
(2 * (y / np.sqrt(R**2 - y**2)))
/ (1 - (y / np.sqrt(R**2 - y**2)) ** 2)
* np.sqrt(R**2 - y**2)
- y
) / (
y / x + (2 * (y / np.sqrt(R**2 - y**2))) / (1 - (y / np.sqrt(R**2 - y**2)) ** 2)
)
Y = y / x * X
you need to inline tan_theta too
done
get big equation, then simplify terms whenever possible
it should end up as just a product of simple add/sub terms
X = -(m * np.sqrt(R**2 - y**2) - y) / (y + mx) * x
is this one rearranged?
like to map to original?
maybe this π
i mapped a and b to x and y
since otherwise it might confuse wolframalpha
.latex
$$
\frac{a\left(R^2-2b^2\right)}{-2a\sqrt{b^2-R^2}-R^2}
$$
great
so now i have the inverses
numerator = X * (R**2 - 2 * Y**2)
denominator = -2 * X * np.sqrt(Y**2 - R**2) - R**2
x = numerator / denominator
y = (x * Y) / X
now i need to find a way to map to screen?
@vocal basin i still dont get this
i give it the original image coords and i want to map to transformed
but then now i have the func for transformed to img
but i cant get the output coordinate without first mapping the input to output?
so do i do a forward -> backward -> get the (X,Y) then back to foward again?
is it faster lol
cant i use mesh directly
like i can quantise X,Y to nearest int? how shit is that
your goal is to get what colour the output pixel needs to be
i have that info
no, you have a set of points
which aren't exactly corresponding to the output coordinates
for i, px in enumerate(real_img.reshape(-1, 3) / 255.0):
i have the input img pixel values
you can also do interpolation probably
just find the nearest point to the output from that list
or several
and then use a weighted average
but doesnt this work?
i iterate through the colour values directly
you must iterate over output, not points you have
this is the critical piece for how all such things work when implemented reliably
you effectively need colour_output(x_out, y_out)
implemented somehow
i dont undestand
when the inverse is easy to compute, it's just colour_inputβreverse
i thought the colour info "followed" the coordinates, so whatever properties the coord has, the colour is associated with
so if x,y is mapped, so does the colour?
so the corresponding X,Y has the same colour as x,y
okay, simpler situation:
you only have three points in your universe
ok
what are you calculating :-
you map them to 0 and 2
:0*
what colour is 1 in the output?
[red, blue, none]
[red, ???, blue]
if you just map, it will be none
because nothing maps there
so you get holes in your output
well 3 points, each point should have their own colour, so there has to be 3 colours to start with
each pixel is actually behaving like a square full of colour
you should really understand that your goal is to find the colour for each pixel of the output
not paint over the output point by point
how do i exec code here again?
AAAA AA A A A A AA A A A
!e
```py
code
```
there do exist ways to automate how you invert a function
especially if it's continuous and injective
(within the domain)
just to clarify is this what you were talking about earlier
the [none] thing
this
Wolfram proper can possibly give you an inverse of a function if you give it the function
(wolframscript or wolfram notebook)
!e
import numpy as np
a=[[1,2,3],[4,5,6],[7,8,9]]
b=np.array(a)
print(a[:][2])
print(b[:,2])
^^ notice how i can get the last column of a matrix with numpy but with regular python 2D lists I can't.
inconsistent behavior.
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | [7, 8, 9]
002 | [3 6 9]
it's not inconsistent
i mean.. why do you think so?
!e
import numpy as np
a=[[1,2,3],[4,5,6],[7,8,9]]
b=np.array(a)
print(a[:][2])
print(b[:][2])
:white_check_mark: Your 3.13 eval job has completed with return code 0.
001 | [7, 8, 9]
002 | [7 8 9]
different operations lead to different output
there is no inconsistency
i see
i'm confused as to what a[:][2] should mean with lists..
copy the list, get the second element
so once i get the mapping back from the input after the inverse function, how do i plot this? i can do plt.imshow() for the original image but the distorted image is not an image proper
well what about a[0:3][2] ? same?
whereas [:,2] is not defined on list
right.. i see
would be imshow too
you also have to guess somehow the output region correctly
(rectangle within which to compute and plot it)
for image editors this part of the operation is quite trivial: just calculate the whole image
i see
Hey guys, I am currently working on a personal project and I'm having some problems with the code, can anyone help me ??
I need help with pyttsx3 and basically with the working of STT and TTS modules
And sorry if this message was not supposed to be posted here, I just joined the server and I don't know where to ask for help and I'm also in a bit of hurry
gl boys
Out now: https://found.ee/nu_delhi
Pre-save our upcoming album NU DELHI if you like what you hear!: https://found.ee/nudelhi
THE RETURN OF THE SINGH TOUR 2025 (EU/UK Leg) announced!
Tickets: https://www.bloodywood.net/tour
Credits:
Karan Katiyar-Director
Kushagra Nautiyal-Cinematographer
Athul Sudhakaran-Editor
Joyner Thomas-Colourist
Siddh...
How is everyone doing today?
@wise loom how are you doing
hello
hey fox, just woke up
How are you doing today?
trying to survive
Me too
player.draw(screen,ocean_blue)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
TypeError: Player.draw() takes 2 positional arguments but 3 were given
PS C:\Users\cas
I think you have to remove the screen variable
You can hover the function call and enter gd
Also python is self documented it explain the argument
And a good library have type annotations
Hello
fixed it
Hello
π€«
yh but still not getting verified
@wraith pelican gimme a second, going closer to the router, i was outside
HI
Hey
i have a rounding Error in my code how do I fix it? How do I let the code no went to round and went not to round
*know when to round
I am sorry but iβm a beginner canβt help u sorry
any one in that chat
Hey π
hello
import pygame as pyg
from random import randint
#===[init]===#
pyg.init()
class Player:
def __init__(self):
pass
def Player_Movement(self,surface,delta_time):
player_pos = pyg.Vector2(surface.get_width() / 2, surface.get_height() / 2)
keys = pyg.key.get_pressed()
if keys[pyg.K_w]:
player_pos.y -= 300 * delta_time
if keys[pyg.K_s]:
player_pos.y += 300 * delta_time
if keys[pyg.K_a]:
player_pos.x -= 300 * delta_time
if keys[pyg.K_d]:
player_pos.x += 300 * delta_time
def draw(self,surface,color,rect_dimentions):
pyg.draw.rect(surface,color,rect_dimentions)
why dose it not move!!!!
@woeful blaze show the game loop
and put the
player_pos = pyg.Vector2(surface.get_width() / 2, surface.get_height() / 2)
keys = pyg.key.get_pressed()``` into init function
import pygame as pyg
from time import sleep
# import from settings
from settings import *
# import from indecator bars
from player_indicator_bars import Health_bar
from player_indicator_bars import Hunger_bar
from player_indicator_bars import Thirst_bar
from player_indicator_bars import Experiance_bar
# import from player
from player import Player
#===[init]===#
pyg.init()
# screen dimention
screen = pyg.display.set_mode(window_dimentions)
# clock time
dt = 0
# Clock
clock = pyg.time.Clock()
# classes
health = Health_bar(20, 20, 200, 25, 100)
hunger = Hunger_bar(20, 70, 200, 25, 100)
thirst = Thirst_bar(20, 130, 200, 25, 100)
exp = Experiance_bar(200,500,500,15,100)
# main loop
while Game_Running:
player = Player()
for event in pyg.event.get():
if event.type == pyg.QUIT:
Game_Running = False
#screen
screen.fill(grass_green)
#bars
# Health bar
health.hp = 20
health.draw(screen,Red_Health,green_Health)
# Hunger bar
hunger.Hunger = 75.5
hunger.draw(screen,brown_orange,orange_hunger)
# Thirst bar
thirst.Thirst = 20.9
thirst.draw(screen,blue_grey,blue)
#exp bar
exp.exp = 50.5
exp.draw(screen,exp_blank,green_exp)
# ceate player
rect_dimentions = (450,300,80,80)
player_movement = player.Player_Movement(screen,dt)
player.draw(screen,ocean_blue,rect_dimentions)
pyg.display.flip()
dt = clock.tick(60) / 1000
pyg.quit()
the game loop looks fine
It doesn't update if I hit AWSD
your not using the player_movement
How?
line 72
player_movement = player.Player_Movement(screen,dt) it just sits there and not being used
i agree
What would I need to do I swear I've been using it
This is the entire code
I swear I was but I've been tired lately
show where that variable is used
Now I see it I haven't so I get rid of player movement As its name
And just have player.Player_monvement
also why you initializing the pygame twice
on the main file and the player.py
class Player:
def __init__(self, screen):
self.screen = screen```
!doc pygame.time.Clock
Hey chris
chris have u used tkinter before
how do you change the logo on the taskbar, so its not the blue feather
the .spec file?
root.icon?
import pygame as pyg
from time import sleep
# import from settings
from settings import *
# import from indecator bars
from player_indicator_bars import Health_bar
from player_indicator_bars import Hunger_bar
from player_indicator_bars import Thirst_bar
from player_indicator_bars import Experiance_bar
# import from player
from player import Player
#===[init]===#
pyg.init()
# screen dimention
screen = pyg.display.set_mode(window_dimentions)
# clock time
dt = 0
# Clock
clock = pyg.time.Clock()
# classes
health = Health_bar(20, 20, 200, 25, 100)
hunger = Hunger_bar(20, 70, 200, 25, 100)
thirst = Thirst_bar(20, 130, 200, 25, 100)
exp = Experiance_bar(200,500,500,15,100)
player = Player()
# ceate player
rect_dimentions = (450,300,80,80)
# main loop
while Game_Running:
for event in pyg.event.get():
if event.type == pyg.QUIT:
Game_Running = False
#screen
screen.fill(grass_green)
#bars
# Health bar
health.hp = 20
health.draw(screen,Red_Health,green_Health)
# Hunger bar
hunger.Hunger = 75.5
hunger.draw(screen,brown_orange,orange_hunger)
# Thirst bar
thirst.Thirst = 20.9
thirst.draw(screen,blue_grey,blue)
#exp bar
exp.exp = 90
exp.draw(screen,exp_blank,green_exp)
player.Player_Movement(screen,dt)
player.draw(screen,ocean_blue,rect_dimentions)
pyg.display.flip()
dt = clock.tick(60) / 1000
pyg.quit()
import tkinter as tk
root = tk.Tk()
root.title("My App")
root.iconbitmap("my_icon.ico")
root.mainloop()
Ty
```py
code()
```
import pygame as pyg
from random import randint
#===[init]===#
pyg.init()
class Player:
def __init__(self):
pass
def Player_Movement(self,surface,delta_time):
player_pos = pyg.Vector2(surface.get_width() / 2, surface.get_height() / 2)
keys = pyg.key.get_pressed()
if keys[pyg.K_w]:
player_pos.y -= 300 * delta_time
if keys[pyg.K_s]:
player_pos.y += 300 * delta_time
if keys[pyg.K_a]:
player_pos.x -= 300 * delta_time
if keys[pyg.K_d]:
player_pos.x += 300 * delta_time
def draw(self,surface,color,rect_dimentions):
pyg.draw.rect(surface,color,rect_dimentions)```
!doc pygame.draw.rect
pygame.draw.rect()```
Draw a rectangle.
rect(surface, color, rect, width=0, border\_radius=-1, border\_top\_left\_radius=-1, border\_top\_right\_radius=-1, border\_bottom\_left\_radius=-1, border\_bottom\_right\_radius=-1) -> Rect
Draws a rectangle on the given surface.
!doc pygame.Rect
pygame.Rect```
pygame object for storing rectangular coordinates
Rect(left, top, width, height) -> Rect
Rect((left, top), (width, height)) -> Rect
Rect(object) -> Rect
Rect() -> Rect...
player_pos = pyg.Vector2(screen.get_width() / 2, screen.get_height() / 2)
import pygame as pyg
from random import randint
class Player:
def __init__(self):
self.pos = pyg.Vector2(0,0)
def Player_Movement(self,delta_time):
keys = pyg.key.get_pressed()
if keys[pyg.K_w]:
self.pos.y -= 300 * delta_time
if keys[pyg.K_s]:
self.pos.y += 300 * delta_time
if keys[pyg.K_a]:
self.pos.x -= 300 * delta_time
if keys[pyg.K_d]:
self.pos.x += 300 * delta_time
def draw(self,surface,color,rect_dimentions):
pyg.draw.rect(surface,color,pyg.Rect(self.pos,rect_dimentions))
@woeful blaze try this
player.Player_Movement(screen,dt,player_pos)
pygame.key.get_pressed()```
Get the state of all keyboard buttons.
get\_pressed() -> ScancodeWrapper
Returns a sequence of boolean values representing the state of every key on the keyboard. Use the key constant values to index the array. A `True` value means that the button is pressed.
import pygame as pyg
from time import sleep
# import from settings
from settings import *
# import from indecator bars
from player_indicator_bars import Health_bar
from player_indicator_bars import Hunger_bar
from player_indicator_bars import Thirst_bar
from player_indicator_bars import Experiance_bar
# import from player
from player import Player
#===[init]===#
pyg.init()
# screen dimention
screen = pyg.display.set_mode(window_dimentions)
# clock time
dt = 0
# Clock
clock = pyg.time.Clock()
# classes
health = Health_bar(20, 20, 200, 25, 100)
hunger = Hunger_bar(20, 70, 200, 25, 100)
thirst = Thirst_bar(20, 130, 200, 25, 100)
exp = Experiance_bar(200,500,500,15,100)
player = Player()
# ceate player
rect_dimentions = (450,300,80,80)
# main loop
while Game_Running:
for event in pyg.event.get():
if event.type == pyg.QUIT:
Game_Running = False
#screen
screen.fill(grass_green)
#bars
# Health bar
health.hp = 20
health.draw(screen,Red_Health,green_Health)
# Hunger bar
hunger.Hunger = 75.5
hunger.draw(screen,brown_orange,orange_hunger)
# Thirst bar
thirst.Thirst = 20.9
thirst.draw(screen,blue_grey,blue)
#exp bar
exp.exp = 90
exp.draw(screen,exp_blank,green_exp)
player.Player_Movement(dt)
player.draw(screen,ocean_blue,rect_dimentions)
pyg.display.flip()
dt = clock.tick(60) / 1000
pyg.quit()
!stream 1318626588560199692
β @woeful blaze can now stream until <t:1754795527:f>.
you have bad internet connection or what...
My computer is finicky locked me out discord when the FPS dropped
you can lower the stream fps
!stream 1318626588560199692
β @woeful blaze can now stream until <t:1754795944:f>.
use this
change the line 25 to
class User:
def __init__(self):
self.rank = -8
self.progress = 0
def inc_progress(self,activity_rank:int):
allowed_rank = [-8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8]
if activity_rank not in allowed_rank:
raise ValueError("The Rank of the activity must be in the allowed ranks -8 to 8 excluding 0")
if(activity_rank == self.rank):
self.progress += 3
elif(activity_rank == self.rank-1):
self.progress +=1
elif(activity_rank > self.rank):
d = activity_rank - self.rank
self.progress += 10*d*d
while(self.progress >= 100):
self.progress -= 100
self.rank +=1
if self.rank == 0:
self.rank =1
elif self.rank == 9:
self.rank =8
Business Rules:
A user starts at rank -8 and can progress all the way to 8.
There is no 0 (zero) rank. The next rank after -1 is 1.
Users will complete activities. These activities also have ranks.
Each time the user completes a ranked activity the users rank progress is updated based off of the activity's rank
The progress earned from the completed activity is relative to what the user's current rank is compared to the rank of the activity
A user's rank progress starts off at zero, each time the progress reaches 100 the user's rank is upgraded to the next level
Any remaining progress earned while in the previous rank will be applied towards the next rank's progress (we don't throw any progress away). The exception is if there is no other rank left to progress towards (Once you reach rank 8 there is no more progression).
A user cannot progress beyond rank 8.
The only acceptable range of rank values is -8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8. Any other value should raise an error.
The progress is scored like so:
Completing an activity that is ranked the same as that of the user's will be worth 3 points
Completing an activity that is ranked one ranking lower than the user's will be worth 1 point
Any activities completed that are ranking 2 levels or more lower than the user's ranking will be ignored
Completing an activity ranked higher than the current user's rank will accelerate the rank progression. The greater the difference between rankings the more the progression will be increased. The formula is 10 * d * d where d equals the difference in ranking between the activity and the user.
what's all of this?
Can you turn on your mic?
this is from codewars
https://www.codewars.com/kata/51fda2d95d6efda45e00004e
[..]
elif(activity_rank > self.rank):
if self.rank < 0 and activity_rank > 0:
# explicitly exclude the zero
d = activity_rank - self.rank - 1
else:
d = activity_rank - self.rank
self.progress += 10*d*d
[..]
here is a new test
@test.it("[5,1,2,2,1,-1]")
def _():
user = User()
user.inc_progress(1)
user.inc_progress(1)
user.inc_progress(1)
user.inc_progress(1)
user.inc_progress(1)
user.inc_progress(2)
user.inc_progress(2)
user.inc_progress(-1)
test.assert_equals(user.rank, 1)
test.assert_equals(user.progress, 21)
if(activity_rank == self.rank-2):
self.progress +=1```
elif((activity_rank == self.rank-1 and self.rank-1 !=0) or (self.rank ==1 and activity_rank in [-1,2] )):
self.progress +=1
elif (activity_rank,self.rank) == (-1,+1) or (activity_rank * self.rank > 0 and activity_rank == self.rank - 1 ):
@weary lion π
Hi
Hello π
thielocracy is doing everything it can to look worse than Russia
Thielocracy?
yeah
@peak depot bcantrill once mentioned how someone asked him to show he's over 18 in very recent years
one of the techno lords
(he's >50)
opal, where did he sya that?
i know he is like the gavin benson character from silicon valley
and hes like obsessed with being inmortal
To be honest the Young Man in Germany was the result of the year of sanction on Germany
i do believe in the technolords, oh mighty lords please forgive me for my sins such as owning something that you dont
dictatorship leadership devours itself/its allies faster than whoever it oppresses
(for an example, see what's happening within pro-war part of Russia)
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
@candid spire you never talk?
@long dragon π
Hello
Yes
It is difficult to find a phone with personality π.
Very few phones under 6.1 inch diagonal
Is hemlock busy lately?
yes
morning
got some sleep
import math
import pygame as pyg
class Player:
def __init__(self):
self.player_pos = pyg.Vector2(0,0)
def Player_Movement(self,delta_time):
keys0 = pyg.key.get_pressed()
if keys0[pyg.K_w]:
self.player_pos.y -= 2* delta_time
if keys0[pyg.K_s]:
self.player_pos.y += 2* delta_time
if keys0[pyg.K_a]:
self.player_pos.x -= 2* delta_time
if keys0[pyg.K_d]:
self.player_pos.x += 2* delta_time
return self.player_pos
def draw(self,surface,color,rect_dimentions):
pyg.draw.rect(surface,color,pyg.Rect(self.player_pos.x,self.player_pos.y,*rect_dimentions))
class Monster:
def __init__(self,player_pos):
self.Monster_pos = pyg.Vector2(0,0)
self.player_pos = pyg.Vector2(0,0)
def follow_player (self,Monster_pos,player_pos):
distance = self.Monster_pos - self.player_pos
print(distance)
def draw(self,surface,color,rect_dimentions):
pyg.draw.rect(surface,color,pyg.Rect(self.player_pos.x,self.player_pos.y,*rect_dimentions))
how can I get the Player_pos for Monster?
also how is everyone
why i can't speak
!voice
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
Does anyone know how to unpack a dictionary after importing it it's for my game
from settings import Game_Running
from settings import *game_colors
Myer's algorithm
purplesyringa did something JSON-parsing-related too
google gets the intent so wrong
so, yeah, seems to be a real unsolved problem
not even remotely solved
@storm jewel do you control the data storage or are you querying something external?
I mean is it local
in-memory is as local as it can be
so you control how the data is represented
yeah, then a lot of work there is about data structures
filtering and searching isn't really that algorithm-heavy, most of it is about how the data is structured
one common example for searching is stuff like search by keywords;
you need store an index that allows you to somehow find entries based on those keywords, you can't just "algorithmically search" through it without involving extra structures
for searching by a single keyword/tag it's fairly trivial
it's an example of how extra structures are necessary for search, not a solution to your problem
how much data are you dealing with? (approximately)
gigabytes
so, small/medium search set + infrequent queries, right? (can afford a scan)
how many per second?
(scan = look through all data)
Hlo any Indian My first time on discord
I think you shouldn't really ask it to evaluate something
instead have some other metric to go by
@wind raptor .sort_by(|a, b| llm(format!("please sort {a}, {b}")))
I guess if you scan, you are actually kind of aiming for ranking rather than filtering
this might simplify it a bit
@wind raptor will be on in a bit if you want to work on git
he is probably just happy to be back
are there mechanisms for DI in Ocen
dependency injection
reflection should be enough for it
for webby stuff having DI is very convenient
(maybe there's a way to invent some weird hacky mechanism that Ocen can facilitate okay-ish-ly)
offloading the action of providing arguments (dependencies) to some external thing that figures out how to provide (inject) them
the general idea of being able to say "I want this, give it to me, I don't really care how" in code (in a convenient way)
maybe I'm just dense but that sounds like a function no? code example pls?
i could just google it too
yeah, that's kind of the point, that it's just a function,
but you're not calling that function, something else figures out how to call it
how's that different from say a lambda or passing a function pointer
@get("/settings")
def get_settings(
user: CurrentUser,
db: DataBase,
):
...
it needs to derive stuff dynamically sometimes
so you can't just have something in closure
@app.get("/settings")
def get_settings( # not aware of `SQLite`
user: CurrentUser,
db: DataBase,
):
...
app[DataBase] = SQLite("./stuff.db") # not aware of `get_settings`
@lavish rover can't you push over HTTPS with a token?
right maybe
i was thinking more ssh keys, i don't remember
!stream 1145811320621510738
β @manic basin can now stream until <t:1754856371:f>.
password access was removed
when password=site sign on password
I think it now defaults to new smart token/oauth2 thingy with a git credentials manager when HTTPS auth is required
where it redirects you to the website
there is some semi-open protocol for this
(on top of oauth2)
so it works with websites other than github sometimes
do alt right
do whom again?
another option: listen to something with incoherent lyrics
grindcore π€
is GitHub still SHA1-only?
iirc Forgejo supports SHA2
@lavish rover you should add {1 + 2 = } syntax from Python
!e
print(f"{1 + 2 = }")
i should
:white_check_mark: Your 3.13 eval job has completed with return code 0.
1 + 2 = 3
VSCode 2
noway the sequel
# TODO 4: Calculate commission (2% of sales over $1000)
print("\nCommission Report:")
total_commission = 0
for i in range(len(days)):
day = days[i]
sale = daily_sales[i]
# TODO: Calculate commission
if sale > 1000:
commission = 0 # TODO: Calculate 2% of amount over $1000
else:
commission = 0
total_commission += commission
print(f"{day}: ${commission:.2f}")
print(f"Total weekly commission: ${total_commission:.2f}")```
.
How to get a remote sde job in europe?
@wind raptor hai
Sorry, have to go now. Good to see you though! I'll be on again in a couple of hours.
oki
Applied for a role at Spotify, start your bets now on how long the rejection email will take to turn up π
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
sup
my voice dont work
i need help with a scrip
cript
can you accept my friend request?
!code
its complicated
im working on a macro
based on image recognition
problem is when it goes to the 2nd step the element it doesnt click the button
on the game
i think the game doesnt see the clicks as valid
because when i nudge my mouse it works fine
but pyton cant do it
python with import tkinter as tk
from tkinter import messagebox
import pyautogui
import time
import threading
import webbrowser
import os
import configparser
import keyboard
import random
Click here to see this code in our pastebin.
i have the images in the same folder
to help u understand it moves the mouse perfectly
i dont think so because the button after that works
but not the second button you need to click
i can send the pictures
i mean it goes to the image and does click
@fair otter π
but my mouse esnt update
i tried making it 5 times
still doesnt update the mouse
it does it once but i tired multiple times
still same result
would be easy if i could screenshare
is it possible i could try focus window
no my macro is only interacting with npcs
i did have a cleaner version
i can send that
ai has helped with this btw
its mostly my code
but ai has been used in places
Please react with β
to upload your file(s) to our paste bin, which is more accessible for some users.
alrigiht thanks
do ou think i can send a video?
to show u whats wrong
@somber heath
Guys I received a DM from @wise shale
I don't know what to tell him
He is asking me if I'm "any good with Python"
@sleek brook π
π
Bro unmute voice
Perm
@somber heath
!voice
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
25mesaag ?
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
Of course it make sense
Yes sure you are right
Yes people are coming in and out for no reason I understand
Sorry I did not Heard you π
Would be a total nightmare I guess
Yup
Are you working today ?
Nice plans
You work as a freelancer ?
I mean like for yourself ?
Oh no problem π
Itβs currently almost 6 in the morning at my place
Kinda difficult Yeah
Ahahah
Iβm not a patriot donβt worry
This clichΓ© is real btw
π
Honestly I do not like the French mentality
Yeah π
You are american ?
No you sound british
π
Wow Nice !
I Know some people there
Your accent is Perfect
You got that accent Perfect too
Iβm laughing hard
Yeah itβs kinda hard I mean the balance is not good
π
You seems very frustrated π
But I understand you
Do you wanna call ?
Maybe it Will be easier to talk
Okey thatβs fine
Yup
Yup
Itβs not a problem I Will have to Wait π
You live in a Great country
The only things I do not like in Australia are the spider and snake
Damn
You sound like the Australian Chuck Norris who fights threats with his bare hands π
I hate this π
I have to go ! such a pleasure to talk to you ! Have a Nice day or evening !
Bye bye !
@somber heath
hai
gotta be here 3 days to talk
:c
sadge
a friend shoed me a game called "farmer was replaced"
and you gotta code drones to do stuff
what?
i am bored
@frigid atlas π
Canβt talk in voice chat? Check out #voice-verification to get access. The criteria for verifying are specified there.
@serene sigil π
Go to http://brilliant.org/BranchEducation/ for a 30-day free trial and expand your knowledge. Use this link to get a 20% discount on their annual premium membership.
Integrated Circuits, CPUs, GPUs, Systems on a Chip, Microcontroller Chips, and all the other different types of microchips are the brains of all the devices and technology that we...
Possibly the best video I saw during 2025
Hello guys
@peak depot your uni is fully online?
yes
accepting of foreign students?
no
@kind cloud π
@somber heath hey
@prisma scarabπ
@lilac topazπ
Also applied for a role at Monzo, let's see how that goes..
inverse = unitary_layer[-(i + 1)][1].conj().T
if inverse.shape[0] == 4:
disentangled_mps.gate_split_(inverse, (i - 1, i))
else:
disentangled_mps.gate_(inverse, (i), contract=True)
Best of luck. Hopefully you'll get it.
such Absurd Issue (AI)
I'm starting to learn python rn how can I learn fast and where?
in general, such issues are insta-reject
multiple issues with <...>
no, try again, learn how to use GitHub
I've done large PRs before but at least those list what actually happened in short
https://github.com/rodrimati1992/abi_stable_crates/pull/121
off-by-user-error
hackerone is filled with AI-made reports
you can hide contents
and you can delete them now, yes
this should be prosecuted, since it's fraud
@upper basin or make a bot that auto-deletes their issues
(make them waste effort)
π₯
You mean based on their account?
Or based on content?
account
Hehe
rather than banning
I love it.
"I shant kill you. I shall leave you alive, to suffer in the futility of your existence."
def get():
url = "https://discord.com/"
response = requests.get(url)
print(response.status_code, response.text)
if response.status_code == 200:
print("Works")
else:
exit(0)
get()``` simple api req
@somber heath what can u add on to this
well idk
0 means 0 erros
i believe
oh ok
so just a pass or no else
it like sends
likely @property
probably javascript not java
yea
iirc it's something like this
@property
def text(self):
return self._raw.read().decode()
i meant javcascript
i say java for short
cus i think people know what im sayin
but i always correct them
i know there diffrent langs but i feel thats slang for it
Java is very separate from JavaScript, and it should be that way
Oracle should abandon the JavaScript trademark
ecmascript
or just javascript
another word for javascript, but which isn't trademark
also javascript is often mentioned as just js
iirc lit. "JS" isn't copyrighted by Oracle
those mess me up whenever im talking abt websites and they think im talking abt the java language
=> why JSConf is allowed to exist
js would be better ig
i dont think it matters but like
(Applets)
... and now also can probably run via WASM
@dark jewelπ
yes
Hello @somber heath
it can
1995-ish
@whole bearπ
do u feel that java should be coded in any ide
or do u have a fav
Intellij @lilac topaz
i like vscode
I don't write any Java code;
but if I were to do so, either IntelliJ IDEA or Eclipse
Eclipse is slightly newer than IntelliJ IDEA
its smoother with typing
Hi
i just feel like other ides dont have a smooth typing feature like vscode
so i stick with it even if im maining visual studio for csharp projects
or c++
just paste the code into it afer im done
@lilac topaz what do u mean by smooth typing feature?
u didnt know it has smooth typing?
the most beautiful thing is vscode
for C++, I only use VSCode
i just don't know what that means
I abandoned VS proper in 2022
the smooth typing si why i main it
like when u type its smooth not like
when I stopped using C#
yk
changes cursor movement presumably
or u can just use vim
Hmm
type stuff
okay seems like no one is going to even question this
Eclipse
IntelliJ IDEA
the first one does not look newer
this one is nice man
this one is newer than both of those
speaking of VSCode, @somber heath, do you remember the Red with a certain font?
peak miscustomisation so far
is there smooth typing on those ides
as in the screenshot I sent
(I meant do you remember the screenshot and just how horrible it looked)
@midnight ospreyπ
!charinfo xa
\u0078 : LATIN SMALL LETTER X - x
\u0061 : LATIN SMALL LETTER A - a
\u0078\u0061
okay so not Cyrillic
they get filtered more slowly
the site is called bemlex
and its a scam
they make u think ur winning and u have to pay a fee to depo
because it's not blocklisted
so they just get banned for spam
most of timeout messages used to land in #off-topic-lounge-text
but now I think they end up somewhere in code jam channels
want to gamble => play minesweeper instead
minesweeper.online can show you a fake money number too
just code one
I did
(it's very clearly just an estimate of how much you need to donate to get the same stuff)
who needs casino when you can have minesweeper
minesweeper is a game called mines
on those sites
idk if u heard of it
more u click more money u get
high frequency gambling
and if u bomb u lose it
do numbers work there
u make it on a site
very casino
all the logic is done via HTMX
I could've actually moved the template generation to the server
however that would be more difficult
HTMX isn't necessarily easier
but it's more concise
it uses some amount of JS inside
but it's a very tiny library
i never really heard of it
HTMX is mostly for fetching pieces of the page
rather than local-first interactivity
example of how Forgejo uses it:
when you click one of these buttons, it only re-fetches the contents of a button instead of reloading the whole page to update the number
htmx gives you access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, using attributes, so you can build modern user interfaces with the simplicity and power of hypertext
htmx is small (~14k min.gzβd), dependency-free, extendable, IE11 compatible & has reduced code base sizes by 67% when compared with react
alright
what u guys talking about
even negative traits have some positive effects sometimes
like there is a reason why you wouldn't want to remove the sickle trait entirely from the population
@ocean turret π
hello
vim.opt.number = true
vim.opt.relativenumber = true
π₯
vim = false
@scarlet halo how do u get screenshare access?
the mods trusted me with this power
ok
i am unstoppable
totally
lol
vim.π₯ = true
meh
what is that code editor
just showing off my nvim config π
cuz i was thinking of installing linux mint
