• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:00
CEST 19:00
KST 02:00
  • 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
[ASL21] Ro8 Preview Pt1: Inheritors14[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists19[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10
Community News
2026 GSL Season 1 Qualifiers22Maestros of the Game 2 announced92026 GSL Tour plans announced15Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid25
StarCraft 2
General
Team Liquid Map Contest #22 - The Finalists MaNa leaves Team Liquid Maestros of the Game 2 announced 2026 GSL Tour plans announced Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
2026 GSL Season 1 Qualifiers Sparkling Tuna Cup - Weekly Open Tournament INu's Battles#14 <BO.9 2Matches> GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base Mutation # 521 Memorable Boss
Brood War
General
[ASL21] Ro8 Preview Pt1: Inheritors BGH Auto Balance -> http://bghmmr.eu/ FlaSh: This Will Be My Final ASL【ASL S21 Ro.16】 Leta's ASL S21 Ro.16 review ASL21 General Discussion
Tourneys
[ASL21] Ro8 Day 1 [Megathread] Daily Proleagues [ASL21] Ro16 Group D Escore Tournament StarCraft Season 2
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Dawn of War IV Stormgate/Frost Giant Megathread Diablo IV Nintendo Switch Thread Total Annihilation Server - TAForever
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread 3D technology/software discussion European Politico-economics QA Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion McBoner: A hockey love story
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2323 users

The Big Programming Thread - Page 413

Forum Index > General Forum
Post a Reply
Prev 1 411 412 413 414 415 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.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-25 05:06:14
December 25 2013 05:04 GMT
#8241
On December 24 2013 09:21 RoyGBiv_13 wrote:
Show nested quote +
On December 23 2013 23:50 darkness wrote:
[Java]
Is it a good idea to have an interface of a class that has a lot of methods just to show some overview of functionalities? E.g. simply treating the interface as a Class.h file.


There have been plenty of opinions posted above. You've obviously opened up a can of worms.

I, for one, love the C-style header way of collecting function prototypes, but often my C structures are designed as differently as night and day compared to java objects. I'd probably hate to reference someone else's java class using it's interface.

In Java, while debugging or coding, you frequently reference the API and javadocs. Thus, when organizing your code for other people to use, try to make it fit within the same work flow that they already used. This is a key feature of successful projects. If you know someone else will reference your class, do all the work of understanding the class for them, and write it up in javadoc format. If you don't it will take more time overall for them to read through your code and figure out what to do, what the arguments mean, etc.

If you just want to make a quick reference for yourself, I love using the Interface feature as a virtual to-do list. I leave it in my project at the end for completion sake, so a lot of my projects have this C-style header interface.

It's your code, though, and you can make your own decision how to document it.

EDIT: Low Level/ OS developer here


Instead of that you could use TDD and write tests for each method, its basically exactly the same.

The only difference is, with interfaces you are kind of screwing with the code-base (there are interfaces where there shouldn't be), but with tests it won't affect your code-base.

In code avoid doing anything unless it makes the code simpler or better. If you are just using features for not their intended purposes you are turning your code into a pillar of pain in the long term.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
December 25 2013 07:09 GMT
#8242
Finished my Tic Tac Toe game. In the end, it is composed of a JFrame with 3 JPanels. Feel free to comment on any code, in particular the AI.

https://github.com/WarSame/TicTacToeGraeme
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
JieXian
Profile Blog Joined August 2008
Malaysia4677 Posts
December 25 2013 07:33 GMT
#8243
anyone using drupal cms here? @.@
Please send me a PM of any song you like that I most probably never heard of! I am looking for people to chat about writing and producing music | https://www.youtube.com/watch?v=noD-bsOcxuU |
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-12-25 08:49:43
December 25 2013 08:48 GMT
#8244
On December 25 2013 16:09 WarSame wrote:
Finished my Tic Tac Toe game. In the end, it is composed of a JFrame with 3 JPanels. Feel free to comment on any code, in particular the AI.

https://github.com/WarSame/TicTacToeGraeme


I suggest that you use MVC next time.

http://stackoverflow.com/a/26693

Some code example: http://leepoint.net/notes-java/GUI/structure/40mvc.html
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-25 11:32:08
December 25 2013 11:27 GMT
#8245
On December 25 2013 17:48 darkness wrote:
Show nested quote +
On December 25 2013 16:09 WarSame wrote:
Finished my Tic Tac Toe game. In the end, it is composed of a JFrame with 3 JPanels. Feel free to comment on any code, in particular the AI.

https://github.com/WarSame/TicTacToeGraeme


I suggest that you use MVC next time.

http://stackoverflow.com/a/26693

Some code example: http://leepoint.net/notes-java/GUI/structure/40mvc.html


It is MVC.

MouseHandler = Controller
Frame/Components = View
Players/Variables = Models

That leepoint link is a really bad example of MVC IMO. Its overly complicated and obtuse and not well implemented.

Always be careful about giving "blanket" suggestions like this, IMO a tictactoe game does not need MVC to make it better. In many ways it would make it more complex than it needs to be.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
Last Edited: 2013-12-25 16:30:16
December 25 2013 16:29 GMT
#8246
Mine is MVC, right?

Model = the data, which is my game array and variables.

View = paint*() which are all separate from the controlling logic.

Control = controlling logic, such as AI, and player choice.

In my case I can change the AI code as I want, and the view and model will automatically be able to handle that as long as I keep the interface the same. I can change the view, and as long as the interface is the same it will handle it. Etc.

But thank you for the suggestion! This last semester I have been learning about the architecture/paradigms and that was one I've used before, but this time I didn't really think about it. It was just supposed to be as modifiable as I could make it.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
JieXian
Profile Blog Joined August 2008
Malaysia4677 Posts
December 25 2013 17:14 GMT
#8247
On December 25 2013 16:09 WarSame wrote:
Finished my Tic Tac Toe game. In the end, it is composed of a JFrame with 3 JPanels. Feel free to comment on any code, in particular the AI.

https://github.com/WarSame/TicTacToeGraeme


erm sorry but how do i run it? I need a java compiler? like Visual basic for c?
Please send me a PM of any song you like that I most probably never heard of! I am looking for people to chat about writing and producing music | https://www.youtube.com/watch?v=noD-bsOcxuU |
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
Last Edited: 2013-12-25 17:32:32
December 25 2013 17:18 GMT
#8248
I think you do. If you have a Java IDE like Eclipse you can run it in there for sure.

EDIT: For some reason when I exported it as a JAR it won't run, so I can't really do that for you.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
Last Edited: 2013-12-25 20:15:22
December 25 2013 18:46 GMT
#8249
Ok, I added an executable JAR to the GitHub repo. Feel free to check that out. You can run the JAR without having to install any programs.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-12-25 22:53:45
December 25 2013 22:48 GMT
#8250
On December 25 2013 20:27 sluggaslamoo wrote:
Show nested quote +
On December 25 2013 17:48 darkness wrote:
On December 25 2013 16:09 WarSame wrote:
Finished my Tic Tac Toe game. In the end, it is composed of a JFrame with 3 JPanels. Feel free to comment on any code, in particular the AI.

https://github.com/WarSame/TicTacToeGraeme


I suggest that you use MVC next time.

http://stackoverflow.com/a/26693

Some code example: http://leepoint.net/notes-java/GUI/structure/40mvc.html


It is MVC.

MouseHandler = Controller
Frame/Components = View
Players/Variables = Models

That leepoint link is a really bad example of MVC IMO. Its overly complicated and obtuse and not well implemented.

Always be careful about giving "blanket" suggestions like this, IMO a tictactoe game does not need MVC to make it better. In many ways it would make it more complex than it needs to be.


Well, I'm used to a different style of MVC. E.g. a separate class for each of M-V-C. It's possible I didn't understand design though.

Edit: It doesn't look like this in my opinion: http://leepoint.net/notes-java/GUI/structure/40mvc.html
ParasitJonte
Profile Joined September 2004
Sweden1768 Posts
December 26 2013 08:55 GMT
#8251
Finished my (first) holiday mini-project! A machine learning decision tree (http://en.wikipedia.org/wiki/Decision_tree). Though it is very limited. It only handles discrete-type attributes. Also, while I have some tests I wouldn't be surprised to learn about bugs.

I'm going to clean up the page about but anyone interested in artificial intelligene, feel free to check it out (needs java, scala and simple build tool): https://github.com/MikaelUmaN/DecisionTree
Hello=)
Boske
Profile Joined December 2013
20 Posts
Last Edited: 2013-12-26 16:43:17
December 26 2013 16:13 GMT
#8252
On December 26 2013 03:46 WarSame wrote:
Ok, I added an executable JAR to the GitHub repo. Feel free to check that out. You can run the JAR without having to install any programs.


Tried it out, is it supposed to let the player win most of the time?
Edit: Played more games, seems like it manages to tie about 15% of the time. I guess it's pretty much random where the AI puts it unless you or the AI have 2 in a row?

Edit2: I looked closer at your code, it does indeed seem like it randomizes where to put it unless there is two in a row for either the AI or the Player. This makes going first move corner the best with about a 91.67% (11/12) winrate if my math is correct.
(if the AI doesn't go center first move you always win, if the AI goes center you put it on the opposite corner to where you first move and you win if the AI goes to any of the two remaining corners.)

So unless you want it to lose most of the time I suppose you have to add in more checks.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
Last Edited: 2013-12-26 17:36:29
December 26 2013 17:34 GMT
#8253
Yeah, the AI is not that strong. I figured since it's Tic Tac Toe... if it was strong you'd just tie all the time. The Tic Tac Toe game was designed to be extensible(i.e. 3x3, 4x4, 5x5...). The best method of implementing the AI is to have "win if you can", then "don't lose if you can" then "calculate the end results of every move and pick the one that has the best winning chance". However, that's really processing heavy and I didn't want to code it haha. So instead it just uses the random guess for the last one.

EDIT: Darkness, you're right, I think. But they are separate methods at least, so in this case hopefully that's enough.
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: 2013-12-26 23:02:34
December 26 2013 23:02 GMT
#8254
3x3 Tic-Tac-Toe is solved, check out Wikipedia if you want the algorithm. I implemented it before and it's pretty simple/naive. I believe with an arbitrary sized TTT board it's simple to force draws at the very least. They're all interesting AI expansions that I would suggest you take a stab at (great to talk about and really cool learning exp.)
There is no one like you in the universe.
sluggaslamoo
Profile Blog Joined November 2009
Australia4494 Posts
Last Edited: 2013-12-27 03:54:33
December 27 2013 03:48 GMT
#8255
On December 27 2013 02:34 WarSame wrote:
Yeah, the AI is not that strong. I figured since it's Tic Tac Toe... if it was strong you'd just tie all the time. The Tic Tac Toe game was designed to be extensible(i.e. 3x3, 4x4, 5x5...). The best method of implementing the AI is to have "win if you can", then "don't lose if you can" then "calculate the end results of every move and pick the one that has the best winning chance". However, that's really processing heavy and I didn't want to code it haha. So instead it just uses the random guess for the last one.

EDIT: Darkness, you're right, I think. But they are separate methods at least, so in this case hopefully that's enough.


On December 26 2013 01:29 WarSame wrote:
Mine is MVC, right?

Model = the data, which is my game array and variables.

View = paint*() which are all separate from the controlling logic.

Control = controlling logic, such as AI, and player choice.

In my case I can change the AI code as I want, and the view and model will automatically be able to handle that as long as I keep the interface the same. I can change the view, and as long as the interface is the same it will handle it. Etc.

But thank you for the suggestion! This last semester I have been learning about the architecture/paradigms and that was one I've used before, but this time I didn't really think about it. It was just supposed to be as modifiable as I could make it.


A controller is more of an interface, think of it like a game controller. It converts human readable inputs into something the program can understand.

Your code definitely lacks basics but its not MVC that needs to be looked into but rather its a lot more basic than that.

Have a look into functional decomposition and abstraction.

Each method should only do one thing, and named for doing that one thing, and your main function should read somewhat like a story. MVC moves towards responsibility driven design, but this sort of methodology is just adding a layer of complication that will make it impossible until you understand the basics of structured (non-OO) programming.

The code could definitely be written 100x better, but good job nevertheless. Finishing is always the hardest part IMO.
Come play Android Netrunner - http://www.teamliquid.net/forum/viewmessage.php?topic_id=409008
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
December 27 2013 04:24 GMT
#8256
What is the 100x better? I went through my original code and improved it a lot based off of his comments, so could you do the same thing? There was nothing that struck me as obviously bad, so there's really nothing left for me to catch for myself.

Anyway... the sad thing is I'm in 3rd year Software Engineering. Finally starting to actually use my free time to program.
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Whyn
Profile Joined December 2013
Denmark2 Posts
Last Edited: 2013-12-27 05:21:39
December 27 2013 04:33 GMT
#8257
Hi All

I'm new here

And i have been working on this little application for about a week now.

It started out to be for myself and my friends because i couldn't find anything like it elsewhere.
But now i have decided to share it

It's a Windows Form Application in C# that will only use your Twitch.tv username and notify you when a channel you are following on Twitch.tv comes Live.

See more here: https://github.com/WhyN92/WhyNsStreamWatcher

I have no idea if this have been created before, but here it is
Feedback is appreciated, and this is my first time making something public and using GitHub.


Whyn
Woot?
Amnesty
Profile Joined April 2003
United States2054 Posts
December 27 2013 04:41 GMT
#8258
I cant imagine many people wanting to put there name/pass into a app from a user with 1 post.
Besides that, twitch.tv does that for you anyway with texts/emails via its settings.
The sky just is, and goes on and on; and we play all our BW games beneath it.
Whyn
Profile Joined December 2013
Denmark2 Posts
December 27 2013 04:52 GMT
#8259
You only type your username in

And for my experience is E-mails delayed and just a bit spamy sometimes.
Woot?
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
December 27 2013 05:02 GMT
#8260
Whyn, your app seems like a cool idea. Thanks for making it!
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Prev 1 411 412 413 414 415 1032 Next
Please log in or register to reply.
Live Events Refresh
Monday Night Weeklies
16:00
#49
RotterdaM596
TKL 193
IndyStarCraft 192
BRAT_OK 124
SteadfastSC111
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 596
Hui .243
TKL 193
IndyStarCraft 192
BRAT_OK 124
SteadfastSC 111
UpATreeSC 65
StarCraft: Brood War
Calm 5195
EffOrt 931
actioN 635
Stork 506
ggaemo 463
Free 212
Barracks 120
Rush 116
PianO 95
Hyun 83
[ Show more ]
Shinee 79
ajuk12(nOOB) 36
Killer 33
Sacsri 29
Sexy 29
Bale 26
soO 24
HiyA 20
Terrorterran 18
910 16
GoRush 15
Dota 2
qojqva5107
BananaSlamJamma356
Counter-Strike
byalli568
fl0m487
Super Smash Bros
Mew2King65
Heroes of the Storm
Khaldor240
Other Games
Grubby2820
singsing2067
B2W.Neo1203
ceh9573
KnowMe336
Beastyqt291
crisheroes215
Sick208
Trikslyr43
C9.Mang041
MindelVK7
Organizations
Dota 2
PGL Dota 2 - Main Stream365
StarCraft: Brood War
Kim Chul Min (afreeca) 9
Other Games
BasetradeTV5
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 17 non-featured ]
StarCraft 2
• StrangeGG 94
• intothetv
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• blackmanpl 30
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
League of Legends
• Nemesis4292
• TFBlade679
Other Games
• WagamamaTV486
• Shiphtur232
• imaqtpie66
Upcoming Events
Replay Cast
7h
Replay Cast
16h
Afreeca Starleague
17h
Leta vs YSC
GSL
1d 16h
Rogue vs Percival
Zoun vs Solar
Replay Cast
2 days
GSL
2 days
Cure vs TriGGeR
ByuN vs Bunny
The PondCast
2 days
KCM Race Survival
2 days
Replay Cast
3 days
Replay Cast
3 days
[ Show More ]
Escore
3 days
Replay Cast
4 days
Replay Cast
4 days
IPSL
4 days
Ret vs Art_Of_Turtle
Radley vs TBD
BSL
5 days
Replay Cast
5 days
uThermal 2v2 Circuit
5 days
BSL
6 days
IPSL
6 days
eOnzErG vs TBD
G5 vs Nesh
Replay Cast
6 days
Wardi Open
6 days
Afreeca Starleague
6 days
Jaedong vs Light
Monday Night Weeklies
6 days
Liquipedia Results

Completed

Escore Tournament S2: W4
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W5
KK 2v2 League Season 1
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
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 © 2026 TLnet. All Rights Reserved.