Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
behavioralcontrol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mastLab
behavioralcontrol
Commits
d5bb76ce
Commit
d5bb76ce
authored
Jul 16, 2020
by
Dave Pena PhD
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parents
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
167 additions
and
0 deletions
+167
-0
mastbehavior.koi
mastbehavior.koi
+0
-0
mastbehavior.py
mastbehavior.py
+167
-0
No files found.
mastbehavior.koi
0 → 100644
View file @
d5bb76ce
This diff is collapsed.
Click to expand it.
mastbehavior.py
0 → 100644
View file @
d5bb76ce
#!/usr/bin/env python
from
decorator
import
decorator
import
time
from
array
import
array
import
pygame
as
pg
from
pygame.mixer
import
Sound
,
get_init
import
pygame.gfxdraw
as
gfx
@
decorator
def
on_start
(
func
,
*
args
,
**
kwargs
):
if
kwargs
!=
{}:
try
:
if
kwargs
[
'Start'
]:
if
'Verbose'
in
kwargs
[
'Settings'
]:
if
kwargs
[
'Settings'
][
'Verbose'
]:
print
(
func
)
pass
response
=
func
(
*
args
,
**
kwargs
)
return
response
else
:
kwargs
[
'Start'
]
=
False
print
(
func
,
"DID NOT START"
)
return
(
kwargs
)
except
Exception
as
e
:
print
(
'NODE ERROR OCCURED TRYING TO START NODE FUNCTION:'
)
print
(
'==========================================='
)
print
(
func
,
e
)
print
(
'==========================================='
)
print
(
'LAST STATE SET TO:'
)
print
(
'==========================================='
)
print
(
'ekwargs'
)
print
(
'==========================================='
)
print
(
'LAST NODE FUNCTION SET TO:'
)
print
(
'==========================================='
)
print
(
'efunc'
)
print
(
'==========================================='
)
global
ekwargs
global
efunc
ekwargs
=
kwargs
efunc
=
func
print
(
'HALTING'
)
raise
else
:
print
(
'Empty kwargs'
)
return
()
def
start
():
return
{
'Start'
:
True
,
'Settings'
:{
'Verbose'
:
False
},
'Status'
:{},
'Threads'
:[]}
@
on_start
def
stremePyGame_node_36
(
*
args
,
**
kwargs
):
pg
.
mixer
.
pre_init
(
44100
,
-
16
,
1
)
pg
.
init
()
pluriPalette
=
{
"pluri"
:(
135
,
138
,
238
),
"pluriDark"
:(
89
,
45
,
84
),
"pop1"
:(
252
,
22
,
139
),
"alert"
:(
222
,
83
,
96
),
"muted"
:(
212
,
212
,
212
),
"pop2"
:(
85
,
216
,
203
),
"white"
:(
255
,
255
,
255
),
"black"
:(
0
,
0
,
0
)
}
screen
=
pg
.
display
.
set_mode
([
800
,
800
])
screen
.
fill
(
pluriPalette
[
'pluri'
])
pg
.
display
.
set_caption
(
"Experiment"
)
font
=
pg
.
font
.
Font
(
pg
.
font
.
match_font
(
'lato'
),
72
)
text
=
font
.
render
(
'SomeText'
,
True
,
pluriPalette
[
'white'
])
kwargs
[
'Data'
]
=
True
# nodes will see anything placed in kwargs
########### Keeps an error from occuring when nodes are not connected #######
event1
=
""
event2
=
""
event3
=
""
event4
=
""
##############################################################################
while
kwargs
[
'Data'
]:
screen
.
blit
(
text
,
(
10
,
10
))
###################### BACK PIN EVENTS #######################################
kwargs
=
keydown_node_47
(
**
kwargs
)
###############################################################################
{
event2
}
{
event3
}
{
event4
}
if
kwargs
[
'Data'
]:
for
i
in
pg
.
event
.
get
():
if
i
.
type
==
pg
.
QUIT
:
kwargs
[
'Data'
]
=
False
pg
.
quit
()
pg
.
display
.
flip
()
return
kwargs
class
Note
(
Sound
):
def
__init__
(
self
,
frequency
,
volume
=
.
1
):
self
.
frequency
=
frequency
Sound
.
__init__
(
self
,
self
.
build_samples
())
self
.
set_volume
(
volume
)
def
build_samples
(
self
):
period
=
int
(
round
(
get_init
()[
0
]
/
self
.
frequency
))
samples
=
array
(
"h"
,
[
0
]
*
period
)
amplitude
=
2
**
(
abs
(
get_init
()[
1
])
-
1
)
-
1
for
time
in
range
(
period
):
if
time
<
period
/
2
:
samples
[
time
]
=
amplitude
else
:
samples
[
time
]
=
-
amplitude
return
samples
@
on_start
def
keydown_node_47
(
*
args
,
**
kwargs
):
pressed
=
pg
.
key
.
get_pressed
()
if
pressed
[
pg
.
K_w
]:
print
(
"w is pressed"
)
if
pressed
[
pg
.
K_s
]:
print
(
"s is pressed"
)
if
pressed
[
pg
.
K_ESCAPE
]:
kwargs
[
'Data'
]
=
False
if
pressed
[
pg
.
K_SPACE
]:
print
(
"Spacebar Pressed"
)
Note
(
440
).
play
(
100
)
return
kwargs
class
StremeNode
:
def
__init__
(
self
):
pass
def
run
(
self
,
*
args
,
**
kwargs
):
self
.
kwargs
=
stremePyGame_node_36
(
**
kwargs
)
return
(
self
.
kwargs
)
class
liveprocess
:
def
__init__
(
self
):
pass
def
run
(
self
,
expname
=
"Local"
):
self
.
response
=
stremePyGame_node_36
(
**
start
())
return
(
self
.
response
)
if
__name__
==
'__main__'
:
process
=
liveprocess
()
process
.
run
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment