Search Results

Search found 2 results on 1 pages for 'evthim'.

Page 1/1 | 1 

  • Knowing state of game in real time

    - by evthim
    I'm trying to code a tic tac toe game in java and I need help figuring out how to efficiently and without freezing the program check if someone won the game. I'm only in the design stages now, I haven't started programming anything but I'm wondering how would I know at all times the state of the game and exactly when someone wins? Response to MarkR: (note: had to place comment here, it was too long for comment section) It's not a homework problem, I'm trying to get more practice programming GUI's which I've only done once as a freshman in my second introductory programming course. I understand I'll have a 2D array. I plan to have a 2D integer array where x would equal 1 and o would equal 0. However, won't it take too much time if I check after every move if someone won the game? Is there a way or a data structure or algorithm I can use so that the program will know the state (when I say state I mean not just knowing every position on the board, the int array will take care of that, I mean knowing that user 1 will win if he places x on this block) of the game at all times and thus can know automatically when someone won?

    Read the article

  • Concurrent Programming:Should I write a sequential program first, then add thread safety?

    - by evthim
    I'm working on a project where we have to create a number of threads(actual number will be inputted in by testers (TA's)). I'm having trouble not only with the programming but also with the design, I can't wrap my head around all of the threads that will be invoked and where I might cause errors. The project is due soon so I don't want to waste time on this if it'll actually set me back, but I was wondering if I should write the program like only one thread will be running and everything should be sequential and then later go back and try to add the thread safety parts of the code? Would that take twice the original amount of time? Project Description: Note:I'm going to be as vague as possible so I don't violate any honor codes, sorry :( your program should accept n number of objectA threads, m number of objectB threads, and r number of objectC objectB threads interact with code in objectA. objectA threads interact with code in objectB and objectC objectB and objectC don't directly interact, but do so indirectly through objectA -ex: objectB needs something from objectA. objectA gets the result for that something by calling objectC my confusion stems mostly from the fact that all of this interactions will be done by m+n threads and there are various restrictions throughout the descriptions, like objectB can request something from objectA, and objectA has to wait for objectC to finish that something before returning it to objectB. Also each objectA thread can only work on one instruction from objectB at a time, etc. etc. I just want to know if I write the code so that there is only 1 objectA, 1 objectB and 1 object C, can I go back and easily modify it so that those 1's can be changed to m, n and r? Sorry again, if my description is a little bit confusing.

    Read the article

1