Monday, 2024-04-29, 3:16 PM
Welcome Guest

Distance Education

[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 2
  • 1
  • 2
  • »
Forum moderator: Christos  
Forum » Software Development » RE:Work » Upcominhg sac (Anyone know anything specific about it?)
Upcominhg sac
Dr4c0niusDate: Saturday, 2009-05-30, 7:57 AM | Message # 1
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Presumably sac two is on python programming. Anyone got any specifics?

Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Monday, 2009-06-01, 1:27 PM | Message # 2
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
All I know is that I let out a few profanities on the school bus as I read through the task.

An excel document. EXCEL! I can think of at least two far more secure ways to store the information in the program itself. But no. We have to secure an excel document. dry


~ Click it
 
Dr4c0niusDate: Tuesday, 2009-06-02, 2:02 PM | Message # 3
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Facepalm! Ah well, users will be users...

Its IT, not engineering, what did you expect wink

Well, after the sac is over (of course), would you be willing to post your program? I'm interested as to how everyone else solved stuff.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Tuesday, 2009-06-02, 2:32 PM | Message # 4
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Sure. shall we say, a week or so after the deadline? (stragglers can't copy) That way we can't be accused of helping eachother. If we make it 10 days, then they would have lost all the marks anyway.

You know, I tried this with the painter program but nobody else posted sad

So, I say you first this time tongue


~ Click it
 
Dr4c0niusDate: Tuesday, 2009-06-02, 2:52 PM | Message # 5
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Haha, sure. I've actually spent time on this program, so I won't be quite so hesitant this time round biggrin

Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Wednesday, 2009-06-17, 5:31 AM | Message # 6
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
It's just about time. Should we check with the teachers first to make sure that everyone has handed it in?

Added (2009-06-17, 5:31 Am)
---------------------------------------------
I sent an email Trevor Molly about it, and got this reply:

Quote
Hi Hayden - I would not advise you to share your code as you will be
using the last program you wrote in unit 4. You will be able to do this
later in the year.
regards

Trevor Molloy
IT Applications /Software Development
Distance Education Centre Victoria
848 00133
tmolloy@distance.vic.edu.au

So that ruins things. I'm going to propose we just set up a scenario and write a solution for that. If people are willing to do the effort, then we have a program we can compare to each others.


~ Click it
 
Dr4c0niusDate: Wednesday, 2009-06-17, 11:38 AM | Message # 7
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Yeah, it'd be nice to have a whole weekend to write some code anyway. It'll probably help my marks and aside from that I am kind of interested in other techniques.

Sorry for not posting in this thread sooner. I've pretty much had, since last week - Exams, exams, gat, drunk, hangover, banned from posting, bad cold biggrin In that order, day by day.

Are you using the OOP bits, like classes and defines yet?


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

Message edited by Dr4c0nius - Wednesday, 2009-06-17, 11:39 AM
 
HaydenJohnsDate: Thursday, 2009-06-18, 1:10 PM | Message # 8
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Just started on classes. Took me a few days to get my head around the concept. wacko

So, what shall we have for the scenario? Any ideas? Do you think there's something from the challenges in the python book that we could use as a base?


~ Click it
 
Dr4c0niusDate: Friday, 2009-06-19, 11:11 AM | Message # 9
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
*Goes for python book* Hmmm, a lot of the challenges are about improving the existing programs. Could be interesting, though.

Personally I'm kind of interested in encryption, but I'm not sure how easy that would be to implement. Maybe a program that performs some kind of function on files. (stripping unnecessary blank lines from a text file, encrypts the file, whatever)

Another thing I quite like is python-ogre (I think I posted a link to it before), but its a little (at our level) advanced to do anything useful in, and it took me weeks to learn the amount needed to create (and debug enough to work) even a simple program that loaded a 3d object and a background :/

I would be quite interested in doing something with image libraries (like changing formats, displaying in a window etc) but that would probably be pretty hard as well biggrin


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Friday, 2009-06-19, 2:50 PM | Message # 10
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
That's getting a little bit advanced. Perhaps a little less enthusiasm would be good tongue

How about a console game (like the guess my number/hangman/so on) that keeps a list of high scores?


~ Click it
 
Dr4c0niusDate: Friday, 2009-06-19, 5:10 PM | Message # 11
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
That sounds interesting as well. I should probably let you choose the specifications, as I tend to leap head-first into incredibly difficult projects without realising the real difficulty they pose biggrin

Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Saturday, 2009-06-20, 5:41 AM | Message # 12
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Well, what would you suggest for the game (something different to whats in the book, ruling out hangman and tic tac toe)? Preferably something that doesn't involve AI, but that can be worked around.

It would:

>Have to save the top five scores
>Be able to read the high scores
>Have a menu
>Whatever else we think of

A few ideas for the game:

Connect 4 - Has AI, could be tricky to make it a game of skill. High scores are a problem for this as well.

Guess Who - OOP, tricky. AI as well.

Reversi - AI, could be tricky to make it a game of skill. High scores would be the number of tokens you have at the end.

I don't want to do card games, as that starts to get trickier and we'll need OOP for that (something that I can't do right now). But it should be tricker than the 'guess my number' game.

I'd go with the Reversi one, but you might be able to think of something better.


~ Click it
 
Dr4c0niusDate: Saturday, 2009-06-20, 10:14 AM | Message # 13
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Im going with reversi and connect 4 at the moment, so lets make it reversi. Do we implement AI? I might not have a lot of time to code this until the holidays, btw, I've got a spec sac on wednesday/thursday.

Anyone else who wants to try this, you're welcome to.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Saturday, 2009-06-20, 12:17 PM | Message # 14
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Hmm... AI for it could be trickier than I thought. Some moves are illegal, so you would need a check on it. Ensuring the AI only made valid moves would be tricky to say the least; it's rather complex.

4 in a row would be easier to build (not to mention within our ability), but high scores could be an issue (unless its a "wins in a row" thing).

Another option is to get Christos to set up a sub forum for us, and we work together to build a somewhat more difficult program. We would learn less about individual code styles, but we would learn more about how to code.


~ Click it
 
Dr4c0niusDate: Sunday, 2009-06-21, 5:57 AM | Message # 15
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Well, whatever it is I'll do it biggrin

If we end up working together on a complex project, it'll probably necessary to get fairly complex structure going, ie we each work on a class at a time or something and add it to the final thing, so I'd start off with a fairly simple program we each write separately before starting a complex project.

We could work separately on connect 4, then try to create a reversi game with ai and graphics? I'd imagine that it would be fairly easy to write step by step, getting a human vs human console-only game working, then ai, then graphics. Or something like that, at least.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Sunday, 2009-06-21, 9:33 AM | Message # 16
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Agreed. I won't get started until the holidays though.

~ Click it
 
Dr4c0niusDate: Sunday, 2009-06-21, 4:13 PM | Message # 17
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Likewise, ive got through the majority of sacs and exams, but ive still got one left next week.

Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Wednesday, 2009-06-24, 11:42 AM | Message # 18
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Well, I've started to test the waters of the connect four idea. I think it should be plausible (software objects will help. A lot.), but getting it to recognize a win could be difficult with diagonals.

I say go ahead with the connect 4 idea


~ Click it
 
Dr4c0niusDate: Thursday, 2009-06-25, 1:06 PM | Message # 19
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
+1 for connect 4, let us code. Ai will be hard though, but ill add that last.

Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Saturday, 2009-06-27, 1:17 PM | Message # 20
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Well, I'm stumped. I've got the grid/place counter thing working, but I'm not sure how to get the game to recognise that a win has been made. That is, other than making an exhaustive list of every possible way to win like what happens in the naughts and crosses game in the book.

Oh, and I just learned that its a 7x6 grid. I have 7x7. Ah, well, time to change code.


~ Click it
 
Dr4c0niusDate: Sunday, 2009-06-28, 5:39 AM | Message # 21
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Haha, i had to look it up on wikipedia to find out the grid size biggrin

Ive got horizontal and vertical checking working, and im working on diagonal checking now.

What I did was make it go both left and right/up and down and report how many squares it could go in each direction, add them together and add one. Like this:

___def checkRow(self, y, x, colour):
______currentRow = 0 # Sentry variable
______lineTotal = 0 # How many matches have we found this line?
______setBreak = 0

______if self.matrix[y][x] == colour: # If the square we are checking matches
_________lineTotal += 1 # count it, its in the line
______else:
_________return 0 # The square is not the right colour

______for currentRow in range(1,7): # Check forwards
_________if (x - currentRow >= 0):
____________if (self.matrix[y][x - currentRow] != colour):
_______________setBreak = 0
_______________break # It must not be connected; leg it!
____________else:
_______________lineTotal += 1 # Increment number of matches found
____________if setBreak == 1:
________________break
_________if setBreak == 1:
____________break

______setBreak = 0

______for currentRow in range(1,7): # Check backwards
_________if (x + currentRow <= 7):
____________if (self.matrix[y][x + currentRow] != colour):
_______________break # It must not be connected; leg it!
____________else:
_______________lineTotal += 1 # Increment number of matches found
____________if setBreak == 1:
________________break
_________if setBreak == 1:
____________break

______return lineTotal # Tell our result!

Ignore the underscores, indentation doesn't work without them.

Edit: found a fairly major bug biggrin


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

Message edited by Dr4c0nius - Sunday, 2009-06-28, 8:31 AM
 
HaydenJohnsDate: Sunday, 2009-06-28, 9:52 AM | Message # 22
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Just from reading that I can tell that you have better skills than I have.

It looks like you've got it pretty well set out. Each of the spaces on the grid for me is an object with the attributes xpos, ypos, value, playable, winnable (last one not used yet, something for the AI to chew on)

So, I was going to have to place all 42 objects in a tuple and then check the values of the relevant attributes.


~ Click it
 
Dr4c0niusDate: Sunday, 2009-06-28, 12:01 PM | Message # 23
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
I've got the objects stored as a tuple, containing another 7 tuples made up of strings containing the counter (yellow, red, blank) XD

If you want to see the whole source code, go to ftp://draconius.ath.cx/ . I probably won't have my server up till about 9-10 am in the morning though, and I turn it off around 11 PM-12 AM

Edit:

Things implemented -
basic two-player connect 4 (checks for wins)

Things not implemented
good gui (console-based atm, i was thinking of maybe even using ogre to make it 3d)
ai (is very hard to write!)
high scores (easy, ill get to work on them next)


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

Message edited by Dr4c0nius - Sunday, 2009-06-28, 3:19 PM
 
HaydenJohnsDate: Sunday, 2009-06-28, 2:45 PM | Message # 24
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Still need to get the check to work. And it's basically going to stay as console, because I haven't touched guis before.

And high scores is easy.


~ Click it
 
Dr4c0niusDate: Monday, 2009-06-29, 3:12 PM | Message # 25
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Ok, got so far -

Fully working detection of wins
2 players
Decent (well, playable) gui - for a console project, it's as good as I can make it without buffering and input
High scores, top 5, listed by score and saved to file.

And its officially v0.0.2! I <3 incrementing version number!

I'm pretty that's the initial goals complete, next to ai then gui.

Unfortunately, I may not be able to spend much time on this as some wonderful caring person at my tafe decided that all the VET students should come in on the holidays 9AM-5PM for a whole week angry


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Monday, 2009-06-29, 3:44 PM | Message # 26
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
show off. I haven't done much more on it yet.

and the tafe thing sucks


~ Click it
 
Dr4c0niusDate: Monday, 2009-06-29, 3:55 PM | Message # 27
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
XD

Lol, nah its because I got really bored on saturday/sunday and did this, as opposed to actual profitable VCE homework. You have permission to boast about the things you did that didn't involve programming computers in an empty room biggrin

That being said, I sort of don't know how to write AIs at all. The only thoughts I have are a) working out EVERY SINGLE POSSIBLE MOVE or b) making it go for the square that will make the most things connect. Any thoughts on alternatives?


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Tuesday, 2009-06-30, 4:37 AM | Message # 28
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Keeping in mind I still need to get the check working, this would be the pseudocode for the AI:

BEGIN
_____IF move can be made that wins THEN
__________make winning move
_____ELSEIF move can be made that stops opponent from winning THEN
__________Block opponent
_____ELSE
__________Place randomly
END

That would have been my basic one until I started trying to improve it; I'd make the 'place randomly' one what will connect the most squares. You could do it by making a second check function that goes through and says "If something goes here, then how many squares will be lined up?


~ Click it
 
Dr4c0niusDate: Tuesday, 2009-06-30, 2:01 PM | Message # 29
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Hmmmm.... AIs are hard =D

Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Wednesday, 2009-07-08, 2:31 PM | Message # 30
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
That they are.

But it looks like you're going to have a far more impressive result on this then I am. I just got around to starting checking tonight after being sick for almost a week now. I may as well have laryngitis with the state of my throat at the moment.

Added (2009-07-08, 12:53 Pm)
---------------------------------------------
I'm completely lost in the check. I had another look over your code, and it looks like there's another few functions that go along with the one that you posted - no inspiration there. I've gotten it to recognise that the board is full, but I still have no idea about how I'm going to get it to recognise there's four in a row.

Added (2009-07-08, 2:29 Pm)
---------------------------------------------
Got my head around the concept of the check: I'm essentially do the same thing that the tic tac toe game does, for each row, each column, and eventually each diagonal combination checked to see if its met.

so for the grid (the positions are given for x,y and start at the bottom left) of 7x6 spaces, a row only has 4 possible combinations, with the x values of:

1,2,3,4
2,3,4,5
3,4,5,6
4,5,6,7

similarly, the combination of y values that can give a win in a column are:
1,2,3,4
2,3,4,5
3,4,5,6

To get diagonal answers is a little harder, but it can be plotted out on paper to get the list for this as well.

using these lists of answers, spread across a few functions (which I've just discovered can be nested, by the way. I've attached a python file for u to look at), it should be possible to check to see if a valid move can be made.
So, pseudocode function, replacing english commands with the appropriate nested functions:

Code

BEGIN
____check for win in each row
____check for win in each column
____check for win in diagonals
____IF a win has been made THEN
________Notify about win
____END IF
END

Added (2009-07-08, 2:30 Pm)
---------------------------------------------

Code
#Demsonstration of nested functions

def function(x):
     def nestedfunction(a):
         y=a + 1
         return y
     x=nestedfunction(x)
     return x

number = int(raw_input("Pick an integer:"))

try:
     print nestedfunction(number)
except:
     print "nestedfunction() cannot be accessed"

try:
     print function(number)
     print "standard function() can be accessed"
except:
     print "you shouldn't see this"

Added (2009-07-08, 2:31 Pm)
---------------------------------------------
Turns out that it accepts the multiple space thing if you enclose it in the "code" tag


~ Click it
 
Dr4c0niusDate: Wednesday, 2009-07-08, 5:38 PM | Message # 31
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Ah k, thanks for the tip. I can't upload my program, though, the text is too long biggrin Oh well. Even though I haven't really got everything done (ai, gui), I'm going to have to leave it where it is at the moment, as I really need to spend time on my other subjects and I haven't actually done much homework at all yet.

I'll still check back on the forums regularly (couple of times a day, its in my "check" folder with slashdot and gmail cool ) to see if anything comes up, though. Leave a message if you want me for anything.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Friday, 2009-07-10, 11:03 AM | Message # 32
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Understood. you probably should have done the homework first though tongue

And break it up into a few sections: Place the first few functions/classes/whatever into one post, then a few more in the next, etc.

Added (2009-07-10, 9:37 Am)
---------------------------------------------
Finished horizontal and vertical checking. It's not as ugly as I thought it was going to be, but it's going to be a pain doing the diagonal checking. I did some math, and its something like 20 possible combinations, and I can't cut corners using the 'for' command.

so rather than:

for i in range(6):
____if grid[0][i] == "X"

I have to literally map out each and every possible combination. Long and tedious programming sad

Added (2009-07-10, 11:01 Am)
---------------------------------------------
Just got the diagonal check to work... After drawing the grid on a whiteboard and mapping out every possible way to win - 24 ways, by the way.

Here's the code for the diagonal check - just to show how ugly it is dry

Added (2009-07-10, 11:03 Am)
---------------------------------------------

Code
if grid[3][0] == grid[4][1] == grid[5][2] == grid[6][3] != " ":
              return True
                
          elif grid[2][0] == grid[3][1] == grid[4][2] == grid[5][3] != " ":
              return True
          elif grid[3][1] == grid[4][2] == grid[5][3] == grid[6][4] != " ":
              return True
                
          elif grid[1][0] == grid[2][1] == grid[3][2] == grid[4][3] != " ":
              return True
          elif grid[2][1] == grid[3][2] == grid[4][3] == grid[5][4] != " ":
              return True
          elif grid[3][2] == grid[4][3] == grid[5][4] == grid[6][5] != " ":
              return True
                
          elif grid[0][0] == grid[1][1] == grid[2][2] == grid[3][3] != " ":
              return True
          elif grid[1][1] == grid[2][2] == grid[3][3] == grid[4][4] != " ":
              return True
          elif grid[2][2] == grid[3][3] == grid[4][4] == grid[5][5] != " ":
              return True
                
          elif grid[0][1] == grid[1][2] == grid[2][3] == grid[3][4] != " ":
              return True
          elif grid[1][2] == grid[2][3] == grid[3][4] == grid[4][5] != " ":
              return True
                
          elif grid[0][2] == grid[1][3] == grid[2][4] == grid[3][5] != " ":
              return True

Added (2009-07-10, 11:03 Am)
---------------------------------------------

Code
        #Travelling right and down
          elif grid[0][3] == grid[1][2] == grid[2][1] == grid[3][0] != " ":
              return True
                
          elif grid[0][4] == grid[1][3] == grid[2][2] == grid[3][1] != " ":
              return True
          elif grid[1][3] == grid[2][2] == grid[3][1] == grid[4][0] != " ":
              return True
                
          elif grid[0][5] == grid[1][4] == grid[2][3] == grid[3][2] != " ":
              return True
          elif grid[1][4] == grid[2][3] == grid[3][2] == grid[4][1] != " ":
              return True
          elif grid[2][3] == grid[3][2] == grid[4][1] == grid[5][0] != " ":
              return True
                
          elif grid[1][5] == grid[2][4] == grid[3][3] == grid[4][2] != " ":
              return True
          elif grid[2][4] == grid[3][3] == grid[4][2] == grid[5][1] != " ":
              return True
          elif grid[3][3] == grid[4][2] == grid[5][1] == grid[6][0] != " ":
              return True
                
          elif grid[2][5] == grid[3][4] == grid[4][3] == grid[5][2] != " ":
              return True
          elif grid[3][4] == grid[4][3] == grid[5][2] == grid[6][1] != " ":
              return True
                
          elif grid[3][5] == grid[4][4] == grid[5][3] == grid[6][2] != " ":
              return True
                
          else:
              return False


~ Click it

Message edited by HaydenJohns - Friday, 2009-07-10, 11:04 AM
 
Dr4c0niusDate: Friday, 2009-07-10, 3:46 PM | Message # 33
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Ha, yes I probably should have. I got told that I was going to lose a week of worktime on sunday... the day I pretty much finished...

Your code is probably faster, though certainly more... verbose biggrin


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Saturday, 2009-07-11, 7:11 AM | Message # 34
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
pfft. not all the code is like that. Other parts are a bit more elegant.

To tell the truth, that section was a bit of a rushed job. I haven't structured the code like you have - it doesn't check to see how many it can line up. As such, I didn't have anything to work with for the diagonal check. Rather than work on an elegant and attractive way to do run the check, I just lost patience with the whole thing and just opted for an uglier 'brute force' solution.

Added (2009-07-11, 7:11 Am)
---------------------------------------------
Oh, and I could have made it worse lol

Code
if grid[3][0] == grid[4][1] == grid[5][2] == grid[6][3] != " " or grid[2][0] == grid[3][1] == grid[4][2] == grid[5][3] != " "....:
      return true

now imagine looking at that wacko


~ Click it
 
Dr4c0niusDate: Sunday, 2009-07-12, 9:52 AM | Message # 35
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
You could try using a lookup table and use a for loop to travel through the winning moves checking them. Although that would require a rewrite, which nobody in their right mind would want to do biggrin

I hate rewriting code...


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Sunday, 2009-07-12, 11:07 AM | Message # 36
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
I could, but I'm not going to change code that works perfectly fine.

And by lookup table I take it you mean a dictionary? I'm a bit blank about how that would work.

I've given up on the AI (time constraints - homework takes priority), so I'm happy to publish now with it working as a 2 player game.


~ Click it
 
Dr4c0niusDate: Tuesday, 2009-07-14, 11:47 AM | Message # 37
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Agreed. Its pretty much entirely a learning project, and polishing a project that already works perfectly is a waste of time.

How do you attach/upload files? The .py file I have is 2KB, so it's well below the sites limit, I'm just not entirely sure how to upload it tongue


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Tuesday, 2009-07-14, 2:31 PM | Message # 38
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Hmm... It says illegal image format.

I checked the page source, and didn't see anything that would let us get around the validation with javascript injection.

I'm going to rename my file so that it ends with *.jpg

Added (2009-07-14, 1:51 Pm)
---------------------------------------------
no luck.

Added (2009-07-14, 2:31 Pm)
---------------------------------------------
http://rapidshare.com/files/255671487/connect4.py.html

Just upload it to rapidshare. Christos tried, but couldn't fix the issue


~ Click it
 
Dr4c0niusDate: Tuesday, 2009-07-14, 3:05 PM | Message # 39
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Ok. Well, for the moment, mine is hosted at ftp://draconius.ath.cx/ in the base directory.

And christos, if you are reading this, please don't DDoS my server tongue


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Wednesday, 2009-07-15, 1:28 PM | Message # 40
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
no high score file = error

but just looking over the file for the first time says that you know a lot more than I do about python. Did the book tell you about those modules or did you find them yourself?

Added (2009-07-15, 1:28 Pm)
---------------------------------------------
Oh, and I don't quite understand why you bothered with some of the software classes. I mean, sure it might give you a more organized setup, but it is a tad unnecesary.

And I forgot about the high score thing. Oops wacko


~ Click it
 
Dr4c0niusDate: Wednesday, 2009-07-15, 3:47 PM | Message # 41
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Thanks for telling me about the high score error, I didn't realise that except statments didn't need brackets. Fixed now.

The modules are the result of some googling to find out how to output code to the shell (or command prompt biggrin ) and some more googling to find out how to detect operating systems. Python itself doesn't have a clear-screen function so I had to write my own, does it work properly under linux for you?

The classes were created as I added functionality to the program, the only really needful one was board because the board had to be an object. It was fairly easy to put like defines in the same class rather than leaving them on their own. The structure sucks a bit, but hopefully it'll get better.

Would I be able to see your code? I have a tendancy to make my code very very complex, and I'd like to try and view other methods of doing stuff so I can make it more understandable.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Sunday, 2009-07-19, 11:59 AM | Message # 42
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
does the rapidshare link work still? You should be able to open it in IDLE.

and I can't get it to run in terminal - I know how to and have done so before. The clear screen function doesn't have much effect in IDLE, but it does run.

I had to make one minor change to the program though. I added the following three lines to the top (ignore the first, that's telling the script where to find the files it needs)

Code
#!/usr/bin/python/
scoreFile = open("highscore.dat","a")
scoreFile.close()

It gets rid of an error where the program fails to load if it can't find the high scores file.

Added (2009-07-17, 2:26 Pm)
---------------------------------------------
Draconius? Get it working?

*tap*

Added (2009-07-19, 11:59 Am)
---------------------------------------------
*bump*


~ Click it
 
Dr4c0niusDate: Monday, 2009-07-20, 5:14 PM | Message # 43
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Sorry about that, I was away.

The clear screen function I made is kind of terrible; I really think a function like it should be build into the python framework or something. It will NOT work with idle, idle doen't even
have a native clear screen function so the closest you can do is fill the screen with lines sad

If you get rid of the brackets in all the except statments, it deals with any errors to do with the high score file by creating a fresh copy. With the brackets, python doesn't find an error, because it looks inside the brackets for the error that happened and finds a NULL. Without brackets it deals with all errors. No error is thrown by a file that already exists.

I have no trouble running it under windows, I'll find a linux bootable cd image and fix it at some stage.

I'm going to bed now, I'll have a look at the program you wrote tomorrow. I kind of need sleep, sorry biggrin


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Wednesday, 2009-07-22, 2:09 PM | Message # 44
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Nah, no problem.

and I just got my SAC result back today. Very high range (I'm not a fan of the DECV marking system dry ), so at least an A


~ Click it
 
Dr4c0niusDate: Thursday, 2009-07-23, 11:53 AM | Message # 45
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
I've had a look through your project; the code is immaculate as far as I can tell.

The tendancy to use large chunks of data as opposed to alogrithms is actually more appropriate in this case, but I'm not sure how this style could expand to larger projects and grids. Making connect 6 on a 9x10 grid, for example, would require a LOT of writing, thats my only criticism.

As regards the sac, very high as well here. I sort of wish we could get a mark out of 50 or something.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Thursday, 2009-07-23, 2:25 PM | Message # 46
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
Could probably pester our teachers for the exact marks. Might do that next time I touch base (something that I don't do enough).

As for the algorithm thing, to be honest I ran out of patience on getting the diagonal check to work. I didn't want to spend my time getting my head around an algorithm - hence the more "verbose" code, as you put it. I agree that that was getting out of the realms of reasonable.

As for yours, its level of complexity shows an understanding of the code far beyond what I would think to do - your method of writing is one that minimizes system usage - mince causes a processor spike when it reads the grid, and it also increases the amount of RAM being used by a noticeable amount (I have little meters down the bottom of my screen that tell me about my system's resource use). Your code is a bit more intelligent and looks more scalable, while mine just does gets the job done.
The only problem that I can see with yours is that it can be a bit tricky to read - just because of the sheer complexity. Perhaps more comments, such as an explanation about how each method works? It's a bit difficult to understand what's happening at each line of code. But on that note, what's mine like?


~ Click it
 
Dr4c0niusDate: Friday, 2009-07-24, 3:10 PM | Message # 47
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
More loops increase complexity. More defines and classes increase complexity. Yours was incredibly easy to read because you didn't start throwing while loops around willy nilly and kept classes to a minimum.

Regarding your programs system usage, in vista (with its massive overheads and random OS tasks) on a dual-core 2.4 GHz processor with 3 gig of usable memory, I couldn't see any major jump. The memory usage of the python thread stayed constant at 2992 KB and the cpu utilisation went everywhere dry

Edit: it jumped like that while idling too. Vista is like that.


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

Message edited by Dr4c0nius - Friday, 2009-07-24, 3:13 PM
 
HaydenJohnsDate: Friday, 2009-07-24, 3:31 PM | Message # 48
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
1.7GHz processor, 1GB Ram. Laptop that's a few years old and getting to the stage where it needs a hard drive wipe and reinstall.

Could explain why it caused a spike tongue

I remember a glitch in my SAC that took up all the processor's usage - it kept writing to a file because of a broken loop


~ Click it
 
Dr4c0niusDate: Saturday, 2009-07-25, 6:16 AM | Message # 49
Major
Group: Users
Messages: 96
Awards: 2
Reputation: 0
Status: Offline
Loops are evil when they go wrong biggrin I remember once I got a graphics calculator stuck in a permanent loop, and I'm not really sure how even now.

BTW you're nearly up to 100 posts! I feel all inferior tongue


Oderint dum metuant

<locokamil> Your belief system is thermodynamically unsound.

 
HaydenJohnsDate: Saturday, 2009-07-25, 12:24 PM | Message # 50
Lieutenant colonel
Group: Checked
Messages: 123
Awards: 0
Reputation: 0
Status: Offline
100th post biggrin

And have you ever tried fork bombing your computer? Always fun. For example on windows, a batch file named fork.bat

Code
echo off
cls
:lol
start fork.bat
echo WARNING: Failure in physical sector x03218
echo 10234521wdsd321234wssdq2
echo afesrytujdsrhagfETRHEYJTHS
goto lol

What's fun to do is to give it a shortcut, and then call the shortcut something like "Halo" and change its icon to make it look like a game. Then you leave the computer (laptops are good for this) running in a room with a lot of kids that will see "Halo" and click it. Leave the room for a minute and come back.

Just so you know, that file will break Window's GUI if left running for long enough. The left hand side of the screen changes to black and starts to display the echo'd messages.

Anyway, instant amusement as you watch the kids panic and try to explain how they "didn't break your computer"


~ Click it
 
Forum » Software Development » RE:Work » Upcominhg sac (Anyone know anything specific about it?)
  • Page 1 of 2
  • 1
  • 2
  • »
Search: