Skip to content

Commit

Permalink
add groove joint and py3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisKolganov committed Sep 4, 2018
1 parent c361e99 commit f98a291
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
16 changes: 6 additions & 10 deletions madcars/Runners/mechanic/game_objects/base_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def create_wheel(self, wheel_side):
wheel_position = getattr(self, wheel_side + '_wheel_position')
wheel_friction = getattr(self, wheel_side + '_wheel_friction')
wheel_elasticity = getattr(self, wheel_side + '_wheel_elasticity')
wheel_joint = getattr(self, wheel_side + '_wheel_joint')
wheel_damp_position = getattr(self, wheel_side + '_wheel_damp_position')
wheel_damp_length = getattr(self, wheel_side + '_wheel_damp_length')
wheel_damp_stiffness = getattr(self, wheel_side + '_wheel_damp_stiffness')
Expand All @@ -100,8 +99,12 @@ def create_wheel(self, wheel_side):
wheel_shape.elasticity = wheel_elasticity
wheel_objects.append(wheel_shape)

wheel_joint = pymunk.PinJoint(wheel_body, self.car_body, anchor_b=(wheel_joint[0] * self.x_modification, wheel_joint[1]))
wheel_objects.append(wheel_joint)
wheel_grove = pymunk.GrooveJoint(self.car_body, wheel_body,
(wheel_damp_position[0] * self.x_modification, wheel_damp_position[1]),
(wheel_damp_position[0] * self.x_modification,
wheel_damp_position[1] - wheel_damp_length * 1.5),
(0, 0))
wheel_objects.append(wheel_grove)

wheel_damp = pymunk.DampedSpring(wheel_body, self.car_body, anchor_a=(0, 0),
anchor_b=(wheel_damp_position[0] * self.x_modification, wheel_damp_position[1]),
Expand All @@ -110,16 +113,9 @@ def create_wheel(self, wheel_side):
damping=wheel_damp_damping)
wheel_objects.append(wheel_damp)

wheel_stop = pymunk.Poly(self.car_body, [(0, 0), (0, 1), (wheel_radius * 2 * self.x_modification, 1), (wheel_radius * 2 * self.x_modification, 0)],
transform=pymunk.Transform(tx=wheel_damp_position[0] * self.x_modification - wheel_radius * self.x_modification, ty=wheel_damp_position[1]))
wheel_objects.append(wheel_stop)

wheel_stop.color = 0, 255, 0

wheel_motor = None
if (wheel_side == 'rear' and self.drive in [self.AWD, self.FR]) or (wheel_side == 'front' and self.drive in [self.AWD, self.FF]):
wheel_motor = pymunk.SimpleMotor(wheel_body, self.car_body, 0)
# wheel_objects.append(motor)

return wheel_body, wheel_motor, wheel_objects

Expand Down
19 changes: 6 additions & 13 deletions madcars/Runners/mechanic/game_objects/cars.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Buggy(Car):

rear_wheel_mass = 50
rear_wheel_position = (29, -5)
rear_wheel_joint = (150, 0)
rear_wheel_damp_position = (29, 20)
rear_wheel_damp_stiffness = 5e4
rear_wheel_damp_damping = 3e3
Expand All @@ -37,7 +36,6 @@ class Buggy(Car):

front_wheel_mass = 5
front_wheel_position = (122, -5)
front_wheel_joint = (0, 6)
front_wheel_damp_position = (122, 20)
front_wheel_damp_length = 25
front_wheel_radius = 12
Expand Down Expand Up @@ -69,15 +67,13 @@ class Bus(Car):
rear_wheel_radius = 13
rear_wheel_position = (38, -5)
rear_wheel_friction = 0.9
rear_wheel_joint = (153, 5)
rear_wheel_damp_position = (38, 30)
rear_wheel_damp_length = 35
rear_wheel_damp_stiffness = 10e4
rear_wheel_damp_damping = 6e3

front_wheel_radius = 13
front_wheel_position = (125, -5)
front_wheel_joint = (0, 6)
front_wheel_damp_position = (125, 30)
front_wheel_damp_length = 35
front_wheel_damp_stiffness = 10e4
Expand Down Expand Up @@ -108,7 +104,6 @@ def create_wheel(self, wheel_side):
wheel_position = getattr(self, wheel_side + '_wheel_position')
wheel_friction = getattr(self, wheel_side + '_wheel_friction')
wheel_elasticity = getattr(self, wheel_side + '_wheel_elasticity')
wheel_joint = getattr(self, wheel_side + '_wheel_joint')
wheel_damp_position = getattr(self, wheel_side + '_wheel_damp_position')
wheel_damp_length = getattr(self, wheel_side + '_wheel_damp_length')
wheel_damp_stiffness = getattr(self, wheel_side + '_wheel_damp_stiffness')
Expand All @@ -124,8 +119,12 @@ def create_wheel(self, wheel_side):
wheel_shape.elasticity = wheel_elasticity
wheel_objects.append(wheel_shape)

