help with arrays and random.shuffle

i need heelp with running and importing the array module, also display

Page 1 of 1

3 Replies - 4167 Views - Last Post: 05 March 2008 - 06:53 AM Rate Topic: -----

#1 wokeup2sleep  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-March 08

help with arrays and random.shuffle

Posted 04 March 2008 - 08:38 AM

im a beginner at comp science, and my prof is using python, which is totally new tom me i had a few questions with the program im writing, im having a few problems.

brief summary
i have to do a project where there are nine boxes filled with number 1-8, and 1 space is empty, the game needs to be scrambled, also all the moves need to be saved. the game can be paused anytime during thegame. the object is to move the numbers into the black spot till they are all in order.

the grid i have needs to contain variables so that can be moved by the players

this what i have and i know it is far off

def board():
board = [1,2,3,4,5,6,7,8,9]

for x in range(0, 9):
print "|"

if(board[x]==9):
print "_"
else:
print board[x]



if(x==8):
print "|"
board()





when i run that it looks like this

|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
_
|


and this is how i need it to look:

|1|2|3|
|4|5|6|
|7|8|_|

what am i doing wrong? also how do i use the random.shuffle() function so i can scramble the numbers?

help would be greatly appriciated...

also how would i save every move, also the random fuction isnt working so i can scramble the numbers.


i am probably doing everything wrong to make a game board, cause i need everything to to be interchanglable when the players wants to move and adjecent number to the blank spot, any help anyone???

thanks alot ahead of time

also i can't seem to import array or random
in addition my project is attached if anyone didnt understand what i needed to to do

Attached File(s)


This post has been edited by wokeup2sleep: 04 March 2008 - 08:43 AM


Is This A Good Question/Topic? 0
  • +

Replies To: help with arrays and random.shuffle

#2 Nykc  Icon User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 726
  • View blog
  • Posts: 8,638
  • Joined: 14-September 07

Re: help with arrays and random.shuffle

Posted 04 March 2008 - 08:40 AM

:code:

Makes it easier to read.
Was This Post Helpful? 0
  • +
  • -

#3 wokeup2sleep  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-March 08

Re: help with arrays and random.shuffle

Posted 04 March 2008 - 08:44 AM

thx for the tip
Was This Post Helpful? 0
  • +
  • -

#4 wokeup2sleep  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-March 08

Re: help with arrays and random.shuffle

Posted 05 March 2008 - 06:53 AM

can anyone help me please???
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1