home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
authors
/
stephan_scholz
/
party.amos
/
party.amosSourceCode
Wrap
AMOS Source Code
|
1986-08-03
|
7KB
|
204 lines
'
' ************************************************************
' * LA OROYA Stephan Scholz - 1993 *
' * >>> PARTY <<< *
' * *
' * Different affinity factors determine the behaviour of *
' * members in a group. They move around seeking the least *
' * uncomfortable position, i.e. the closest to their ideal *
' * situation with regard to everyone else in the group (and *
' * to a food table in the middle of a room). *
' * *
' * Alter the preference settings at the bottom right of the *
' * screen with the left or right mouse buttons, and watch *
' * the effects on the behaviour of the pieces. *
' * *
' * The bottom left numbers are the (un)happiness values for *
' * the pieces' position and N,S,E,W surrounding squares. *
' * *
' * Pieces A, B and C can also be placed manually while the *
' * programme is running. *
' * *
' ************************************************************
'
Set Buffer 50
Screen Open 1,640,350,16,Hires
Limit Mouse 130,56 To 440,279
Curs Off : Paper 0 : Cls 0
'80 chars wide (0 to 79)
'32 chars high (0 to 31)
QUAN=7
Dim PERSON$(QUAN)
Dim XPOS(QUAN)
Dim YPOS(QUAN)
Dim PREF(QUAN,QUAN)
Dim DIST(QUAN,QUAN)
Dim DIFF(QUAN,QUAN)
'this leaves room for data bottomscreen.
YY=22
XX=79
'matrix for happiness in 1-actual position, or one square
'2-North,3-South,4-East,5-West, and 6-movement decision
Dim HAPPY(QUAN,6)
'
'this sets default distance preferences to other pieces
Restore DATOS
For N=1 To QUAN-1
For M=1 To QUAN
Read A
PREF(N,M)=A
Next M
Next N
DATOS:
Data 0,1,1,1,1,1,1
Data 20,0,20,20,20,20,3
Data 1,20,0,20,20,20,9
Data 1,20,1,0,9,15,11
Data 1,20,1,9,0,1,13
Data 1,20,1,15,1,0,2
'
'Las value in each line is the affinity to the food table in
'the centre of the room.
'These default settings make A like everyone, and everyone
'but everyone likes A except B, who hates everyone.
'Also, everyone hates B.
'Then, everyone loves C but C doesn't like anyone except A.
'
'The following gives random starting positions leaving a one
'square fringe free for calculations to stay in matrix when
'program looks at squares around a piece.
For N=1 To QUAN-1
XPOS(N)=Rnd(XX-1)+1
YPOS(N)=Rnd(YY-1)+1
Next N
'Table:
XPOS(7)=32
YPOS(7)=10
Locate 0,23
Paper 7 : Pen 4
Print "Who? Pos N S E W To? A B C D E F T "
Paper 0 : Pen 2
'
Do
Pen 2
'measurese distances from each piece, (except table)
For N=1 To QUAN-1
'and from positions surrounding each piece,
For P=1 To 5
HAPPY(N,P)=0
'to every other piece (including table).
For M=1 To QUAN
If N=M Then Goto PAP
X=XPOS(N)
If P=4 Then X=XPOS(N)-1
If P=5 Then X=XPOS(N)+1
X1=XPOS(M)
X2=Abs(X-X1)
Y=YPOS(N)
If P=2 Then Y=YPOS(N)-1
If P=3 Then Y=YPOS(N)+1
Y1=YPOS(M)
Y2=Abs(Y-Y1)
DIST(N,M)=Sqr(X2*X2+Y2*Y2)
'compare this real distance with the preferred distance
DIFF(N,M)=Abs(DIST(N,M)-PREF(N,M))
'and add it to the overall (un)happiness account of current position
Add HAPPY(N,P),DIFF(N,M)
PAP:
Next M
Next P
'
'decide whether to move and where:
'Happy(n,6) registers: 1=Stay put; 2=N; 3=S; 4=W; 5=E.
SEE=400
HAPPY(N,6)=1
For S=1 To 5
'if cornered, seek other movement or stay put.
If S=2 and YPOS(N)=0 Then Goto UU
If S=3 and YPOS(N)=YY Then Goto UU
If S=4 and XPOS(N)=0 Then Goto UU
If S=5 and XPOS(N)=XX Then Goto UU
'if the same value, random one in two chance to movement decision
If SEE=HAPPY(N,S) and Rnd(1)=0 Then HAPPY(N,6)=S
'choose the lowest value
If SEE>HAPPY(N,S) Then SEE=HAPPY(N,S) : HAPPY(N,6)=S
UU:
Next S
'
'erase previous on screen position
Locate XPOS(N),YPOS(N)
Print " "
If HAPPY(N,6)=2 Then If YPOS(N)>0 Then YPOS(N)=YPOS(N)-1 : Goto TT
If HAPPY(N,6)=3 Then If YPOS(N)<YY Then YPOS(N)=YPOS(N)+1 : Goto TT
If HAPPY(N,6)=4 Then If XPOS(N)>0 Then XPOS(N)=XPOS(N)-1 : Goto TT
If HAPPY(N,6)=5 Then If XPOS(N)<XX Then XPOS(N)=XPOS(N)+1
TT:
'print new on screen position
Locate XPOS(N),YPOS(N)
Print Chr$(N+64)
Next N
'print table
Locate XPOS(7),YPOS(7)
Print Chr$(155);Chr$(156)
'
'print happiness index of actual, N, S, E and W
'positions and decision taken.
For N=1 To QUAN-1
Pen 4
Locate 1,23+N
Print Chr$(N+64)
'the following four lines can be removed to gain speed
'if you aren't interested in watching the (un)happiness
'values change as pieces move around.
Pen 11
For M=1 To 6
Locate M*4,23+N
Print HAPPY(N,M);" "
Next M
Next N
'
'print preferred distances from each piece (except table)
'to each other piece (including table).
Pen 15
For N=1 To QUAN-1
For M=1 To QUAN
Locate 25+M*4,23+N
Print PREF(N,M);" "
Next M
Next N
'
'The following allows manual intervention to change
'preferred distances (by clicking the right or left
'mousebutton over the desired value).
If Mouse Key<>0
MX=2*X Text(X Mouse)-32
MY=Y Text(Y Mouse)-6
If MY>22
IY=MY-22
IX=(MX-25)/4
If IX<0 : IX=0 : End If
If IX>7 : IX=7 : End If
If IY<0 : IY=0 : End If
If IY>7 : IY=7 : End If
If Mouse Key=1
If PREF(IY,IX)>1 : Dec PREF(IY,IX) : End If
End If
If Mouse Key=2
If PREF(IY,IX)=0 : Goto RR : End If
If PREF(IY,IX)<85 : Inc PREF(IY,IX) : End If
End If
RR:
End If
'
'The following allows the positioning of the pieces A, B and C
'while program is running. Just click where on the screen you wish
'to put A (left button), B (right button) and C (both buttons).
If MY<23
MK=Mouse Key
Locate XPOS(MK),YPOS(MK) : Print " "
XPOS(MK)=MX
YPOS(MK)=MY
Locate XPOS(MK),YPOS(MK) : Print Chr$(MK+64)
End If
End If
Loop