-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #485 from kipr/simChallenges
Sim challenges
- Loading branch information
Showing
69 changed files
with
10,964 additions
and
283 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Dict from '../util/objectOps/Dict'; | ||
import Camera from '../state/State/Scene/Camera'; | ||
import Geometry from '../state/State/Scene/Geometry'; | ||
import Node from '../state/State/Scene/Node'; | ||
import { Vector3wUnits } from '../util/math/unitMath'; | ||
|
||
export type Ids = string | string[] | Set<string>; | ||
|
||
export namespace Ids { | ||
export const toSet = (ids: Ids): Set<string> => { | ||
if (typeof ids === 'string') return new Set([ids]); | ||
if (Array.isArray(ids)) return new Set(ids); | ||
return ids; | ||
}; | ||
} | ||
|
||
export interface ScriptSceneBinding { | ||
readonly nodes: Dict<Node>; | ||
addNode(node: Node, id?: string): string; | ||
removeNode(id: string): void; | ||
setNode(id: string, node: Node); | ||
|
||
readonly geometry: Dict<Geometry>; | ||
addGeometry(geometry: Geometry, id?: string): string; | ||
removeGeometry(id: string): void; | ||
|
||
gravity: Vector3wUnits; | ||
|
||
camera: Camera; | ||
|
||
selectedNodeId?: string; | ||
|
||
readonly programStatus: 'running' | 'stopped'; | ||
|
||
addOnRenderListener(cb: () => void): string; | ||
addOnCollisionListener(nodeId: string, cb: (otherNodeId: string, point: Vector3wUnits) => void, filterIds: Ids): string; | ||
addOnIntersectionListener(nodeId: string, cb: (type: 'start' | 'end', otherNodeId: string) => void, filterIds: Ids): string; | ||
addOnClickListener(filterIds: Ids, cb: (nodeId: string) => void): string; | ||
removeListener(handle: string): void; | ||
|
||
onBind?: (nodeId: string) => void; | ||
onUnbind?: (nodeId: string) => void; | ||
onDispose?: () => void; | ||
|
||
// Used only for unit tests | ||
postTestResult: (data: unknown) => void; | ||
|
||
setChallengeEventValue: (eventId: string, value: boolean) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import Author from "../../../db/Author"; | ||
import Challenge from "../../../state/State/Challenge"; | ||
import Expr from "../../../state/State/Challenge/Expr"; | ||
import LocalizedString from "../../../util/LocalizedString"; | ||
import ProgrammingLanguage from "../../../programming/compiler/ProgrammingLanguage"; | ||
|
||
export default { | ||
name: { [LocalizedString.EN_US]: 'JBC Challenge 1' }, | ||
description: { [LocalizedString.EN_US]: `Junior Botball Challenge 1: Tag, You're it!` }, | ||
author: { | ||
type: Author.Type.Organization, | ||
id: 'kipr' | ||
}, | ||
code: { | ||
'c': ProgrammingLanguage.DEFAULT_CODE.c, | ||
'cpp': ProgrammingLanguage.DEFAULT_CODE.cpp, | ||
'python': ProgrammingLanguage.DEFAULT_CODE.python, | ||
}, | ||
defaultLanguage: 'c', | ||
events: { | ||
can9Touched: { | ||
name: { [LocalizedString.EN_US]: 'Can A Touched' }, | ||
description: { [LocalizedString.EN_US]: 'Can A touched' }, | ||
}, | ||
canAIntersects: { | ||
name: { [LocalizedString.EN_US]: 'Can A Intersects' }, | ||
description: { [LocalizedString.EN_US]: 'Can A intersects circle 9' }, | ||
}, | ||
|
||
canAUpright: { | ||
name: { [LocalizedString.EN_US]: 'Can A Upright' }, | ||
description: { [LocalizedString.EN_US]: 'Can A upright on circle 9' }, | ||
}, | ||
|
||
leaveStartBox: { | ||
name: { [LocalizedString.EN_US]: 'Robot Left Start' }, | ||
description: { [LocalizedString.EN_US]: 'Robot left starting box' }, | ||
}, | ||
returnStartBox: { | ||
name: { [LocalizedString.EN_US]: 'Robot Rentered Start' }, | ||
description: { [LocalizedString.EN_US]: 'Robot reentered starting box' }, | ||
}, | ||
}, | ||
success: { | ||
exprs: { | ||
// Touch Events | ||
can9Touched: { | ||
type: Expr.Type.Event, | ||
eventId: 'can9Touched', | ||
}, | ||
|
||
// Intersects Events | ||
canAIntersects: { | ||
type: Expr.Type.Event, | ||
eventId: 'canAIntersects', | ||
}, | ||
|
||
// Upright Events | ||
canAUpright: { | ||
type: Expr.Type.Event, | ||
eventId: 'canAUpright', | ||
}, | ||
|
||
// Start Box Events | ||
leaveStartBox: { | ||
type: Expr.Type.Event, | ||
eventId: 'leaveStartBox', | ||
}, | ||
leaveStartBoxOnce: { | ||
type: Expr.Type.Once, | ||
argId: 'leaveStartBox', | ||
}, | ||
|
||
returnStartBox: { | ||
type: Expr.Type.Event, | ||
eventId: 'returnStartBox', | ||
}, | ||
returnStartBoxOnce: { | ||
type: Expr.Type.Once, | ||
argId: 'returnStartBox', | ||
}, | ||
|
||
|
||
|
||
startingBox:{ | ||
type:Expr.Type.And, | ||
argIds:['leaveStartBoxOnce', 'returnStartBoxOnce'], | ||
}, | ||
|
||
// Intersects and upright logic | ||
aIntersectsUpright: { | ||
type: Expr.Type.And, | ||
argIds: ['canAIntersects', 'canAUpright'], | ||
}, | ||
|
||
// Success Logic = Can A upright, intersects and touched | ||
completion: { | ||
type: Expr.Type.And, | ||
argIds: ['can9Touched', 'aIntersectsUpright', 'startingBox'], | ||
}, | ||
}, | ||
rootId: 'completion', | ||
}, | ||
sceneId: 'jbc1', | ||
} as Challenge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import Author from '../../../db/Author'; | ||
import Challenge from '../../../state/State/Challenge'; | ||
import Expr from '../../../state/State/Challenge/Expr'; | ||
import LocalizedString from '../../../util/LocalizedString'; | ||
import ProgrammingLanguage from "../../../programming/compiler/ProgrammingLanguage"; | ||
|
||
export default { | ||
name: { [LocalizedString.EN_US]: 'JBC Challenge 10' }, | ||
description: { | ||
[LocalizedString.EN_US]: `Junior Botball Challenge 10: Solo Joust`, | ||
}, | ||
author: { | ||
type: Author.Type.Organization, | ||
id: 'kipr', | ||
}, | ||
code: { | ||
'c': ProgrammingLanguage.DEFAULT_CODE.c, | ||
'cpp': ProgrammingLanguage.DEFAULT_CODE.cpp, | ||
'python': ProgrammingLanguage.DEFAULT_CODE.python, | ||
}, | ||
defaultLanguage: 'c', | ||
events: { | ||
|
||
can1Upright: { | ||
name: { [LocalizedString.EN_US]: 'Can A Upright' }, | ||
description: { | ||
[LocalizedString.EN_US]: 'Can A upright in a circle', | ||
}, | ||
}, | ||
leaveStartBox: { | ||
name: { [LocalizedString.EN_US]: 'Robot Left Start' }, | ||
description: { [LocalizedString.EN_US]: 'Robot left starting box' }, | ||
}, | ||
robotTouchingLine: { | ||
name: { [LocalizedString.EN_US]: 'Robot Touching Line B' }, | ||
description: { [LocalizedString.EN_US]: 'Robot is touching line B' }, | ||
}, | ||
|
||
}, | ||
success: { | ||
exprs: { | ||
|
||
|
||
// Upright Events | ||
can1Upright: { | ||
type: Expr.Type.Event, | ||
eventId: 'can1Upright', | ||
}, | ||
can1NotUpright: { | ||
type: Expr.Type.Not, | ||
argId: 'can1Upright', | ||
}, | ||
|
||
// Line B Event | ||
robotTouchingLine: { | ||
type: Expr.Type.Event, | ||
eventId: 'robotTouchingLine', | ||
}, | ||
robotNotTouchingLine: { | ||
type: Expr.Type.Not, | ||
argId: 'robotTouchingLine', | ||
}, | ||
|
||
// Can 1 Not Upright and Robot Not Touching Line B | ||
NotUprightNotTouching: { | ||
type: Expr.Type.And, | ||
argIds: ['can1NotUpright', 'robotNotTouchingLine'], | ||
}, | ||
|
||
// Start Box Events | ||
leaveStartBox: { | ||
type: Expr.Type.Event, | ||
eventId: 'leaveStartBox', | ||
}, | ||
leaveStartBoxOnce: { | ||
type: Expr.Type.Once, | ||
argId: 'leaveStartBox', | ||
}, | ||
|
||
|
||
completion: { | ||
type: Expr.Type.And, | ||
argIds: ['leaveStartBoxOnce', 'NotUprightNotTouching'], | ||
}, | ||
}, | ||
rootId: 'completion', | ||
}, | ||
sceneId: 'jbc10', | ||
} as Challenge; |
Oops, something went wrong.