Remote agent/Simulation/Julia: Difference between revisions
m
no edit summary
(julia example) |
mNo edit summary |
||
Line 47:
colorant"blue", colorant"yellow", colorant"transparent"
const sectorcolors = [Red, Green, Blue, Yellow]
const colorsectors = Dict{
Blue => SectorBlue, Yellow => SectorYellow)
const colorballs = Dict{
Blue => BallBlue, Yellow => BallYellow)
const configs = Dict{String,Any}("dimensions" => (8, 12), "ballchance" => 0.
"wallchance" => 0.10, "walltile" => '▒', "emptytile" => ' ',
"unknowntile" => '?', "ip" => ip"127.0.0.1","portnumber" => 5021,
"wallcolor" => colorant"darkgray", "unknowncolor" => colorant"gold")
Line 60 ⟶ 59:
mutable struct Sector
ch::Char
clr::
ball::
end
Line 73 ⟶ 72:
location::Pt
direction::Direction
ball::
end
Line 248 ⟶ 247:
# modulino
if occursin(Base.PROGRAM_FILE, @__FILE__)
Line 283 ⟶ 282:
newgame()
end # modulino
</lang>
<lang julia>using Distributed, Sockets, Gtk, Colors, Graphics, Cairo
Line 297 ⟶ 296:
# want the map as learned by agent to be aligned with the map known to server.
# To do so, we start agent facin north, but in a random location with the map
# height and width randomly
# information about the shape and contents of the grid.
height, width = configs["dimensions"]
Line 336 ⟶ 335:
line_to(ctx, (i - 1) * l + fontsize * 1.25, (j - 1) * l + fontsize * 0.2)
stroke(ctx)
set_source(ctx, grid.agent.ball == nocolor ? colorant"black" : grid.agent.ball)
circle(ctx, (i - 1) * l + fontsize * 1.25, (j - 1) * l + fontsize * 2, fontsize / 4)
fill(ctx)
Line 362 ⟶ 361:
end
if GameOver in response
for ch in [GameOver, GameOver, GameOver, GameOver, GameOver, Stop]
put!(outchan, ch)
end
sleep(10)
close(inchan)
close(outchan)
|