ガンホーを指値366円で注文
ガンホー100株を366円で買って400円で売る遊び。
りとる・けいおす
小学生が顔芸で笑わせるギャグ漫画。
省略化したキャラがシリアスになるギャップが面白い。
Nexus7のKindle版を買った。
- 作者: 涼川りん
- 出版社/メーカー: 双葉社
- 発売日: 2015/01/30
- メディア: Kindle版
- この商品を含むブログを見る
- 作者: 涼川りん
- 出版社/メーカー: 双葉社
- 発売日: 2015/07/29
- メディア: Kindle版
- この商品を含むブログを見る
unityで最短経路
A*を使った最短経路のサンプルを作った。
空のGameObjectにMain.csを追加して、ライトを追加する。
前に作ったA*のコードを少しだけ改良した。
Node.cs
using UnityEngine; using System.Collections; using System.Collections.Generic; public class Node : MonoBehaviour { public int id; public List<int> nearList; public Node parent; public float f; public float g; public float h; public bool done; public bool isBlock; private void Awake() { nearList = new List<int>(); parent = null; f = g = h = 0f; done = false; isBlock = false; } public void Clear() { parent = null; f = g = h = 0f; done = isBlock = false; } public void SetBlock() { isBlock = true; GetComponent<Renderer>().material.color = Color.green; } public void SetPass() { GetComponent<Renderer>().material.color = Color.yellow; } }
PathFinding.cs
using UnityEngine; using System.Collections; using System.Collections.Generic; public class PathFinding { public Dictionary<int, Node> nodeDictionary; public List<Node> openList; public List<Node> closeList; public Node start; public Node goal; public PathFinding() { openList = new List<Node>(); closeList = new List<Node>(); } public void Clear() { openList.Clear(); closeList.Clear(); start = goal = null; } public bool Search(int startId, int goalId) { if (nodeDictionary == null || nodeDictionary.Count == 0) { return false; } if (startId == goalId) { return false; } Clear(); start = nodeDictionary[startId]; if (start == null) { return false; } goal = nodeDictionary[goalId]; if (goal == null) { return false; } openList.Add(start); start.g = 0; start.h = Heuristic(start, goal); start.f = start.h; while (true) { if (openList.Count == 0) { Debug.Log("path not found"); return false; } float minCost = float.MaxValue; Node minCostNode = null; foreach (Node searchNode in openList) { if (searchNode.done || searchNode.isBlock) { continue; } if (searchNode.f < minCost) { minCost = searchNode.f; minCostNode = searchNode; } } if (minCostNode == null) { return false; } if (minCostNode == goal) { return true; } minCostNode.done = true; closeList.Add(minCostNode); openList.Remove(minCostNode); UpdateCost(minCostNode); } return false; } private float Heuristic(Node a, Node b) { return Vector3.Distance(a.transform.position, b.transform.position); } private void UpdateCost(Node node) { foreach(int id in node.nearList) { Node nearNode = nodeDictionary[id]; if (nearNode == null || nearNode.done || nearNode.isBlock) { continue; } CalculateCost(node, nearNode); } } private void CalculateCost(Node node, Node near) { float nearH = Heuristic(near, goal); float nearG = node.g + Heuristic(node, near); float nearF = nearH + nearG; if (openList.Contains(near)) { if (nearF < near.f) { near.f = nearF; near.g = nearG; near.h = nearH; near.parent = node; } } else if (closeList.Contains(near)) { if (nearF < near.f) { near.f = nearF; near.g = nearG; near.h = nearH; near.parent = node; openList.Add (near); closeList.Remove(near); } } else { near.f = nearF; near.g = nearG; near.h = nearH; near.parent = node; openList.Add (near); closeList.Remove(near); } } }
Main.cs
using UnityEngine; using System.Collections; using System.Collections.Generic; public class Main : MonoBehaviour { PathFinding pathFinding = new PathFinding(); Dictionary<int, Node> nodeDictionary = new Dictionary<int, Node>(); List<GameObject> lineList = new List<GameObject>(); // Use this for initialization void Start () { BuildNode(); BuildLine(); pathFinding.nodeDictionary = nodeDictionary; if (!pathFinding.Search(1, 6)) { Debug.Log("not found"); } else { Node node = pathFinding.goal; while (node != null) { node.SetPass(); node = node.parent; } } } private void BuildNode() { GameObject prefab = GameObject.CreatePrimitive(PrimitiveType.Cube); GameObject go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(-8, 4, 0); Node node = go.AddComponent<Node>(); node.id = 1; node.nearList.Add (2); node.nearList.Add (4); node.nearList.Add (5); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(-4, 4, 0); node = go.AddComponent<Node>(); node.id = 2; node.nearList.Add (1); node.nearList.Add (3); node.nearList.Add (5); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(0, 4, 0); node = go.AddComponent<Node>(); node.id = 3; node.nearList.Add (2); node.nearList.Add (5); node.nearList.Add (6); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(-8, -4, 0); node = go.AddComponent<Node>(); node.id = 4; node.nearList.Add (1); node.nearList.Add (5); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(-4, -4, 0); node = go.AddComponent<Node>(); node.id = 5; node.nearList.Add (1); node.nearList.Add (2); node.nearList.Add (3); node.nearList.Add (4); node.nearList.Add (6); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); node.SetBlock(); go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(0, -4, 0); node = go.AddComponent<Node>(); node.id = 6; node.nearList.Add (3); node.nearList.Add (5); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); go = GameObject.Instantiate(prefab); go.transform.position = new Vector3(4, -4, 0); node = go.AddComponent<Node>(); node.id = 7; node.nearList.Add (6); nodeDictionary.Add(node.id, node); go.name = node.id.ToString(); GameObject.Destroy(prefab); } private void BuildLine() { int i = 1; GameObject prefab = new GameObject(); GameObject go = GameObject.Instantiate(prefab); LineRenderer lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[1].transform.position); lr.SetPosition(1, nodeDictionary[2].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[1].transform.position); lr.SetPosition(1, nodeDictionary[4].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[1].transform.position); lr.SetPosition(1, nodeDictionary[5].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[2].transform.position); lr.SetPosition(1, nodeDictionary[5].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[4].transform.position); lr.SetPosition(1, nodeDictionary[5].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[2].transform.position); lr.SetPosition(1, nodeDictionary[3].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[3].transform.position); lr.SetPosition(1, nodeDictionary[5].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[3].transform.position); lr.SetPosition(1, nodeDictionary[6].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[5].transform.position); lr.SetPosition(1, nodeDictionary[6].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); ++i; go = GameObject.Instantiate(prefab); lr = go.AddComponent<LineRenderer>(); lr.SetPosition(0, nodeDictionary[6].transform.position); lr.SetPosition(1, nodeDictionary[7].transform.position); lineList.Add(go); go.name = "Line"+i.ToString(); GameObject.Destroy(prefab); } // Update is called once per frame void Update () { } }
恋愛ラボ
女子中学校に通う女の子たちがどうすれば男の子と出会えるかを妄想する4コマ漫画。
登場人物マキの妄想が面白い。
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2008/03/07
- メディア: コミック
- 購入: 3人 クリック: 112回
- この商品を含むブログ (89件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2013/06/28
- メディア: Kindle版
- この商品を含むブログを見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2009/07/07
- メディア: コミック
- 購入: 2人 クリック: 21回
- この商品を含むブログ (36件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2009/12/26
- メディア: コミック
- 購入: 5人 クリック: 37回
- この商品を含むブログ (38件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2010/11/06
- メディア: コミック
- 購入: 2人 クリック: 33回
- この商品を含むブログ (29件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2013/06/28
- メディア: Kindle版
- この商品を含むブログを見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2012/11/22
- メディア: コミック
- 購入: 2人 クリック: 8回
- この商品を含むブログ (18件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2013/07/04
- メディア: コミック
- この商品を含むブログ (22件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2013/09/05
- メディア: コミック
- この商品を含むブログ (14件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2014/09/05
- メディア: コミック
- この商品を含むブログ (8件) を見る
- 作者: 宮原るり
- 出版社/メーカー: 芳文社
- 発売日: 2015/08/07
- メディア: コミック
- この商品を含むブログを見る