• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:08
CET 14:08
KST 22:08
  • 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
RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13
Community News
RSL Season 3: RO16 results & RO8 bracket3Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge1[TLMC] Fall/Winter 2025 Ladder Map Rotation14Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA9
StarCraft 2
General
RSL Season 3: RO16 results & RO8 bracket GM / Master map hacker and general hacking and cheating thread Mech is the composition that needs teleportation t SC: Evo Complete - Ranked Ladder OPEN ALPHA RotterdaM "Serral is the GOAT, and it's not close"
Tourneys
RSL Revival: Season 3 Constellation Cup - Main Event - Stellar Fest 2025 RSL Offline Finals Dates + Ticket Sales! $5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 500 Fright night Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle What happened to TvZ on Retro? BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review BW General Discussion
Tourneys
[BSL21] GosuLeague T1 Ro16 - Tue & Thu 22:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET
Strategy
Current Meta How to stay on top of macro? PvZ map balance Simple Questions, Simple Answers
Other Games
General Games
Clair Obscur - Expedition 33 Beyond All Reason Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile
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
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Games Industry And ATVI About SC2SEA.COM
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
Dyadica Evangelium — Chapt…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1989 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
Poland17440 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
Poland17440 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
Hyrule19156 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
Spain18125 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
Hyrule19156 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
Poland17440 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
Poland17440 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
Poland17440 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
Poland17440 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 9h 52m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
trigger 89
Trikslyr25
gerald23 12
StarCraft: Brood War
Calm 5127
Rain 3063
actioN 2906
Horang2 2162
GuemChi 1822
Bisu 1489
Hyuk 1129
Stork 367
BeSt 362
Pusan 242
[ Show more ]
Last 211
Soma 197
Light 160
EffOrt 147
Leta 141
Soulkey 82
hero 66
Killer 65
Rush 47
ToSsGirL 44
Barracks 39
Aegong 38
Mind 34
Free 30
Sharp 26
JulyZerg 22
Movie 20
Backho 18
Shine 15
scan(afreeca) 14
yabsab 12
Shinee 9
Terrorterran 9
ivOry 9
Hm[arnc] 8
zelot 7
sas.Sziky 3
Dota 2
singsing2201
Dendi533
XcaliburYe116
Counter-Strike
olofmeister1808
x6flipin611
allub234
oskar76
Other Games
B2W.Neo1182
Fuzer 270
hiko75
Organizations
Dota 2
PGL Dota 2 - Main Stream12598
StarCraft: Brood War
lovetv 10
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH174
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 2
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 1477
League of Legends
• HappyZerGling106
Upcoming Events
Replay Cast
9h 52m
RSL Revival
18h 22m
herO vs Zoun
Classic vs Reynor
Maru vs SHIN
MaxPax vs TriGGeR
OSC
23h 52m
BSL: GosuLeague
1d 7h
RSL Revival
1d 18h
WardiTV Korean Royale
1d 22h
RSL Revival
2 days
WardiTV Korean Royale
2 days
IPSL
3 days
Julia vs Artosis
JDConan vs DragOn
RSL Revival
3 days
[ Show More ]
Wardi Open
4 days
IPSL
4 days
StRyKeR vs OldBoy
Sziky vs Tarson
Replay Cast
4 days
Monday Night Weeklies
5 days
Replay Cast
5 days
Wardi Open
5 days
Replay Cast
6 days
Wardi Open
6 days
Liquipedia Results

Completed

Proleague 2025-11-16
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
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

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 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.