-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToBots.ps1
57 lines (56 loc) · 2.06 KB
/
ToBots.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<#
|===============================================================>|
AP-Snakes 2 [PowerSneks] by APoorv Verma [AP] on 10/25/2019
|===============================================================>|
$) Color Scheming 1
$) Level Making 0 * 2
$) MAP Saving and Loading 3
$) Obstruction Creation
$) Laser Beams To cut through walls
$) Warping of Obstructions and Snake
$) Game-Console with Laser and Score count
$) CPU cycle and sleep time adjustment as game progresses
$) Snake Grows upon eating food
$) Restore Console Properties upon Close
$) OO Design
$) Multiobject support / Multiplayer!
|===============================================================>|
#>
param(
[int]$Snakes=1,
[ValidatePattern("[A-z]?:?.?\\.*\..*|\/\*\\")][String]$MapFile='/*\',
[Switch]$ShowPlayerLabels,
[Switch]$LoadDefaultSave,
[Switch]$Debug
)
. $PSScriptRoot\PowerSneks_BaseObjects.ps1
. $PSScriptRoot\PowerSneks_GameSettings.ps1
. $PSScriptRoot\PowerSneks_Engine.ps1
. $PSScriptRoot\BotClass.ps1
$SN = $Snakes
$Snakes = 0
#= RUNTIME ====================================================================================|
Start-Game {param($Game, $Tick)
try {
if ($Tick -eq 1) {
if ($Game.Players.Length) {
$bt = $Game.Players | % {$_.SerializeState()}
$Game.Players.clear()
foreach ($e in $bt) {
$b = [SnakeBot]::new($c, $Game)
$Game.attachPlayer($b)
$b.DeserializeState(($e | ConvertTo-Json | ConvertFrom-Json))
$b.respawn()
}
return
}
1..$SN | % {
$c = Get-PlayerSpawn $Game
$Game.attachPlayer([SnakeBot]::new($c, $Game))
}
}
if ($Game.isMultiPlayer() -and ($Tick -lt 100 -and !($Tick % 5)) -or !($Tick % 100)) {
$Game.Players | % {$_.ScanForFoodCoords()}
}
} catch {Write-Host "BOT CRASHED, $_"}
}