# WCCC_BoardGames

# **AstroBattleShips**

For this week's Creative Code Challenge by @sableraph: ***" Classic Boardgames, AstroBattleShips*** takes ***Python, Locomotion & SonicPi Code with Digital Media*** to reimagine the game, **Battleship** as an intergalactic game.

## **Imagination Stage**

This is done by using a modified version of Battleship that uses mines and having the layout of the board code in **Python**. The dark blue represents the mines while the lighter blue represents the ships.

In **SonicPi**, the sounds that are drum-like represent a mine being located while the beeps are for the ships. The overall ambience sound is the open water on the board.

By using 360 alongside some filters, a sci-fi representation can be seen of how board games can be played in a futuristic realm. WIth **Locomotion** to add actual ships.

## Poetry

```ocaml
Where are they located?
How have they been Created?
Will this lead to a feeling frustration
As there is no instruction,
And needs a bit of intuition?
```

## Video

<iframe width="560" height="315" src="https://www.youtube.com/embed/cFe_e512_M8?si=VNQB13Onb2xC1G8U"></iframe>

## Images of the Boards

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716735275962/b54b0231-7e19-4e28-8051-49e1fecd9241.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716735280926/c85e1771-33e4-4b47-b4be-d161ee93f889.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716735293160/343c1eac-0a78-4160-a45a-d1278d27ba33.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716735296819/0627b341-4ec7-4279-b6d7-4b315c44b624.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716735300485/5b49a914-cc1e-4543-bf61-45dbcdbccfb8.png align="center")

## Code

### Python

```python
#battleship is a 10 x 10 board game, for the purpose of this, we will be arranging various new classes of ships

import numpy as np
import seaborn as sns #using the data viz component as a board
import matplotlib.pylab as plt 

def battle():
    #using the 0 & 1 to represent a ship versus the ocean and having a weighted value of 0.8 for ocean, 0.18 for boats and 0.02 for mines
    boats = [0,1,2]
    prob = [0.78, 0.18,0.04]

    #by adding the (10,10) instead of 5, able to make an array with the weighted values
    shipyard2 = np.random.choice(boats, (10,10), p=prob)
    return shipyard2

def plotting(x):
    letters = ['A','B','C','D','E','F','G','H','I','J'] #set for the columns
    uniform_data = x
    ax = sns.heatmap(uniform_data, linewidth=0.5,cmap="Blues") #changing it to blue for ocean representation
    ax.set_xticklabels(letters) #setting the ticks of the x axis to letters
    plt.show()
    return x #to produce array that will be used in sonicpi
    
plotting(battle())
```

### SonicPi

```ruby
#5 different battle ship boards with the mine versions

use_random_seed Time.now.to_i


shipyard1 = [[0, 0, 0, 1, 0, 0, 1, 0, 1, 1],
             [1, 0, 0, 0, 0, 1, 1, 0, 0, 0],
             [1, 0, 0, 0, 0, 1, 1, 0, 0, 0],
             [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
             [1, 2, 0, 0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 2, 0, 0, 1],
             [1, 0, 0, 0, 0, 0, 0, 0, 1, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 1, 0],
             [0, 0, 0, 0, 0, 0, 1, 0, 0, 0],
             [0, 0, 0, 0, 1, 0, 1, 0, 0, 0]]

shipyard2 = [[2, 1, 0, 0, 0, 0, 0, 0, 0, 1],
             [0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
             [0, 0, 1, 0, 0, 1, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 1, 1, 0, 1],
             [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],
             [2, 0, 0, 1, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
             [0, 1, 0, 0, 0, 1, 0, 1, 0, 0],
             [0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
             [0, 0, 0, 0, 0, 1, 0, 1, 0, 0]]


shipyard3 = [[0, 0, 0, 0, 1, 1, 0, 0, 0, 0],
             [0, 0, 0, 0, 1, 0, 1, 1, 0, 0],
             [0, 1, 0, 1, 1, 0, 0, 0, 1, 0],
             [1, 0, 0, 0, 1, 0, 0, 0, 0, 0],
             [0, 0, 2, 0, 0, 0, 0, 1, 1, 0],
             [0, 0, 1, 0, 0, 2, 0, 1, 0, 0],
             [2, 2, 2, 0, 1, 2, 0, 0, 0, 0],
             [0, 1, 0, 1, 0, 0, 0, 0, 0, 0],
             [0, 1, 0, 0, 0, 1, 2, 0, 1, 0],
             [0, 0, 0, 0, 0, 0, 0, 1, 2, 0]]


shipyard4 = [[1, 0, 1, 0, 0, 0, 0, 0, 2, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 1, 0],
             [0, 0, 0, 1, 0, 0, 0, 0, 0, 2],
             [2, 0, 2, 0, 0, 0, 0, 0, 0, 0],
             [0, 1, 1, 0, 0, 0, 1, 0, 0, 0],
             [0, 1, 0, 0, 0, 0, 0, 1, 0, 0],
             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
             [0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 2, 0, 0, 0],
             [0, 0, 0, 2, 0, 0, 0, 0, 0, 0]]


shipyard5 = [[2, 0, 0, 0, 1, 0, 0, 0, 1, 2],
             [0, 0, 0, 0, 0, 0, 1, 1, 0, 0],
             [1, 0, 0, 1, 0, 0, 0, 0, 1, 0],
             [1, 0, 0, 2, 1, 1, 0, 0, 0, 0],
             [0, 1, 0, 1, 0, 0, 0, 0, 0, 2],
             [0, 0, 0, 0, 0, 0, 0, 0, 2, 1],
             [0, 0, 0, 0, 0, 0, 1, 0, 0, 2],
             [0, 0, 0, 0, 0, 1, 0, 0, 1, 0],
             [1, 0, 0, 0, 0, 1, 1, 0, 0, 0],
             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]

def sonification(shipyard,looping,sampling)
  
  live_loop looping do
    
    #iterating the 2d arrays
    for i in (0...shipyard.size) #overall size of range
      for j in (0...shipyard[i].length) #overall length of the arrays
        if shipyard[i][j] == 2   #play every value
          
          with_fx :ixi_techno do
            with_fx :echo, mix: rrand(0.4,0.8) do
              sample [:loop_safari,:tabla_ghe4].choose, amp: 6, beat_stretch: dice(4)
            end
          end
          
        elsif shipyard[i][j] == 1
          with_fx :ping_pong, mix: rrand(0.4,0.8) do
            sample [:elec_blip,:elec_blip2,:elec_bong].choose, amp: 4, decay: 4
          end
        else
          with_fx [:ping_pong,:flanger,:whammy].choose, amp: 1, mix: rrand(0.4,0.8) do
            sample sampling
          end
        end
        sleep [0.75,1,1.5].choose #pause in between each spawn, replicating the different thinking processes
      end
    end
  end
  
end



sonification(shipyard5,:yard5,:ambi_glass_hum)
sonification(shipyard4,:yard4,:ambi_glass_rub)
sonification(shipyard3,:yard3,:ambi_piano)
sonification(shipyard2,:yard2,:ambi_glass_hum)
sonification(shipyard1,:yard1,:ambi_piano)
```

