• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:04
CET 17:04
KST 01:04
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Winners8Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
Starcraft, SC2, HoTS, WC3, returning to Blizzcon!33$5,000+ WardiTV 2025 Championship6[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win9
StarCraft 2
General
RotterdaM "Serral is the GOAT, and it's not close" TL.net Map Contest #21: Winners Starcraft, SC2, HoTS, WC3, returning to Blizzcon! 5.0.15 Patch Balance Hotfix (2025-10-8) Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win
Tourneys
$5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BW General Discussion [ASL20] Ask the mapmakers — Drop your questions [BSL21] RO32 Group Stage BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review
Tourneys
[Megathread] Daily Proleagues [ASL20] Grand Finals [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Nintendo Switch Thread ZeroSpace Megathread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1696 users

The Big Programming Thread - Page 802

Forum Index > General Forum
Post a Reply
Prev 1 800 801 802 803 804 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
TanGeng
Profile Blog Joined January 2009
Sanya12364 Posts
November 23 2016 15:18 GMT
#16021
lol
Moderator我们是个踏实的赞助商模式俱乐部
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
November 23 2016 16:01 GMT
#16022
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...
Time is precious. Waste it wisely.
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
November 23 2016 16:13 GMT
#16023
On November 23 2016 16:16 Acrofales wrote:
Show nested quote +
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?


I believe the solution is:
self.remove_meth()





If only that worked IRL :/
TRUEESPORTS || your days as a respected member of team liquid are over
Cyx.
Profile Joined November 2010
Canada806 Posts
November 23 2016 16:46 GMT
#16024
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?

Maybe I'm misunderstanding this, but I think what you want to do is often done by measuring how much time has passed since the last frame, and passing that value into your `move_creatures()`. Then you can scale that by movement speeds to get movement amounts:

last_time = pygame.time.get_time()
while not game_over:
time = pygame.time.get_time()
dt = time - last_time
self.move_creatures(dt)
last_time = time

// ...

def move_creatures(dt):
for c in self.creatures:
c.position += c.velocity * dt;
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
November 23 2016 16:59 GMT
#16025
Have you tried tinkering with the frames? If I remember correctly you can speed up/slow down the game via the frames setting.
Time is precious. Waste it wisely.
tofucake
Profile Blog Joined October 2009
Hyrule19151 Posts
November 23 2016 17:50 GMT
#16026
On November 24 2016 01:01 Manit0u wrote:
Show nested quote +
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...

Yeah but 7 million people doing it on the landing page after login :|
Liquipediaasante sana squash banana
Acrofales
Profile Joined August 2010
Spain18109 Posts
November 23 2016 19:17 GMT
#16027
On November 24 2016 02:50 tofucake wrote:
Show nested quote +
On November 24 2016 01:01 Manit0u wrote:
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...

Yeah but 7 million people doing it on the landing page after login :|

I hardly ever visit the landing page. Does that solve your problem?
tofucake
Profile Blog Joined October 2009
Hyrule19151 Posts
November 23 2016 19:32 GMT
#16028
On November 24 2016 04:17 Acrofales wrote:
Show nested quote +
On November 24 2016 02:50 tofucake wrote:
On November 24 2016 01:01 Manit0u wrote:
On November 24 2016 00:15 tofucake wrote:
[image loading]

some of our devs need to learn how to manage their queries :\


That seems really small compared to what I deal with on a daily basis... One page doing 1.6mil requests in 21 seconds, another one doing 3 requests in 39 seconds...

Yeah but 7 million people doing it on the landing page after login :|

I hardly ever visit the landing page. Does that solve your problem?

On our website you have to login to see anything (it's a reimbursement program thing) so everyone always sees the landing page.
Liquipediaasante sana squash banana
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
November 23 2016 19:39 GMT
#16029
On November 24 2016 01:46 Cyx. wrote:
Show nested quote +
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?

Maybe I'm misunderstanding this, but I think what you want to do is often done by measuring how much time has passed since the last frame, and passing that value into your `move_creatures()`. Then you can scale that by movement speeds to get movement amounts:

last_time = pygame.time.get_time()
while not game_over:
time = pygame.time.get_time()
dt = time - last_time
self.move_creatures(dt)
last_time = time

// ...

def move_creatures(dt):
for c in self.creatures:
c.position += c.velocity * dt;

The creatures all move discrete distances. They have a speed, such as 1 or 2, and move that many squares per turn. Otherwise, yeah, that would make sense.

On November 24 2016 01:59 Manit0u wrote:
Have you tried tinkering with the frames? If I remember correctly you can speed up/slow down the game via the frames setting.

Yup. The frame rate is set to a maximum of 60 FPS, and it runs at that on my computer. If I lower that, then they move slower, but the player also now can move multiple times per draw. So I'm looking for a way to slow only the trolls down, without effecting the rest of the game, if that's possible.

On November 23 2016 13:49 meatpudding wrote:
Show nested quote +
On November 23 2016 13:23 WarSame wrote:
I'm making a dungeon game and my trolls around running around like they're on meth. I can't figure out how to calm them down. This is in pygame.

The heartbeat:
    def run_game(self):
# Heartbeat
while not (self.game_over or self.level.player.is_dead):
self.handle_events()
self.move_creatures()
self.draw_screen()
pygame.time.wait(100)
self.end_game()


where draw_screen is
    def draw_screen(self):
# Update game visuals
self.screen.fill((0, 0, 0))
self.draw_blocks()
pygame.display.flip()
self.clock.tick(60)


The problem is that I can make the trolls slow down by increasing the wait time between game cycles, but then the player moves too slowly. I'm looking for a fair way to slow down how frequently the trolls move. Any ideas?


Lots of ways to do this. In move_creatures you could add a counter like this
counter += 1
if counter < threshold: return
# reset the counter
counter = 0
...
# actual code here

This seems like a possibility. I'll give it a shot. Thanks!
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-11-23 20:22:10
November 23 2016 20:21 GMT
#16030
On November 23 2016 23:17 Nesserev wrote:
SMALL RANT
I'm really frustrated with the 4th Edition of 'The C++ Programming Language' by Bjarne Stroustrup. I loved the Special Edition, but it seems like the magic was lost a bit in this edition, and there's one thing that really fcking triggers me...

Uniform initialization... AKA ugly squiggly braces from hell... they're fucking ugly as shit, and the book is full of it.

This might sound dumb and shit, but it really ruins an otherwise perfectly good book for me.
END OF RANT


I actually really like the way C++ uses initialization lists. Everyone I show is like, whoa, neat, and it's very clear what its purpose is IMO. Also getting more usage in C++17 too so it's basically here to stay. What's wrong with the book?
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
November 23 2016 20:49 GMT
#16031
On November 24 2016 05:21 Blisse wrote:
Show nested quote +
On November 23 2016 23:17 Nesserev wrote:
SMALL RANT
I'm really frustrated with the 4th Edition of 'The C++ Programming Language' by Bjarne Stroustrup. I loved the Special Edition, but it seems like the magic was lost a bit in this edition, and there's one thing that really fcking triggers me...

Uniform initialization... AKA ugly squiggly braces from hell... they're fucking ugly as shit, and the book is full of it.

This might sound dumb and shit, but it really ruins an otherwise perfectly good book for me.
END OF RANT


I actually really like the way C++ uses initialization lists. Everyone I show is like, whoa, neat, and it's very clear what its purpose is IMO. Also getting more usage in C++17 too so it's basically here to stay. What's wrong with the book?


I agree that uniform initialization actually makes C++ a lot more concise and the code easier to write and follow. I see nothing wrong with that.
Time is precious. Waste it wisely.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-11-24 05:19:29
November 24 2016 05:17 GMT
#16032
--- Nuked ---
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
Last Edited: 2016-11-24 13:23:35
November 24 2016 13:23 GMT
#16033

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...
Time is precious. Waste it wisely.
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
November 24 2016 13:38 GMT
#16034

if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;


sweet baby jesus
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
BluzMan
Profile Blog Joined April 2006
Russian Federation4235 Posts
November 24 2016 21:49 GMT
#16035
On November 24 2016 14:17 Nesserev wrote:
Show nested quote +
On November 24 2016 05:21 Blisse wrote:
I actually really like the way C++ uses initialization lists. Everyone I show is like, whoa, neat, and it's very clear what its purpose is IMO. Also getting more usage in C++17 too so it's basically here to stay. What's wrong with the book?

There's nothing wrong with the book, and I don't mind when initializer lists are used for actual "lists" (e.g. vectors, strings, etc.). But I genuinely dislike the use of the first line over the second.
int i {0};
int i = 0;

And the book is full of lines like the first one... that's all. This just feels so unnecessary... it's the only C++11/14/17 feature that I can think of that I really dislike.


Curly brackets as a habit save you from the dreaded vexing parse.
You want 20 good men, but you need a bad pussy.
BluzMan
Profile Blog Joined April 2006
Russian Federation4235 Posts
November 24 2016 21:52 GMT
#16036
On November 24 2016 22:23 Manit0u wrote:

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...

Why would anyone write PHP these days? Quick and dirty stuff can be done with Node, and "proper" PHP looks a lot like a worse version of Java.
You want 20 good men, but you need a bad pussy.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
November 24 2016 21:59 GMT
#16037
On November 25 2016 06:52 BluzMan wrote:
Show nested quote +
On November 24 2016 22:23 Manit0u wrote:

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...

Why would anyone write PHP these days? Quick and dirty stuff can be done with Node, and "proper" PHP looks a lot like a worse version of Java.


Because PHP has the biggest market share so if you're maintaining a system it was probably written in PHP.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
Last Edited: 2016-11-25 02:50:38
November 24 2016 22:12 GMT
#16038
On November 25 2016 06:52 BluzMan wrote:
Show nested quote +
On November 24 2016 22:23 Manit0u wrote:

public static function bool2int($variable) {
if ($variable === TRUE) {
$result = (int) $variable;
} else if ($variable === FALSE) {
$result = (int) $variable;
} else {
$result = null;
}
return $result;
}


Kill me...

Why would anyone write PHP these days? Quick and dirty stuff can be done with Node, and "proper" PHP looks a lot like a worse version of Java.


"Proper" PHP app can be developed much faster and much cheaper than its Java counterparts while still adhering to all the "enterprise" bullshit.

Also, I'd rather do PHP than JS or, gods forbid, Java... (I know, I'm biased but Java is actually at the bottom of programming languages I'd like to work with and I've tried out quite a lot of them over the past years)
Time is precious. Waste it wisely.
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
November 25 2016 00:47 GMT
#16039
Anyone know of some good quality starter resources for responsive web design? Not using any libraries like bootstrap.
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Manit0u
Profile Blog Joined August 2004
Poland17420 Posts
Last Edited: 2016-11-25 02:51:08
November 25 2016 02:47 GMT
#16040
On November 25 2016 09:47 Birdie wrote:
Anyone know of some good quality starter resources for responsive web design? Not using any libraries like bootstrap.


Bootstrap is probably the best for starters since many products are using it and many other libraries are based on it (foundation, materialize, etc.). As an added bonus you have plenty of resources for that online.

May I ask why no libraries? There is very little point to reinventing the wheel if it's not absolutely necessary.

What kind of resources do you need exactly? General tips and tricks? Something like Google's material design guides? html5rocks? csstricks?
Time is precious. Waste it wisely.
Prev 1 800 801 802 803 804 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 56m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 572
BRAT_OK 90
Codebar 41
Livibee 31
StarCraft: Brood War
Jaedong 1495
GuemChi 1465
EffOrt 1325
Stork 698
Light 607
Larva 417
Snow 411
Mini 356
Rush 223
Barracks 222
[ Show more ]
Leta 119
hero 112
sSak 111
JYJ47
Aegong 37
Backho 34
sorry 29
zelot 26
soO 23
Terrorterran 16
HiyA 15
scan(afreeca) 12
Bale 9
Dota 2
qojqva3422
420jenkins258
syndereN218
Other Games
singsing2199
Sick375
DeMusliM352
crisheroes342
Lowko284
Hui .257
Liquid`VortiX150
oskar109
KnowMe96
XcaliburYe58
QueenE29
Trikslyr17
Organizations
Counter-Strike
PGL201
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 4
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2491
• WagamamaTV466
League of Legends
• Nemesis4280
• Jankos3067
• TFBlade809
Upcoming Events
LAN Event
1h 56m
Lambo vs Harstem
FuturE vs Maplez
Scarlett vs FoxeR
Gerald vs Mixu
Zoun vs TBD
Clem vs TBD
ByuN vs TBD
TriGGeR vs TBD
Korean StarCraft League
10h 56m
CranKy Ducklings
17h 56m
IPSL
1d 1h
dxtr13 vs OldBoy
Napoleon vs Doodle
LAN Event
1d 1h
BSL 21
1d 3h
Gosudark vs Kyrie
Gypsy vs Sterling
UltrA vs Radley
Dandy vs Ptak
Replay Cast
1d 6h
Sparkling Tuna Cup
1d 17h
WardiTV Korean Royale
1d 19h
IPSL
2 days
JDConan vs WIZARD
WolFix vs Cross
[ Show More ]
LAN Event
2 days
BSL 21
2 days
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
2 days
Wardi Open
2 days
WardiTV Korean Royale
3 days
Replay Cast
4 days
Kung Fu Cup
4 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
5 days
The PondCast
5 days
RSL Revival
5 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
5 days
WardiTV Korean Royale
5 days
RSL Revival
6 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
Stellar Fest: Constellation Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.