wheel_joint = pymunk.PinJoint(wheel_body, self.car_body, anchor_b=(wheel_joint[0] * self.x_modification, wheel_joint[1]))
wheel_objects.append(wheel_joint)
wheel_grove = pymunk.GrooveJoint(self.car_body, wheel_body,
(wheel_damp_position[0] * self.x_modification, wheel_damp_position[1]),
(wheel_damp_position[0] * self.x_modification,
wheel_damp_position[1] - wheel_damp_length * 1.5),
(0, 0))
wheel_objects.append(wheel_grove)

wheel_damp = pymunk.DampedSpring(wheel_body, self.car_body, anchor_a=(0, 0),
anchor_b=(wheel_damp_position[0] * self.x_modification, wheel_damp_position[1]),
Expand All @@ -134,12 +133,6 @@ def create_wheel(self, wheel_side):
damping=wheel_damp_damping)
wheel_objects.append(wheel_damp)

wheel_stop = pymunk.Poly(self.car_body, [(0, 0), (0, 1),(wheel_radius * 2 * self.x_modification, 1), (wheel_radius * 2 * self.x_modification, 0)],
transform=pymunk.Transform(tx=wheel_damp_position[0] * self.x_modification - wheel_radius * self.x_modification, ty=wheel_damp_position[1]))
wheel_objects.append(wheel_stop)

wheel_stop.color = 0, 255, 0

wheel_motor = None
if (wheel_side == 'rear' and self.drive in [self.AWD, self.FR]) or (wheel_side == 'front' and self.drive in [self.AWD, self.FF]):
wheel_motor = pymunk.SimpleMotor(wheel_body, self.car_body, 0)
Expand Down
11 changes: 7 additions & 4 deletions madcars/Runners/mechanic/game_objects/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ def __init__(self, space):
self.objects.append(segment)

def create_box(self, space):
left = pymunk.Segment(space.static_body, (0, 0), (0, self.max_height), 1)
bo = self.segment_height - 1 # box offset
left = pymunk.Segment(space.static_body, (-bo, -bo), (-bo, self.max_height + bo), self.segment_height)
left.sensor = True

top = pymunk.Segment(space.static_body, (0, self.max_height), (self.max_width, self.max_height), 1)
top = pymunk.Segment(space.static_body, (-bo, self.max_height + bo),
(self.max_width + bo, self.max_height + bo), 10)
top.sensor = True

right = pymunk.Segment(space.static_body, (self.max_width, self.max_height), (self.max_width, 0), 1)
right = pymunk.Segment(space.static_body, (self.max_width + bo, self.max_height + bo),
(self.max_width + bo, -bo), 10)
right.sensor = True

bottom = pymunk.Segment(space.static_body, (self.max_width, 0), (0, 0), 1)
bottom = pymunk.Segment(space.static_body, (self.max_width + bo, -bo), (-bo, -bo), 10)
bottom.sensor = True

self.objects.extend([left, top, right, bottom])
Expand Down
6 changes: 4 additions & 2 deletions madcars/dockers/python3/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM ubuntu:16.04
MAINTAINER Boris Kolganov <[email protected]>

RUN apt-get update && apt-get install -y python3 python3-pip && pip3 install -U numpy scipy cython scikit-learn keras pandas tensorflow==1.5.0 pymunk==5.3.2
RUN add-apt-repository ppa:jonathonf/python-3.6 && \
apt-get update && apt-get install -y python3.6 python3-pip && \
python3.6 -m pip install -U numpy scipy cython scikit-learn keras pandas tensorflow==1.5.0 pymunk==5.3.2

ENV SOLUTION_CODE_ENTRYPOINT=main.py
ENV SOLUTION_CODE_PATH=/opt/client/solution
ENV RUN_COMMAND='python3 -u $SOLUTION_CODE_PATH/$SOLUTION_CODE_ENTRYPOINT'
ENV RUN_COMMAND='python3.6 -u $SOLUTION_CODE_PATH/$SOLUTION_CODE_ENTRYPOINT'

0 comments on commit f98a291

Please sign in to comment.