### Locomotion

```haskell
c = hsv (step [0,1/3,2/3] (phase 1 0)) 1 (range 0.5 1 (osc 0.25));


point {color = c, x = 0, y = range -3 3 (osc 2), z = 4};
directional { colour=0xf00f80, intensity = range 0 2 (osc 0.5), z = range 0 17 (osc 1), y = 10, x = range -6 6 (osc 1.4) };
directional { colour=0xf00f80, intensity = range 0 2 (osc 0.5), z = range 0 17 (osc 0.8), y = 10, x = -6 };
ambient { intensity = range 0.5 10.5 (osc 0.75) };


b n = dancer {url = "https://raw.githubusercontent.com//IllestPreacha/CreativeDataStuff/004a835d7dd8c0ffac55e17b21d14a1ac6511938/3Dmodel/Ships3.glb", 
size =  ((n +8)/5)/5 + range 0 3 (osc 0.24),y = range 4 -4 (osc 0.15), ly = range (-10) 0 (in 10), lz = range (-10) 0.5 (in 20), lx = range -10 35 (osc 0.0135),
x = 0 + (n/5 + 1) + range -4 4 (osc 0.25),  z = range -5 5 (phase 1 (n/50) * 2 + (-2)), rx = n * 23.7,dur = 0.5};
for [0..15] b;



dancer { url = "https://raw.githubusercontent.com//IllestPreacha/CreativeDataStuff/004a835d7dd8c0ffac55e17b21d14a1ac6511938/3Dmodel/Ships3.glb", animation = [15,1,17,1,21,1],size = range 0.25 12.15 (osc 0.17), ry = range - 90 90(osc 0.25), z = -3, ly = range -180 180 (osc 2)};


--Glitchy Droid More
r2 = step [3,4,5,6] (phase 4 0);
r = step [0.5,2,1,4] (phase 16 0);


for [0..10]  (\n -> dancer {url = "https://raw.githubusercontent.com//IllestPreacha/CreativeDataStuff/004a835d7dd8c0ffac55e17b21d14a1ac6511938/3Dmodel/Ships3.glb", dur = n*0.5, x = (n)+(-20), y = -4 + osc(1) * sin(n), z = -10, rx = r2 * r2 * r2, ry = 0, rz = 0, size= r*3});



dancer{url = "https://raw.githubusercontent.com//IllestPreacha/CreativeDataStuff/004a835d7dd8c0ffac55e17b21d14a1ac6511938/3Dmodel/Ships3.glb",x = range 5 -5 (osc 1), rx = range 5 -5 (osc 0.5)};  -- 15 words
dancer{url = "https://raw.githubusercontent.com//IllestPreacha/CreativeDataStuff/004a835d7dd8c0ffac55e17b21d14a1ac6511938/3Dmodel/Ships2.glb",y = range 5 -5 (osc 0.25), animation = [2 ,1, 3,1], rz = 17}; -- 16 words
dancer{url = "https://raw.githubusercontent.com//IllestPreacha/CreativeDataStuff/004a835d7dd8c0ffac55e17b21d14a1ac6511938/3Dmodel/Ships2.glb",z = range 5 -5 (osc 0.15), rx = range 5 -5 (osc 1)};  -- 15 words
```
